PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

How to import page and preserve orientation?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3543
Page 1 of 1

Author:  yinso [ Tue Feb 21, 2017 12:07 am ]
Post subject:  How to import page and preserve orientation?

Hi,

I'm trying to import a landscape page, but after the import it appears that the orientation is no longer preserved.

The code is basically as follows:

Code:
PdfDocument target = new PdfDocument();
PdfDocument source = PdfReader.Open('source.pdf', PdfDocumentOpenMode.Import);
foreach (PdfPage srcPage in source.Pages) {
  PdfPage added = target.AddPage(srcPage); // the orientation appears not preserved.
}
target.Save('target.pdf');


So, if the source page has the following width, height & orientation:

Code:
width = 3024, height = 2016, orientation = Landscape


Once added it becomes

Code:
width = 2016, height = 3024, orientation = Portrait


How can I fix this issue? Thanks.

Author:  Thomas Hoevel [ Tue Feb 21, 2017 9:05 am ]
Post subject:  Re: How to import page and preserve orientation?

Hi!

The recommended fix is described here:
viewtopic.php?p=9591#p9591

Comment some lines in "internal PdfPage(PdfDictionary dict)" and recompile PDFsharp.

Or try the fix from the post above - just a change in your code, no change in PDFsharp required.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/