Main Content

Generate a PDF Document with Page Borders

This example generates a PDF document that has solid, red, 0.5-point borders positioned 20 points from the page margins.

Import the DOM API package so that you do not have to use long, fully qualified class names.

import mlreportgen.dom.*;

Create a PDF document.

d = Document("myDocument","pdf");

Create a PageBorder object and specify the style, color, width, and margin for all border segments. For PDF Documents, the margin of a border segment specifies the distance between the segment and the page margin.

pageBorder = PageBorder("solid","red","0.5pt","20pt");

Set the PageBorder property of the layout associated with the document to the PageBorder object.

d.CurrentPageLayout.PageBorder = pageBorder;

Add text to the document. Close and view the document.

append(d,"The solid, red, 0.5-point border segments are twenty points from the margins.");

See Also

| | | |

Related Topics