Hello,
Thanks for your inquiry!
Kindly note that our Free Spire.PDF is limited to 10 pages of PDF, and this limitation is enforced during loading and creating files.
I used the following code to compress a scanned PDF document with 2 pages with the latest
Free Spire.PDF V7.2 in .Net Core 3.1, but did not reproduce your issue.
- Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"E:\testdoc\Sample.pdf");
CompressContent(doc);
CompressImage(doc);
doc.SaveToFile("CompressDocument_result.pdf");
private static void CompressContent(PdfDocument doc)
{
//Disable the incremental update
doc.FileInfo.IncrementalUpdate = false;
//Set the compression level to best
doc.CompressionLevel = PdfCompressionLevel.Best;
}
private static void CompressImage(PdfDocument doc)
{
//Disable the incremental update
doc.FileInfo.IncrementalUpdate = false;
//Traverse all pages
foreach (PdfPageBase page in doc.Pages)
{
if (page != null)
{
if (page.ImagesInfo != null)
{
foreach (PdfImageInfo info in page.ImagesInfo)
{
page.TryCompressImage(info.Index);
}
foreach (PdfImageInfo info in page.ImagesInfo)
{
info.Image.Dispose();
}
}
}
}
}
To help us further investigate and reproduce your issue, please provide us with your input file and testing code for reference, you can send them to us via email (
[email protected]). Thanks in advance.
Sincerely,
Marcia
E-iceblue support team