Hi ,
I am using Aspose pdf to generate a pdfa (with weboptimization ) from an input pdf (Original_input.pdf).
Scenario #1
PDFA rendition is generated fine with a size of ~3MB for an input of ~ 3MB.
Scenario #2
I use a third party to add a watermark to the Original_input.pdf and then this pdf (Watermark_input1.pdf) is then, sent as an input to the Aspose PDF. But the PDFA rendition rendered is 150 MB now and it takes a lot of time for the conversion (~10 minutes compared to 1 minute earlier).
Sample Code:-
try {
com.aspose.pdf.Document document = new com.aspose.pdf.Document("C:\\Users\\Administrator\\Desktop\\D2\\input.pdf");
PdfFormatConversionOptions opts = new PdfFormatConversionOptions("C:\\Users\\Administrator\\Desktop\\D2\\logFile2.txt", PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
opts.setOptimizeFileSize(false);
document.convert(opts);
document.optimize();
document.save("C:\\Users\\Administrator\\Desktop\\D2\\output.pdf");
document.dispose();
} catch (Exception e) {
System.out.println("Exception while converting PDF to PDFA compliance : "+e.getMessage());
}
I can see errors in the log file generated as a part of the PDFA conversion and attaching here.
Please review them as well and let us know, why is so much time and size difference. aspose.zip (5.0 MB)
I cant upload the rendered pdf as the size were too big.
We were able to notice a similar issue in our environment while using Aspose.PDF for Java 20.7. Therefore, we have logged it as PDFJAVA-39626 in our issue tracking system. We will further investigate it and keep you posted with its correction status. Please spare us some time.
We understand your concerns and will surely take care of them during issue investigation. The issue will be investigated and resolved on first come first serve basis and we will certainly inform you as soon as we have some definite updates regarding its resolution. Please have patience and give us little time.
Hi @asad.ali,
I am aware of the free support queue system but this issue can potentially stop our release since PDFA is a big functionality for us.
Similar use case issue has/ had already been reported to the enterprise support as well.
Have you created a new ticket in the paid support forum for the same case? You can simply report reference of this ticket “PDFJAVA-39626” there and it will be escalated accordingly.
We have further investigated the ticket and found that the key reason of size grow is added transparency in watermark. Transparency is forbidden by PDFA_1A standard.
And the only way not to break the look of a document and ensure that the document conforms to the standard is to replace each part of the page with transparency on the image with the same content, but without transparency. In this case, at least 352 images were added to the document. If the large size of the document is sensitive to you - you can try to use the watermark without transparency.
Also we can recommend using the following code to add stamp without transparency and keep file size to 2.5Mb:
com.aspose.pdf.Document document = new com.aspose.pdf.Document(dataDir+"input.pdf");
//add stamp
FormattedText formatText = new FormattedText("Static");
TextStamp textStamp = new TextStamp(formatText);
textStamp.setRotateAngle(45d);
textStamp.setHorizontalAlignment(HorizontalAlignment.Center);
textStamp.setVerticalAlignment(VerticalAlignment.Center);
textStamp.getTextState().setFont(FontRepository.findFont("TimesNewRoman"));
textStamp.getTextState().setFontSize((float)128);
textStamp.getTextState().setFontStyle(FontStyles.Bold);
textStamp.setBackground(false);
textStamp.getTextState().setForegroundColor(Color.getOrange());
for (Page page : document.getPages())
page.addStamp(textStamp);
//convert
PdfFormatConversionOptions opts = new PdfFormatConversionOptions(
dataDir+"logFile.txt", PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
opts.setOptimizeFileSize(false);
opts.setTransparencyAction(ConvertTransparencyAction.Default);
opts.setConvertSoftMaskAction(ConvertSoftMaskAction.ConvertToStencilMask);
document.convert(opts);
document.optimize();
document.save(dataDir+"watermark1_output20_8__noAlphaStamp_PDF_A_1A.pdf");
document.dispose();
You can try suggested code snippet with Aspose.PDF for Java 20.9 and let us know if you need further assistance.
Hi @asad.ali,
It seems you are suggesting us to use aspose for adding watermark. But the input file received to aspose would already be watermarked. We donot have the control over the inputs we receive and we cannot advise customers on how to add watermark.
We need aspose to work efficiently with Scenerio #2. Because that is the main use case for our customers.
Let us know what issue are you facing with current input. Is it not a valid input(pdf)?
We have recorded your feedback and will further investigate the ticket. We will inform you as soon as we have additional updates in this regard. We will also request for information in case we need some from your side. Please give us some time.
We regret that we could not investigate against the latest feedback that you provided upon suggested solution. We will soon try to gather complete details and share it with you within this forum thread. We highly appreciate your patience and comprehension in this matter. Please give us some time.
We have logged another task as PDFJAVA-40005 in our issue tracking system to implement an option that can remove transparency color to avoid large output size. We will further work over this task and let you know as soon as it is resolved. Please be patient and spare us some time.
Could you please use the following option with Aspose.PDF for Java 21.2 to replace transparency color with non-transparency analogue and keep PDFA compliant without document size grow.
opts.setTransparencyIgnore(true);
Please let us know if issue still persists. We will further proceed to assist you accordingly.
We have logged another ticket as PDFJAVA-40492 in our issue tracking system for this issue. We will further look into its details and let you know once it is resolved. Please be patient and spare us some time.