Hi Team,
I have a complex way of generating a complete form using aspose.words.tables within aspose.words. But I am finding it difficult to place this built table inside a pdf file which is in memory. Our requirement is to construct a pdf document and keep adding to it until it is done and then save it.
For example, we generate information from a table using aspose.pdf, and then generate a form in table format using aspose.words (we had to use this due to some column width restrictions) these two should appear one after the other. There maybe any combination of such tables.
In short, it would be like adding a pdf table and convert the builder into a pdf object - preferably so that they could technically appear in the same page and so on.
I have attached a sample of what my word looks like.
Please check and let me know!
Is this conversion possible in apose.words?wordtrial.pdf (68.6 KB)
@SumithaS You can save only the whole document to PDF. You can achieve this in memory. For example:
Document doc = new Document(@"C:\Temp\in.docx");
MemoryStream ms = new MemoryStream();
doc.Save(ms, SaveFormat.Pdf);
You should note that PDF documents are fixed page document and all elements are absolutely positioned on pages. However, if I understand correctly, your scenario supposes that the content should be reflowed according to the added content. I am afraid, this is not possible with PDF document. In this case, I would suggest you to generate the whole report using Aspose.Words as a flow document and then save the generated document to PDF.
Hi Alexey Noskov,
Sorry for the late reply. Thank you for your response!
Considering that we can’t add a word object and add it to a pdf page,iIs it possible for me to convert a single page word document to pdf and then add that to an existing pdf that is still in memory?
for example, i generate a table in word, convert that to a single pdf page and then add that as the next page in a pdf document that is still being created?
Thanks in advance!
@SumithaS Sure, you can convert a single page of MS Word document to PDF, simply specify PageSet in PdfSaveOptions:
Document doc = new Document(@"C:\Temp\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.PageSet = new PageSet(0); // Convert only the first page.
doc.Save(@"C:\Temp\out.pdf", opt); // You can save to stream
Then you can use Aspose.PDF to merge the generated PDF document with your existing PDF:
https://docs.aspose.com/pdf/net/merge-pdf-documents/
1 Like
Thank you! I will try this out and let you know. Appreciate it!
1 Like