Free Support Forum - aspose.com

How to render System.Drawing.Imaging.Metafile into PDF pages, keep shapes separate and better quality

We are replacing PDFDocScout SDK with Aspose.PDF.

The PDFDocScout can render Metafile into PDF pages, and each shape(lines, rects, texts) is translated to PDF objects. (I can select text objects …)
We tried to use Page.AddImage() of Aspose.PDF to implement the same function, but we found the output is ONLY a Image. (I cannot select texts object in the PDF file.) In addition, the output quality is not as good as PDFDocScout.

Screenshot(left:PDFDocScout, right: Aspose) Capture.PNG (118.7 KB)

So I have 2 questions:

  • Is there a way to let us render EMF(System.Drawing.Imaging.Metafile) into PDF, and keep each shape separate?
  • Is there a way to improve the output quality?

@weibanban

You may please use following code snippet in order to improve the rendering quality of the image inside PDF:

var pdf = new Aspose.Pdf.Document();
var pdfImageSection = pdf.Pages.Add();
FileStream stream = new FileStream(dataDir + "emf.emf", FileMode.Open);
var image = new Aspose.Pdf.Image { ImageStream = stream };
image.IsApplyResolution = true;
pdfImageSection.Paragraphs.Add(image);
pdf.Save(dataDir + "EMF_With_DOM.pdf");

We regret to share that currently, this feature is not available in the API. However, would you kindly share your sample EMF file along with the expected PDF output? We will surely log a feature request and share the ticket ID with you.

Hi, I just noticed Aspose.Images SDK can do this job, but I encounter another problem: the font size is not translated correctly.

I posted another ticket and attached my EMF file there.

@weibanban

Yes, Aspose.Imaging also offers this feature and you can use that API in case you have its license. Nevertheless, your other inquiry will definitely be served accordingly.