Hi Team,
We are currently using Aspose Total and the aspose pdf version in use is 22.9. We found that certain documents like email printouts combined as a PDF, documents with multiple headers, more than 100 pages are taking longer times for conversion.
One of the scenario where a email copy document of 2 Pages took around 26 Mins for conversion. Could you please let us know if this is expected behavior for these type of files or how to optimize this?
Current JDK : 21-jre-alpine
Code Snippet :
pdfDocument.validate(“Validation_log.xml”, PdfFormat.PDF_A_1B);
valid = pdfDocument.convert(“Conversion_log.xml”, PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);
Thanks
@PrasanthTirlangi
It sounds like you’re experiencing performance issues when converting certain PDF documents to PDF/A-1B format using Aspose.PDF. This can occur with complex documents, such as those with multiple headers or a large number of pages, as they may require more processing time.
Cause: The complexity and size of the PDF documents are likely contributing to the performance issues during conversion.
Solution: To optimize the conversion process, consider the following steps:
-
Update Aspose.PDF: Ensure you are using the latest version of Aspose.PDF, as performance improvements and bug fixes are regularly included in updates.
-
Optimize PDF Document: Before conversion, optimize the PDF document to reduce its size and complexity. This can be done using the OptimizeResources
method, which removes unused objects and compresses images. Here’s a code snippet to help you with that:
using (var pdfDocument = new Aspose.Pdf.Document("input.pdf"))
{
var optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions
{
RemoveUnusedObjects = true,
RemoveUnusedStreams = true,
LinkDuplicateStreams = true
};
pdfDocument.OptimizeResources(optimizationOptions);
pdfDocument.Save("optimized.pdf");
}
-
Adjust Conversion Settings: Experiment with different settings in the PdfSaveOptions
class to see if they affect performance. For example, setting PdfCompression
to a more aggressive option might help.
-
Profile the Conversion: If possible, profile the conversion process to identify specific bottlenecks. This can help you understand which parts of the document are causing delays.
-
Test with Smaller Documents: If you have control over the document creation process, try breaking down larger documents into smaller parts to see if that improves conversion times.
Next Steps: If the issue persists after trying these optimizations, please provide more details about the specific documents that are causing delays, and we can further investigate.
Let me know if this helps!
How to Profile the Conversion?
@PrasanthTirlangi
Could you provide document you mentioned to investigate this issue?
@ilyazhuykov I would not be able to share the exact document. Also, I have updated Aspose-pdf to 25.7. But, a 5MB PDF when converted is giving 27 MB file. Is this expected behaviour?
Current JDK : 21-jre-alpine
@PrasanthTirlangi
As I know, in general during PDF/A conversion fonts are embedded into document affecting file size + there’re some specifics related to some formats of PDF/A conversion , so yes, file size increase can be called expected behaviour
@ilyazhuykov Are there any special optimization or compression options available which can decrease both the time for conversion and size? I have used optimizationOptions.all() but this didn’t had a significant effect.
@PrasanthTirlangi
Optimization options make converted document lighter but optimization is added to conversion time and makes it slower
so in case you need faster result probably it’s better not to use optimizationOptions at all
and in case of fonts embedding and some image formatting very few adjustments for file size
I asked development team and was recommended to choose PDF/A-2 or PDF/A-3 as less strict and as a result most time efficient formats and use only OptimizeFileSize in optimizationOptions to minimize file size. Hope it helps.