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.

Thu Dec 05, 2019 2:11 pm

Hi, I'm trying to convert a pdf to an image, but it fails pretty fast. I'm using your code from the tutorial:
Code: Select all
            
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"C:\Program Files (x86)\e-iceblue\Spire.Pdf-Fe\Demos\Data\SampleB_1.pdf");
Image bmp = doc.SaveAsImage(0);
Image emf = doc.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Metafile);
...etc


line doc.SaveAsImage(0) is ok but line doc.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Metafile) gives an exception, "Indata string had wrong format" with this stack trace:
Code: Select all
vid System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
   vid sprᢥ.ᜀ(String[] A_0)
   vid sprᢥ.ᜀ(sprᤋ A_0)
   vid sprᢥ.᜺()
   vid sprᢜ.ᜀ(Boolean A_0, Int32 A_1, Boolean A_2, Boolean A_3, Boolean A_4)
   vid sprᢜ.ᜁ(Boolean A_0, Single A_1, Boolean A_2, Boolean A_3)
   vid Spire.Pdf.PdfDocumentBase.ᜀ(Boolean A_0, Int32 A_1)
   vid Spire.Pdf.PdfDocumentBase.ᜀ(Int32 A_0, PdfImageType A_1)
   vid Spire.Pdf.PdfDocument.SaveAsImage(Int32 pageIndex, PdfImageType type)
   vid WebTime.Filesave.makePdfImage(Stream stream) i c:\MyProjects\webtimeaj\App_Code\FileSave.cs:rad 245


"vid" is "at" in Swedish by the way.

I'm using spire.pdf_5.11.18 NET4.6

Any clues what might have gone wrong?

Klodvig1
 
Posts: 2
Joined: Wed Dec 04, 2019 4:49 pm

Fri Dec 06, 2019 3:08 am

Hi,

Thanks for your inquiry.
I did an initial test with the Spire.PDF 5.11.18, but didn't encounter the issue when exectuing the second method. To help us further investigate your issue, please provide the following information. Thanks in advance.

1) The type of your application, such as Winform app.
2) Your testing environment, such as OS infromation (E.g. Windows 7, 64bit) and Region setting (E.g. China, Chinese).

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Fri Dec 06, 2019 6:16 am

Thanks for your swift reply!

The code is running on a webserver, using NET 4.6.1. Server application language is C#. OS is Windows 10, 64 bit, as per latest update. OS language is Swedish. Current localization of the web server application (that runs the pdf-conversion) is most likely Swedish, (which, among other things, means it most likely expects string representations of floats should have comma as decimal delimiter).

I'm happy to provide you with more details if neccessary.

Thanks
Michael

Klodvig1
 
Posts: 2
Joined: Wed Dec 04, 2019 4:49 pm

Fri Dec 06, 2019 7:36 am

Dear Michael,

Thank you so much for your information.
I have reproduced your issue on my side. The issue is related to the current culture. To get rid of it, please refer to the following code to set it as InvariantCulture. Any question, please feel free to write back.
Code: Select all
CultureInfo cc = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(Server.MapPath("SampleB_1.pdf"));
System.Drawing.Image bmp = doc.SaveAsImage(0);
System.Drawing.Image emf = doc.SaveAsImage(0, PdfImageType.Metafile);
//...
Thread.CurrentThread.CurrentCulture = cc;
Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Wed Dec 25, 2019 7:54 am

Dear Michael,

Greetings from E-iceblue.
Has your issue been resolved?
Thanks in advance for your valuable feedback and time.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF

cron