This is a migrated thread and some comments may be shown as answers.

PDF Margins and Orientation

1 Answer 1006 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Trey
Top achievements
Rank 2
Trey asked on 28 Sep 2015, 05:02 PM

Could an example be provided on how to create a PDF and set the Margins and Orientation for WinForms?

And if this involves the orientation involves use of PageRotation, could you please include how to rotate the text to match the rotation?

1 Answer, 1 is accepted

Sort by
1
Tanya
Telerik team
answered on 01 Oct 2015, 11:42 AM
Hello Trey,

You could use the API of RadFixedDocumentEditor to set the margins and rotation of a page. Please, refer to the snippet below, which demonstrates how you could achieve this:
RadFixedDocument document = new RadFixedDocument();
using (RadFixedDocumentEditor editorDocument = new RadFixedDocumentEditor(document))
{
    editorDocument.SectionProperties.PageMargins = new Padding(300);
    editorDocument.SectionProperties.PageRotation = Rotation.Rotate90;       
 
    editorDocument.InsertRun("Test Run.");
    editorDocument.InsertLine("Some longer test sentence.");
    editorDocument.InsertRun("Another Run.");
}

Using the PageRotation property of the SectionProperties object, the text will be automatically rotated with the page.

Hope this is helpful.

Regards,
Tanya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Alexandre
Top achievements
Rank 1
Iron
Iron
commented on 10 May 2022, 07:24 PM

but if you already have document, how you can rotate it?

snipped above just rotate text you added after setting PageRotaion.

Svilen
Telerik team
commented on 11 May 2022, 02:39 PM

Hello, Alexandre,

My name is Svilen and it would be my pleasure to assist here.

You can use the RadFixedPage's Rotation property:

RadFixedPage page = document.Pages[0]; 
page.Rotation = Rotation.Rotate270; 

 

You can also do so by using the PdfStreamWriter, which is a good tool for manipulating existing content without modifying it internally. Our Developer Focused Examples contain a great way of manipulating pages that makes use of the PdfStreamWriter - Manipulate pages. I've modified it in a way that achieves your goal in a small sample project, which I've attached here.

I hope it helps. 

Regards,
Svilen
Progress Telerik

Tags
PdfProcessing
Asked by
Trey
Top achievements
Rank 2
Answers by
Tanya
Telerik team
Share this question
or