We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to export PDF document as metafile and save as EMF?

The PDF viewer for WF allows the user to export pages of the PDF document as Metafile, which is a vector format which does not lose quality when zooming.

Directly saving the Metafile image to disk with *.emf extension will save the resultant in scalar format which would result in quality loss. Here in the KB we have explained the way to save the metafile in *.emf format, which does not lead to quality loss.


private PdfViewerControl viewer = new PdfViewerControl();

viewer.Load("../../Data/HTTP Succinctly.pdf");

Metafile[] images ;


            if (allpageBtn.Checked)


                images = this.viewer.ExportAsMetafile(0, viewer.PageCount - 1);




                images = this.viewer.ExportAsMetafile((int)fromPage.Value - 1, (int)toPage.Value - 1);



            foreach (Metafile image in images)



                //Create new MemoryStream

                System.IO.MemoryStream metafileStream = new System.IO.MemoryStream();

                System.Drawing.Graphics OffScreenDC = System.Drawing.Graphics.FromHwndInternal(IntPtr.Zero);

                System.Drawing.Imaging.Metafile wrappedMetaFile = new System.Drawing.Imaging.Metafile(metafileStream, OffScreenDC.GetHdc(), System.Drawing.Imaging.EmfType.EmfOnly);


                //Draw image

                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(wrappedMetaFile);

                g.DrawImage(image, 0, 0);



                //Write to file

                System.IO.FileStream wfile = new System.IO.FileStream("../../Output/Output" + Guid.NewGuid().ToString() + ".emf", System.IO.FileMode.Create);






Please find the sample from below link:


Article ID: Published Date: Last Revised Date: Platform: Control:
9243 09/04/2018 09/20/2018 Windows Forms PdfViewer
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon