Merging two pages to a single page

Merging two pages to a single page

Forum member · Oct 16, 2007
I have two PDF documents that contain data that I would like to merge to a new document that has only a single page. Both original documenst are a single page, with the actual content less than half a page. I have been able to merge the two documents to a new document with two pages, but I really want to combine the documents so the new document is one page. How should I approach this? Bill Manring Wavefront Software, Inc.

Re: Merging two pages to a single page

Support · Oct 16, 2007
Hello Bill, Yes, you can add the two pages data to a single page of another PDF document without any problem by using the ImportedPageData or ImportedPageArea classes. The form fields will not be preserved when adding the pages in this way to another page. You can refer to the ImportedPageData class on our help documentation. Thanks, ceTe Software Support Team.

Re: Merging two pages to a single page

Forum member · Oct 16, 2007
Thanks for the reply. I did get it to work, here is the code: Dim mergeFileName As String = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "MergePDF.pdf") Dim MyDocument As Document = New Document() Dim MyPage As Page = New Page(PageSize.Letter, PageOrientation.Portrait, 1.0F) Dim MyImportedPageArea As ImportedPageArea = New ImportedPageArea(Me.txtHeaderFile.Text, 1, 0, 0, 1.0F) MyImportedPageArea.Contents.ClipLeft = 50 MyImportedPageArea.Contents.ClipTop = 0 MyImportedPageArea.Contents.ClipRight = 100 MyImportedPageArea.Contents.ClipBottom = 100 MyPage.Elements.Add(MyImportedPageArea) MyImportedPageArea = New ImportedPageArea(Me.txtDataFile.Text, 1, 50, 100, 1.0F) MyImportedPageArea.Contents.ClipLeft = 50 MyImportedPageArea.Contents.ClipTop = 0 MyImportedPageArea.Contents.ClipRight = 100 MyImportedPageArea.Contents.ClipBottom = 100 MyPage.Elements.Add(MyImportedPageArea) MyDocument.Pages.Add(MyPage) MyDocument.Draw(mergeFileName) My question is regarding the X and Y coordinates on the ImportedPageArea constructor. I manualy, by trial and error, came up with numbers that worked. I would like a little more intelligent and base it on the size of the contents of the first file. Is there a way I can tell where the data from the first file ends?

Re: Merging two pages to a single page

Support · Oct 16, 2007
Hello Bill, You can get the height and width of the ImportedPageArea by using the Height and Width properties of the ImportedPageArea class. In order to add the second imported page area you can calculate the Y coordinate using the Height of the first imported page area. You will have to add some padding to the height and use this as the Y coordinate for the second imported page area. Thanks, ceTe Software Support Team.

Re: Merging two pages to a single page

Forum member · Oct 16, 2007
I thought of this, but the Height and Width properties seem to return the Height and Width of the entire page, not just the contents. For example, they always return 692 and 512, which is much larger than the actual contents. Am I missing something?

Re: Merging two pages to a single page

Support · Oct 16, 2007
Hello, It looks like you are using the Height and Width property of the Page object and not the ImportedPageArea object. Please make sure that you use the Height and Width property of the ImportedPageArea object you are adding to the page. Thanks, ceTe Software Support Team

Re: Merging two pages to a single page

Forum member · Oct 16, 2007
I used the Height property of the ImportedPageArea Class. I also tried ImportedPageArea.Contents.Height. It returns the same value.

Re: Merging two pages to a single page

Support · Oct 16, 2007
Hello, The likely reason you get the value of height and width same as that of the PDF page size is because the PDF page you are importing is of the size 692 x 512. Thanks, ceTe Software Support Team

Re: Merging two pages to a single page

Forum member · Oct 16, 2007
I appreciate all of your responses. I think what you are saying is that I cannot tell the size of the contents in my PDF file, possibly because of how it was created in the first place. Even though the actual data is less than the full page, the PDF contents are defined as the whole page. Can I reach inside of PDF files, created outside of your software, and get access to individual data elements? The PDF file is just a series of lines of text. It is the header for a report that I am trying to combine with the detail data, which comes from a different source. Can I get access to the lines of text in the header file?

Re: Merging two pages to a single page

Support · Oct 17, 2007
Hello, You can get the height of the imported page area without any problem by using the Height property. Contents.Height gives the original height of the contents in the page. ImportedPageArea.Height gives the height of the area and it can be changed when scaling the area. We used the following code to add two areas one after the other without any problem. Dim mergeFileName As String = "C:\Temp\fw9AcroForm_03.pdf" Dim MyDocument As Document = New Document Dim MyPage As Page = New Page(PageSize.Letter, PageOrientation.Portrait, 1.0F) 'Scale is 0.5 for the area and it decreases the size and height Dim MyImportedPageArea As ImportedPageArea = New ImportedPageArea(mergeFileName, 1, 0, 0, 0.5F) MyPage.Elements.Add(MyImportedPageArea) MyImportedPageArea = New ImportedPageArea(mergeFileName, 1, 0, MyImportedPageArea.Height + 20, 0.5F) MyPage.Elements.Add(MyImportedPageArea) MyDocument.Pages.Add(MyPage) MyDocument.DrawToWeb() It is not possible to access the contents of an existing PDF documents. You can not read or extract the text or any contents of a PDF. You can add any new data or elements to the PDF and you can do the form filling using our product. Thanks, ceTe Software Support Team.