请参考以下代码:
PauseUtil pause = new PauseUtil();
OptimizerSettings settings = new OptimizerSettings();
System.out.println("Optimized Start.");
Progressive progressive = Optimizer.optimize(doc, settings, pause);
int state = Progressive.e_ToBeContinued;
while (state == Progressive.e_ToBeContinued) {
state = progressive.resume();
int rate = progressive.getRateOfProgress();
System.out.println("Optimize progress percent: " + rate + "%");
}
if(state == Progressive.e_Finished)
{
doc.saveAs("ImageCompression_Optimized.pdf",e_SaveFlagRemoveRedundantObjects);
}