I have a pdf given to me by our drafting department. It is 1112KB in size. If I open the document in Acrobat and take the option to “Optimize Pdf” and take the standard settings the doc is reduced to 805KB.
Whe I use Aspose PDF and use either optimize() or optimizeResources() there is no size change.
When I use optimizeResources with an OptimizationOptions class set to remove everything and compress images I can get the size as low as 1009KB if I set the imageQuality to 5…
I tried using the ximage method and the file increased to 8000KB…
All I need this to do is the same thing Acrobat does and optimize the file for the web, but all of the examples provided on the forum fall far short of this goal.
What do I need to do?
Jon
Hi Jon,
I just attached the pdf to the original post.
Hi Jon,
Where are we on this ticket? I cannot complete my project without being able to optimize the pdfs.
Jon
Hi Jon,
I has been a month since I sent this issue in, and I still haven’t heard anything. I have a project waiting on this? Is this going to be resolved or do I need to find another tool?
Jon
Hi Jon,
note that as a normal rule of practice, issues are resolved in first come and
first serve basis; but the problems logged/reported under Enterprise or
Priority support model, have high precedence in terms of resolution, as compare
to issues under normal/free support model. Nevertheless, as soon as we have some further updates, we will let you know.
Hi,
String dataDir = “src/programmersguide/workingwithasposepdf/workingwithdocument/optimizepdfdocument/data/”;
//Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir+ “input.pdf”);
//Optimize for web
pdfDocument.optimize();
//Save output document
pdfDocument.save(“Optimized_output.pdf”);
makes even the pdf-file larger…
Setting the OptimizationOptions dont make it better.
kindly regards
ToYi
Hi ToYi,ToYi:Hi,i have the same issue like Jon.Using your example input.pdf and code:String dataDir = “src/programmersguide/workingwithasposepdf/workingwithdocument/optimizepdfdocument/data/”;
//Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir+ “input.pdf”);
//Optimize for web
pdfDocument.optimize();
//Save output document
pdfDocument.save(“Optimized_output.pdf”);makes even the pdf-file larger…Setting the OptimizationOptions dont make it better.
kindly regardsToYi
Hi,
Hi ToYi,
//Open
document<o:p></o:p>
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("c:/pdftest/input (1).pdf");
com.aspose.pdf.Document.OptimizationOptions optimize = new com.aspose.pdf.Document.OptimizationOptions();
optimize.setCompressImages(true);
optimize.setRemoveUnusedObjects(true);
optimize.setRemoveUnusedStreams(true);
//optimize.setUnembedFonts(true);
//Optimize file size
pdfDocument.optimizeResources(optimize);
//Save output document
pdfDocument.save("c:/pdftest/Optimized_output.pdf");
pdfDocument.optimize();
Hi Nayyer,
Document.OptimizationOptions opt = new Document.OptimizationOptions();
opt.setCompressImages ( true );
// Set the quality of images in PDF file
opt.setImageQuality ( 10 );
doc.optimizeResources(opt);
But executing this code results with an exception:
java.lang.IllegalArgumentException: Map size (0) must be >= 1
kindly regardsToYi
Hi ToYi,ToYi:Hi Nayyer,thx for your fast response.I already used the optimizeResources method, but no changes recognized.For pdf-files with images i've used the compress methode:Document.OptimizationOptions opt = new Document.OptimizationOptions();opt.setCompressImages ( true ); // Set the quality of images in PDF file opt.setImageQuality ( 10 ); doc.optimizeResources(opt);But executing this code results with an exception:java.lang.IllegalArgumentException: Map size (0) must be >= 1
kindly regardsToYi
Hi Nayyer,
Hi Toyi,
Hi Oliver,dr_oli:any news here? It is now 7 months without update.
Do you need the requirement to convert RGB colorspace PDF to GrayScale document ? If so is the case, then please visit the following link for related information on Convert a PDF from RGB colorspace to Grayscaledr_oli:Can you do same thing like Adobe with change of ColorSpace?
Hi Oliver,