Free Support Forum - aspose.com

Need details about PdfFormatConversionOptions.setOptimizeFileSize API

Hi,


A new method named ‘setOptimizeFileSize’ seems to have been introduced in PdfFormatConversionOptions class as per 16.12 release note.

http://www.aspose.com/docs/display/pdfjava/Aspose.Pdf+for+Java+16.12.0+Release+Notes

Can you share what exactly it does internally ? Whether / how output quality will be impacted ? When should it be used ? Can it be used only while creating PDF/A or during normal PDF as well ?

Thanks,
Rajiv

Hi Rajiv,


Thanks for your inquriy. Please note setOptimizeFileSize Boolean property is used in PDF to PDFA conversion. Setting property enables/disables special conversion mode to get PDF/A document with reduced file size. Set of this flag and mode could significantly reduce file size but at the same time it could significantly decrease performance of conversion.

Please feel free to contact us for any further assistance.

Best Regards,


Hi Tilal,


- Do you have more technical details on what exactly it does internally in order to reduce the file-size ?
- Will there be any known impact on PDFA compliance ?
- And how is it different from com.aspose.pdf.Document.optimize() API which also aims at compressing the output and reducing its size ?

Thanks,
Rajiv

Hi Rajiv,


Thanks for your inquriy.
rajivrp:

- Will there be any known impact on PDFA compliance ?
- And how is it different from com.aspose.pdf.Document.optimize() API which also aims at compressing the output and reducing its size ?


The property does not have any impact on the PDFA compliance of resultant file and it keeps the PDFA compliance while reducing the file size.

rajivrp:

- Do you have more technical details on what exactly it does internally in order to reduce the file-size ?


I have logged an internal ticket PDFNET-42242 regarding your requirement and will update you as soon as any update is available.

Best Regards,

Hi Tilal,


You have any update on PDFNET-42242 ?

We need more technical details on how it reduces the file size and how this API is different from com.aspose.pdf.Document.optimize().

Thanks,
Rajiv

Hi Rajiv,


Thanks for your inquiry. Please note currently usage of setOptimizeFileSize flag executes optimization for fonts used in the PDF document, how fonts will be optimized depends on strategy selected - please see the PdfFormatConversionOptions.ExcludeFontsStrategy field and PdfFormatConversionOptions.RemoveFontsStrategy enumeration.

Possibly, in future, this flag will be also used to switch on optimization for other data structures, such as graphic.

Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal,


So what does com.aspose.pdf.Document.optimize() do ? I want to understand the difference between both the APIs.

Thanks,
Rajiv

Hi Rajiv,


Thanks for your inquiry. Please note method com.aspose.pdf.Document.optimize() optimizes document structure and also reduces size of PDF document. But this method differs from OptimizeFileSize in areas to support, method com.aspose.pdf.Document.optimize() can be used with any PDF document while OptimizeFileSize impacts only on documents which are converting into PDF/A format. If you are converting document into PDF/A format and want to reduce file size it is better to join both functionalities OptimizeFileSize and com.aspose.pdf.Document.optimize(), so to achieve more compact PDF/A document you can use code like this:

Aspose.Pdf.Document
pdfDoc = new Aspose.Pdf.Document(myDir + “Test.pdf”);<o:p></o:p>

PdfFormatConversionOptions opts = new PdfFormatConversionOptions(myDir + "sample.txt", PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);

opts.OptimizeFileSize = true;

pdfDoc.Convert(opts);

pdfDoc.Optimize();

pdfDoc.Save(myDir + "Test_PDF_A_1b.pdf");


Please feel free to contact us for any further assistance.


Best Regards,