Render PDF to EMF

Convert PDF, Printing
8/24/2015

PDF Rasterizer can also render a PDF page to to an EMF object (Enhanced Metafile). This format is graphical format which is commonly used in .NET applications and in printing.

1 using (FileStream fs = new FileStream(@"..\..\input.pdf", FileMode.Open, FileAccess.Read)) 2 { 3 Document d = new Document(fs); 4 Page page = d.Pages[0]; 5 6 Metafile metafile = null; 7 8 using (Graphics graphics = this.CreateGraphics()) 9 { 10 System.IntPtr hdc = graphics.GetHdc(); 11 metafile = new Metafile(hdc, new System.Drawing.RectangleF(0, 0, (float)page.Width, (float)page.Height), MetafileFrameUnit.Point); 12 graphics.ReleaseHdc(hdc); 13 } 14 15 using (Graphics metafileGraphics = Graphics.FromImage(metafile)) 16 { 17 metafileGraphics.SmoothingMode = SmoothingMode.AntiAlias; 18 page.Draw(metafileGraphics); 19 } 20 21 }