merging a document into a new document
i have already achieved the desired functionality when the 'template document is saved on the file system.
'This code works when the template document is saved to the filesystem
Dim page As New Page(PageSize.A4, PageOrientation.Portrait)
document.Pages.Add(page)
If Not letterheadfilepath.Equals(String.Empty) Then
Dim letterheadcontents As ImportedPageContents = New ImportedPageContents(letterheadfilepath, 1)
Dim letterheaddata As ImportedPageData = New ImportedPageData(letterheadcontents, 0, 0, 1)
page.Elements.Add(letterheaddata)
End If
now i want to load the template document from a stream(from a zip file)
My problem is how to get importedpagecontents from importedpage - i just cannot see hwo to do it and i am sure it must be trivial
Dim page As New Page(PageSize.A4, PageOrientation.Portrait)
document.Pages.Add(page)
If Not letterheadfilename.Equals(String.Empty) Then
Dim templatedoc As New ceTe.DynamicPDF.Merger.PdfDocument(zipfile(letterheadfilename).OpenReader)
Dim mypage As ImportedPage = New ImportedPage(templatedoc.GetPage(1))
'THIS IS THE LINE WHERE I CANNOT WORK OUT HOW TO GET FROM ImportedPage to ImportedPageContents
Dim letterheadcontents As New ImportedPageContents(??????????????????)
Dim letterheaddata As ImportedPageData = New ImportedPageData(letterheadcontents, 0, 0, 1)
page.Elements.Add(mypage.Elements) '
End If
thanks
merger - pdfdocument from stream
Re: merger - pdfdocument from stream
Support · Jul 23, 2012Hello,
You will need to import the contents and load into the ImportedPageContents object and then you will need to build ImportedPageData object using ImportedPageContents. You will need to add the ImportedPageData to a page and add the page to the Document. This will work for you. Below is the sample code for it.
'Edit the already existing PDF with PdfDocument class.
'Below we used code to edit the PDF from file path similary you can use PDF stream.
Dim pdf As New PdfDocument("F:\temporary\DocumentC.pdf")
'Import the contents from the desired page.
Dim contents As New ImportedPageContents(pdf.Pages(0))
'Add the imported contents to the ImportedPageData.
Dim pageData As New ImportedPageData(contents, 0, 0)
Dim document As New Document()
Dim page As New Page()
'Add the ImportedPageData to the page.
page.Elements.Add(pageData)
document.Pages.Add(page)
document.Draw("C:\Mydocument.pdf")
If you continue getting the error then please send over the following details to our support team at: [^a|mailto:support@cete.com|opennewwindow|support@cete.com^] so that they can look into it further.
1.Exact version and build number of the DynamicPDF product dll.
2.Sample code using which we can recreate the error.
3.Input PDF document which you are using to import the contents.
4.Full stack trace of error message.
Thanks,
ceTe Software Support Team.
Re: merger - pdfdocument from stream
Forum member · Jul 27, 2012thank you for your incredibly quick reply and apologies for my slow response back to that.
thanks! that sample has solved my problem