Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jun 04, 2014 1:55 pm

Hello Spire Team,

I am evaluating Spire PDF for .Net. My main goal is to create PDF from EMF files.
See Code below:

Code: Select all

            //Create a pdf document with a section and page added.
            PdfDocument doc = new PdfDocument();
             doc.FileInfo.Version = PdfVersion.Version1_4;
         
             
             doc.CompressionLevel = PdfCompressionLevel.None;

             //adjust page size, and add to Document
             Size size = new Size(1754,1240);
             PdfMargins margins = new PdfMargins();
             margins.Top = 0f;
             margins.Bottom = 0f;
             margins.Left = 0f;
             margins.Right = 0f;
             PdfPageBase page = doc.Pages.Add(size, margins , PdfPageRotateAngle.RotateAngle0, PdfPageOrientation.Landscape);
             
            //add section, and ajust size
             PdfSection section = doc.Sections.Add();
             section.PageSettings.Size = size;
           
            //Load a EMF image from system
             PdfImage image = PdfImage.FromFile(@"C:\images\emf\Ocr2.EMF");

             //adjust size, and drwa Image
             float widthFitRate = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width;
             float heightFitRate = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height;
             float fitRate = Math.Max(widthFitRate, heightFitRate);
             float fitWidth = image.PhysicalDimension.Width / fitRate;
             float fitHeight = image.PhysicalDimension.Height / fitRate;
             page.Canvas.DrawImage(image, 0, 0, fitWidth, fitHeight);
           
            //save and launch the file
            string outPath = @"C:\Windows\Temp\spireEmfTopdf.pdf";
            doc.SaveToFile(outPath);
           
           doc.Close();
           System.Diagnostics.Process.Start(outPath);



The resulting PDF doesnt display the all content(Text,Image) from the EMF file. Only some Text. No images from the EMF.
Am i missing something/ or doing wrong?

Art
 
Posts: 1
Joined: Mon Nov 05, 2012 8:09 am

Thu Jun 05, 2014 2:30 am

Hello,

Thanks for your evaluating our product. Please attach your emf file for testing. Kindly note that zip it before uploading.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.PDF