Table of Contents
- Getting Started
- EO.Pdf
- Overview
- Installation and Deployment
- Using HTML to PDF
- Using PDF Creator
- Using PDF Creator
- Getting Started
- Advanced Formatting Techniques
- Interactive Features
- Low Level Content Objects
- Working with Existing PDF Files
- Using in Web Application
- Advanced Topics
- EO.Web
- EO.WebBrowser
- EO.Wpf
- Common Topics
- Reference
Page Columns and Margins |
Overview
AcmRender takes one or more AcmPageLayout objects through its constructor. The AcmPageLayout allows you to set page margins and divide a page into multiple columns.
Setting Page Size
By default, AcmRender creates new pages using standard letter size (8.5 inch by 11 inch). You can call SetDefPageSize on the AcmRender to set the default page size:
//Create a new AcmRender object with page size //set to 11 inch by 8.5 inch (landscape mode) AcmRender render = new AcmRender(doc); render.SetDefPageSize(new System.Drawing.SizeF(11f, 8.5f));
Alternative, you can also use AcmPageLayout object to configure each page's size separately. See the section below for more details.
Setting Page Margins
The following code creates an AcmPageLayout object that sets the page margin to 0.5 inch on all sides:
//Create a new AcmPageLayout object with margin //set to 0.5 inch on all sides AcmPageLayout pageLayout = new AcmPageLayout(new AcmPadding(0.5f)); //Use it to create an AcmRender object AcmRender render = new AcmRender(doc, pageLayout);
AcmPageLayout object can also be used to configure page size. The following code creates a new AcmPageLayout that sets the new page size to 11 inch by 8.5 inch (landscape mode):
//Create a new AcmPageLayout object with margin //set to 0.5 inch on all sides and page size set //to 11 by 8.5 AcmPageLayout pageLayout = new AcmPageLayout( new System.Drawing.SizeF(11f, 8.5f), new AcmPadding(0.5f)); //Use it to create an AcmRender object AcmRender render = new AcmRender(doc, pageLayout);
Creating Multiple Columns in a Page
The following code creates an AcmPageLayout object that sets the page margin to 0.5 inch on all sides and also divide the page into two columns:
//Create a new AcmPageLayout object with margin //set to 0.5 inch on all sides and also creates //two columns AcmPageLayout pageLayout = new AcmPageLayout(new AcmPadding(0.5f), new AcmColumn(0.5f, 3f), new AcmColumn(4.5f, 3f)); //Use it to create an AcmRender object AcmRender render = new AcmRender(doc, pageLayout);
The above code defines two columns. The first column starts at 0.5 inch and is 3 inches wide. The second column starts at 4.5 inch and is also 3 inches wide. When using this render to render contents, the contents flow from top to the bottom in the first column first, then the second column, then the first column on the second page, then the the second column on the second page, and so on.
You can pass multiple AcmPageLayout objects to the AcmRender object. For example,
//Create the first AcmPageLayout object. This layout //is used for the first page AcmPageLayout pageLayout1 = new AcmPageLayout(new AcmPadding(0.5f), new AcmColumn(0.5f, 3f), new AcmColumn(4.5f, 3f)); //Create a second AcmPageLayout object. This layout //has only one column and is used for the second //page and any page after it. AcmPageLayout pageLayout2 = new AcmPageLayout(new AcmPadding(0.5f)); //Create a new AcmRender object using these two //AcmPageLayout objects AcmRender render = new AcmRender(doc, pageLayout1, pageLayout2);
The above code divide the first page into two columns and does not divide page for the second page and any page after it. Note the second AcmPageLayout object also applies to the third page and so on because the last AcmPageLayout object is being repeated until the render finishes.
Rendering from the Middle of a Document
A second AcmRender constructor allows you to render from the middle of the document. This can be useful if a document needs to go through different rendering stages that renders different sections of the document.
The following code start rendering at the middle of the second page:
//Get the second page, this assumes "doc" is a PdfDocument //object and it already have at least two pages PdfPage startPage = doc.Pages[1]; //Start rendering at 4 inches from the top on the second page AcmRender render = new AcmRender(startPage, 4f);