PDF Xpress for .NET - User Guide > How To > Modify PDF Document Content > Render to Device Context |
To render a PDF document directly to a Device Context, do the following:
This will render the document directly to the Device Context, in this case the printer.
C# Example |
Copy Code
|
---|---|
using System; using System.Drawing; using System.Drawing.Printing; using Accusoft.PdfXpressSdk; namespace DC { class RenderToDC { static Document doc; static RenderDcOptions options; static void Main(string[] args) { using (PdfXpress pdf = new PdfXpress()) { try { pdf.Initialize(@"C:\Users\Public\Documents\Accusoft\PDFXpress\v7.0\Support\Font", @"C:\Users\Public\Documents\Accusoft\PDFXpress\v7.0\Support\CMap"); doc = new Document(pdf, "C:\\myfile.pdf"); options = new RenderDcOptions(); options.ForDeviceTechnology = DeviceTechnology.Printer; PrintDocument printer = new PrintDocument(); printer.PrintPage += new PrintPageEventHandler(PrintPage); printer.Print(); } finally { if (doc != null) { doc.Dispose(); doc = null; } } } } static void PrintPage(object sender, PrintPageEventArgs e) { doc.RenderPageToDeviceContext(0, e.Graphics, options); } } } |