Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Page size issues when appending existing pdfs

$
0
0
Hi,

I am using the following simple piece of code to merge several pdfs in to a single pdf. The last two pdfs each contain a single page that is A3 sized and landscape orientation. All pages of the other documents are regular portrait A4. If I look at the resultant pdf all pages are there and all are displayed correctly. The last two pages of the merged document are indeed A3 landscaped pages when viewed with Adobe Acrobat Reader.

However, if I look at the PageInfo properties of the pages in either the outputDocument.Pages or reopen.Pages collections, they are always 842.0 height and 595.0 width and non-landscaped. The media box, crop box, rectangle, etc. of the last two pages are 842 x 1190 as would be expected of a landscape A3 page, but the PageInfo structure is incorrect.

            var inputDocument2 = new Document(@"D:\append-2.pdf");            var inputDocument3 = new Document(@"D:\append-3.pdf");            var inputDocument4 = new Document(@"D:\append-4.pdf");            var inputDocument5 = new Document(@"d:\ml-spread-report-hc01-abs0011-2010-11.pdf");            var outputDocument = new Document();            outputDocument.Pages.Add(inputDocument2.Pages);            outputDocument.Pages.Add(inputDocument3.Pages);            outputDocument.Pages.Add(inputDocument4.Pages);            outputDocument.Pages.Add(inputDocument5.Pages);            outputDocument.Save(@"D:\output.pdf");            var pageEditor = new PdfPageEditor(outputDocument);            var pageCount = pageEditor.GetPages();            for (int pageNum = 1; pageNum <= pageCount; pageNum++)            {                var pageSize = pageEditor.GetPageSize(pageNum);            }            var reopen = new Document(@"d:\output.pdf");

Additionally, if I look at the pageSize value received from the PdfPageEditor class the page sizes do come through correctly, it is only the page info within the Pages class received from the Document.Pages property that are incorrect.

Am I doing something wrong? I need to do some further operations, positioning some floating boxes to cover the existing page header and footer information before replacing them, so I need to know the sizes of the pages.

Lastly, can you recommend a better way of removing the header and footers from the existing pdf files and then merging them in to a new document that has a consistent (programatically generated) header and footer across all pages?

Edit: Oh, and I am using the 9.2.1.0 version of the Aspose.Pdf library.


Viewing all articles
Browse latest Browse all 3131

Trending Articles