Hey, Mario.
Could you tell me how to change Page view (Landscape to portrait)? Without rotation content!
For example: I have the input PDF (A4 Landscape) and want to get the same text in DOCX or PDF (A4 Portrait).
Thanks
Hey, Mario.
Could you tell me how to change Page view (Landscape to portrait)? Without rotation content!
For example: I have the input PDF (A4 Landscape) and want to get the same text in DOCX or PDF (A4 Portrait).
Thanks
Hi,
GemBox.Document has two types of PDF readers: Logical and HighFidelity:
With a logical PDF reader, the Paragraph
and Table
elements will be recognized from the PDF content and placed in the normal flow of the DocumentModel
content.
With a high-fidelity PDF reader, the PDF content is imported into a DocumentModel
with elements that have absolute positioning.
When changing the page’s orientation, the absolutely positioned elements won’t be affected; only elements in normal flow will be affected.
So, try using the following:
var pdfLoadOptions = new PdfLoadOptions() { LoadType = PdfLoadType.Logical };
var document = DocumentModel.Load("Input.pdf", pdfLoadOptions);
foreach (var section in document.Sections)
section.PageSetup.Orientation = Orientation.Portrait;
document.Save("Output.pdf");
I hope this helps.
Regards,
Mario
Maybe I can do the same using Gembox.PDF?
No, I’m afraid that GemBox.Pdf doesn’t support saving to DOCX.
What if PDF (Landscape) to PDF (Portrait) by Gembox.PDF. Is it possible?
Or maybe you have any example: hoe to generate PDF landscape or PDF portrait content?
If I understood correctly what you want to achieve, I don’t think that’s possible in PDF because in it the whole content is defined with absolute positioning.
If I perhaps misunderstood you, can you send us a sample PDF in landscape and that same PDF content in portrait so I can observe your exact requirements?
Regarding generating PDF landscape, you just need to set the page’s width and height to the desired value by using the PdfPage.SetMediaBox()
method:
using var document = new PdfDocument();
var page = document.Pages.Add();
page.SetMediaBox(page.Size.Height, page.Size.Width);
document.Save("output.pdf");
Regards,
Mario
Thanks. Now I got a good result.
Because I thought that page.Rotate () - it’s mean Landscape or Portrait
Now, I see that page.SetMediaBox(page.Size.Height, page.Size.Width); works for me.
Thanks