I was think All Pdf's is going to be happen this. but i was wrong.
the Source isn't problem. because it'll be appear from your sample code.
[url]https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Document-Operation/How-to-Compress-PDF-Document-in-C-VB.NET.html
[/url]
but if you wanna see my test code , that's no problem at all
- Code: Select all
//Loads the PDF document
PdfDocument doc = new PdfDocument(AppDomain.CurrentDomain.BaseDirectory + "Booklet.pdf");
//Disables the incremental update
doc.FileInfo.IncrementalUpdate = false;
try
{
//Traverses all pages
foreach (PdfPageBase page in doc.Pages)
{
//Extracts images from page
Image[] images = page.ExtractImages();
if (images != null && images.Length > 0)
{
//Traverses all images
for (int j = 0; j < images.Length; j++)
{
Image image = images[j];
PdfBitmap bp = new PdfBitmap(image);
//Reduces the quality of the image
bp.Quality = 20;
//Replaces the old image in the document with the compressed image
page.ReplaceImage(j, bp);
}
}
}
}
catch(Exception err)
{
System.Diagnostics.Trace.WriteLine(err.Message);
}
//Saves and closes the resultant document
doc.SaveToFile("Output.pdf");
doc.Close();
if i change pdf file to "CompressDocument.pdf" then, there's no problem.
thanks for fast feedback.
and i hope fast feedback this time too.