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.

Mon Nov 13, 2023 1:04 pm

This code does not compile:
Code: Select all
           PdfDocument doc = new PdfDocument();
           doc.LoadFromFile("sample.pdf");

           for (int i = 0; i < doc.Pages.Count; i++)
           {
               String fileName = String.Format("Sample-img-{0}.emf", i);
               using (Image image = doc.SaveAsImage(i, Spire.Pdf.Graphics.PdfImageType.Metafile, 300, 300))
               {
                   image.Save(fileName, System.Drawing.Imaging.ImageFormat.Emf);
               }
           }

I am getting error
Code: Select all
error CS0117: 'PdfImageType' does not contain a definition for 'Metafile'

I am using Spire.PDF 9.11.4

vjedlicka
 
Posts: 3
Joined: Fri Aug 18, 2023 4:54 pm

Tue Nov 14, 2023 1:46 am

Hello,

Thanks for your inquiry.
Please note that System.Drawing only supports vector graphics on Windows systems. As a result, converting PDF documents to metafile image types(PdfImageType.Metafile) is only supported on the .NET Framework platform.
Based on the information you provided, it seems that you are using a .NETCore project on a Windows system. Since .NETCore is a cross-platform framework, it does not support metafile image types. Therefore, your code will throw an error.
Thank you for your understanding.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Tue Nov 14, 2023 9:42 am

Thank you, I made a classic .NET app and it works.

However, the input PDF contains perfectly readable texts, and in the resulting EMF the texts are not readable. It looks like the PDF has been rasterized. Are there any options to keep it as a vector graphics?

vjedlicka
 
Posts: 3
Joined: Fri Aug 18, 2023 4:54 pm

Tue Nov 14, 2023 10:05 am

Hello,

Thanks for your feedback.
The unreadable text in the resulting EMF file you mentioned refers to the text being garbled? To help us investigate your issue quickly and efficiently, please provide your complete test project (include the input pdf file) and test environment (such as Windows7, 64bit and region setting (E.g. China, Chinese)). You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Nov 15, 2023 2:46 am

Hello,

Thanks for sharing the information via email.
I have tested the documents you provided and carefully compared the original document with the EMF files (both the one you provided and the one generated from my testing). I did not find any differences between them.
Could you please provide more details about the "text not readable in the EMF file"? Also, could you tell me the tool you used to view the EMF file?
Thank you for your cooperation.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF

cron