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.

Wed Jan 10, 2024 6:29 am

We are trying to compress the pdf document using Spire.PDF for .NET image compression but its giving exception System.ArgumentException: 'Parameter is not valid.'
. Please help us fix this issue.
Following code is used for the compression
PdfCompressor compressor = new PdfCompressor(pdfFilePath);
TextCompressionOptions textCompression = compressor.Options.TextCompressionOptions;
textCompression.CompressFonts = true;
ImageCompressionOptions imageCompression = compressor.Options.ImageCompressionOptions;
imageCompression.ImageQuality = ImageQuality.High;
imageCompression.ResizeImages = true;
imageCompression.CompressImage = true;
compressor.CompressToFile(outputFilePath);

The product version used is Spire.Pdf for .NET 9.11.4 . The OS is Windows 10, 64-bit and region India. The application is Web application with .Net Framework 4.8.
Stack Trace:
at System.Drawing.Bitmap..ctor(Image original, Int32 width, Int32 height)
at sprㄑ.뎛(spr肛 A_0)
at sprㄑ.뉦(spr茅 A_0)
at sprオ.뉦(spr첦 A_0)
at spr촍.뉦(PdfDocumentBase A_0, String A_1)
at Spire.Pdf.Conversion.Compression.PdfCompressor.CompressToFile(String filePath)

preludesys
 
Posts: 1
Joined: Wed May 24, 2023 1:38 pm

Wed Jan 10, 2024 7:06 am

Hello,

Thank you for your inquiry.
Based on the information you provided, I simulated a PDF file and conducted preliminary testing using the code you provided. However, I was unable to reproduce the issue you mentioned. I used Spire.PDF Pack Version 10.1, and your license file is valid for this version.
I kindly request that you upgrade to this version and conduct another round of testing. If the issue persists after the update, please provide us with the PDF file you used for testing. This will enable us to investigate the matter further. You could attach it here or send it to us via email ([email protected] ). Thank you in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Thu Jan 18, 2024 2:49 pm

Getting same error..

Running on IIS ASP.NET 4.8 Framework C#
Spire.PDF 10.1.0

I can confirm this cause an error

If I comment out the following parameter, I don't get this error. I can't post my PDF example as it has PII. Does seem it has to be a specific PDF file. In my case the original file came to me as a scanned document pdf from probably a office scanner.

//Resize images
imageCompression.ResizeImages = true;


Code: Select all
//Load a PDF document while initializing the PdfCompressor object
PdfCompressor compressor = new PdfCompressor(dirpath);

//Get text compression options
TextCompressionOptions textCompression = compressor.Options.TextCompressionOptions;

//Compress fonts
textCompression.CompressFonts = true;

//Unembed fonts
textCompression.UnembedFonts = true;

//Get image compression options
ImageCompressionOptions imageCompression = compressor.Options.ImageCompressionOptions;

//Set the compressed image quality
imageCompression.ImageQuality = ImageQuality.High;

//Resize images
imageCompression.ResizeImages = true;

//Compress images
imageCompression.CompressImage = true;

//Save the compressed document to file
compressor.CompressToFile(newdirpath);

motogeek
 
Posts: 17
Joined: Tue Mar 16, 2021 4:18 am

Fri Jan 19, 2024 1:51 am

Hello,

Thank you for your feedback.
Based on your description, I simulated a scanned PDF document and retested the issue. However, I was still unable to reproduce the problem you mentioned. In order to investigate your issue quickly and effectively, could you please provide the PDF file you used for testing? Please ensure that any sensitive data is removed, as we will only be using it for testing and investigating your specific problem. You could attach it here or send it to us via email ([email protected]). Thanks in advance.
Please be assured that we treat our customers' documents with absolute confidentiality and they are solely used for testing and addressing customer issues.

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