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.

Tue Mar 30, 2021 5:51 pm

Hi,
We have a problem converting the PDF file to an image in Thai language and 2 from 10 times the same problem in English.
It’s Urgent !

Error : Parameter is not valid. responseCode=2004
ToImageController 2004-0 Stack Trace: at Boj.DM.WebAPI.FileConverter.Controllers.ToImageController.SaveAsImage(PdfDocument document) in C:\VS\dm.fileconverter\Boj.DM.WebAPI.FileConverter\Controllers\ToImageController.cs:line 211
at Boj.DM.WebAPI.FileConverter.Controllers.ToImageController.ConvertImage(Nullable`1 conversionFormat, String fileBytes) in C:\VS\dm.fileconverter\Boj.DM.WebAPI.FileConverter\Controllers\ToImageController.cs:line 177
at Boj.DM.WebAPI.FileConverter.Controllers.ToImageController.Post(ToImageRequestModel request) in C:\VS\dm.fileconverter\Boj.DM.WebAPI.FileConverter\Controllers\ToImageController.cs:line 40. InnerException:System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.MeasureString(String text, Font font, PointF origin, StringFormat stringFormat)

at spr?.?(Font A_0, String A_1)
at spr?.?(spr? A_0, spr? A_1, Font A_2, Char A_3)
at spr?.?(spr? A_0, spr? A_1, Graphics A_2, PointF A_3)
at spr?.?(Graphics A_0, spr? A_1, Boolean A_2)
at spr?.?(String A_0, spr? A_1, String A_2, Boolean A_3)
at spr?.?(String[] A_0, String A_1)
at spr?.?(spr? A_0)
at spr?.?(Boolean A_0)
at spr?.?(Graphics A_0, spr? A_1, spr? A_2)
at spr?.?(String[] A_0)
at spr?.?(spr? A_0)
at spr?.?(Boolean A_0)
at Spire.Pdf.PdfDocumentBase.?(Int32 A_0, Int32 A_1, Int32 A_2)
at Spire.Pdf.PdfDocumentBase.?(Int32 A_0, PdfImageType A_1, Int32 A_2, Int32 A_3)
at Boj.DM.WebAPI.FileConverter.Controllers.ToImageController.SaveAsImage(PdfDocument document) in C:\VS\dm.fileconverter\Boj.DM.WebAPI.FileConverter\Controllers\ToImageController.cs:line 202

in dev everything is ok, in production, when we convert many files, we get this error in Converting pdf to Image :
ConverImage(ConversionFormat,FileType) : one of these 2 params in not valid AND responseCode=2004
can someone tell me when we can receive parameter is not valid if i use the same files every time, and most of the time every thing is ok ?
we have spire.pdf version : 4.11.0.2040, and we have upgrade windows from 2008 to 2016.

thanks

daveva
 
Posts: 1
Joined: Wed Jan 02, 2019 5:56 pm

Wed Mar 31, 2021 2:50 am

Hello,

Thanks for your inquiry.

Since you are using a very old version of Spire.PDF, I’d like to suggest you download the latest Spire.PDF Pack(Hot Fix) Version:7.3.3 and refer to the following code to have a try.
Code: Select all
            String file = @"ToImage.pdf";
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(file);

            for (int i = 0; i < doc.Pages.Count; i++)
            {
               
                String fileName = String.Format("ToImage-img-{0}.png", i);
                using (Image image = doc.SaveAsImage(i, 300, 300))
                {
                    image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                }
            }


If there are still any issues, please provide us with your input file for further investigation. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF