Usage

The code belows shows how to use the SmartDocumentPaginator to generate an XPS document from a FlowDocument:

// "Dots per centimeter"
double DPC = 96 / 2.54;

FlowDocument document = LoadDocument();
var paginator = new SmartDocumentPaginator(document);
paginator.PageSize = new Size(21 * DPC, 29.7 * DPC); // A4
paginator.Margin = new Thickness(2 * DPC); // 2cm

using (Package container = Package.Open("MyDocument.xps", FileMode.Create))
{
   using (XpsDocument xpsDoc = new XpsDocument(container, CompressionOption.Maximum))
   {
      XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
      rsm.SaveAsXaml(paginator);
   }
}

Last edited Dec 30, 2011 at 3:35 AM by fallinor, version 1

Comments

No comments yet.