We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Losing content when adding pages from one document to another

I’ve only just started evaluating Aspose.pdf so might be missing something obvious.

When I add an HTML fragment in a paragraph to a document and save that document it works fine.

However, when I add the pages of that document to another document the new document is blank:

'add HTML as per ASPOSE EXAMPLE
Dim doc As Document = New Document()
Dim page As Page = doc.Pages.Add()
Dim h As HtmlFragment = New HtmlFragment(“TEST”)
page.Paragraphs.Add(h)

'this works as expected
'doc.save(“output.pdf”)


'create a new document and add the pages
Dim pd As New Aspose.Pdf.Document()
pd.Pages.Add(doc.Pages)

'doesn’t display HTML fragment
pd.Save(“output.pdf”)


Hi Ash,


Thanks for your interest in Aspose.

Please note while generating new PDF document using Aspose.Pdf.Document (New DOM approach) user can not manipulate page(document resources) before saving the PDF document. Because the PDF is created dynamically and in order to get real PDF document we should render its programming/dynamic model. So please save the document into stream and then reopen for further processing,

Dim ms As New MemoryStream()<o:p></o:p>

Dim doc As New Document()

Dim page As Page = doc.Pages.Add()

Dim h As New HtmlFragment("TEST")

page.Paragraphs.Add(h)

'this works as expected

doc.Save(ms)

doc = New Document(ms)

'create a new document and add the pages

Dim pd As New Aspose.Pdf.Document()

pd.Pages.Add(doc.Pages)

'doesn't display HTML fragment

pd.Save(myDir + "test_output.pdf")


Please feel free to contact us for any further assistance.


Best Regards,