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?