PDF Mosaic: How to manage page layout in .NET library


Home       Features       Download       Tutorial       Version History       License       Source Code

 

This sample shows how to create PDF documents with different page layouts using PDFMosaic library. You can specify the page layout to be used when the document is opened.

Theare are the following types of page layout:

  1. SinglePage – display one page at a time.
  2. OneColumn – display the pages in one column.
  3. TwoColumnLeft – display the pages in two columns, with odd-numbered pages on the left.
  4. TwoColumnRight – display the pages in two columns, with odd-numbered pages on the right.
  5. TwoPageLeft – display the pages two at a time, with odd-numbered pages on the left.
  6. TwoPageRight – display the pages two at a time, with odd-numbered pages on the right.


 

PDFDocument document = new PDFDocument();
PDFPage page = new PDFPage(PDFPaperFormat.A4);
 
PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 11);
PDFBrush brush = new PDFSolidBrush();
 
page.Canvas.DrawString("Lorem Ipsum is simply dummy text of the printing and typesetting industry.", font, brush, 10, 10);
page.Canvas.DrawString("Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,", font, brush, 10, 25);
page.Canvas.DrawString("when an unknown printer took a galley of type and scrambled it to make a type specimen book. ", font, brush, 10, 40);
page.Canvas.DrawString("It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.", font, brush, 10, 55);
page.Canvas.DrawString("It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, ", font, brush, 10, 70);
page.Canvas.DrawString("and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.", font, brush, 10, 85);
 
page.Canvas.DrawString("Contrary to popular belief, Lorem Ipsum is not simply random text. ", font, brush, 10, 100);
page.Canvas.DrawString("It has roots in a piece of classical Latin literature from 45 BC, ", font, brush, 10, 115);
page.Canvas.DrawString("making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia,", font, brush, 10, 130);
page.Canvas.DrawString("looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, ", font, brush, 10, 145);
page.Canvas.DrawString("and going through the cites of the word in classical literature, discovered the undoubtable source.", font, brush, 10, 160);
page.Canvas.DrawString("Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of \"de Finibus Bonorum et Malorum\" (The Extremes of Good and Evil) ", font, brush, 10, 175);
page.Canvas.DrawString("by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. ", font, brush, 10, 190);
page.Canvas.DrawString("The first line of Lorem Ipsum, \"Lorem ipsum dolor sit amet..\", comes from a line in section 1.10.32.", font, brush, 10, 205);
 
for (int i = 0; i < 8; ++i)
{
    document.Pages.Add(page);
}
 
foreach (PDFPageLayout layout in Enum.GetValues(typeof(PDFPageLayout)))
{
    document.PageLayout = layout;
    document.Save(layout + "Layout.pdf", true);
}

 


Home       Features       Download       Tutorial       Version History       License       Source Code