Hello guys,
We have a problem after updating to aspose pdf version 24.8. When we are trying to redact the file we are getting below error:
Caused by: class com.aspose.pdf.exceptions.IncorrectFontUsageException: Document error: TJ operator without preceding Tf - no font set for the text segment
The same file was working fine with prior versions.
sample code to do redaction:
private static void redactTextFragmentexample() {
PdfAnnotationEditor textOnlyFileEditor = new PdfAnnotationEditor(); Document doc = new Document(“…/…/text.pdf”); textOnlyFileEditor.bindPdf(doc); final Rectangle textFragmentRectangle = new Rectangle(120**,** 120**,** 120**,** 120); textOnlyFileEditor.redactExactArea(1**,** textFragmentRectangle**,** java.awt.Color.BLACK );
}
The error is thrown at redactExactArea method. Can you please help with this.
@connective
It seems that you are encountering an IncorrectFontUsageException
when trying to redact a PDF document using Aspose.PDF version 24.8. This error indicates that there is a problem with the font settings in the document, specifically that the TJ operator is being used without a preceding Tf operator, which means no font has been set for the text segment.
Here are a few steps you can take to troubleshoot and potentially resolve this issue:
-
Check Font Availability: Ensure that the fonts used in the PDF document are available and correctly embedded. If the fonts are missing or not embedded, it can lead to issues during redaction.
-
Update Your Code: Make sure that you are using the latest methods and practices as per the updated Aspose.PDF documentation. Sometimes, methods may change or require additional parameters in newer versions.
-
Use Alternative Redaction Methods: If the redactExactArea
method is causing issues, consider using other methods provided by the PdfAnnotationEditor
class or the RedactionAnnotation
class to see if they yield better results.
-
Revert to Previous Version: If the issue persists and is critical, you might consider reverting to the previous version of Aspose.PDF that was working for you until a fix or workaround is provided.
-
Contact Support: If none of the above solutions work, consider reaching out to Aspose support with detailed information about the issue, including the PDF file and the exact code you are using.
Here is a sample code snippet for redacting a specific area, which you can modify based on your needs:
private static void redactTextFragmentExample() {
PdfAnnotationEditor textOnlyFileEditor = new PdfAnnotationEditor();
Document doc = new Document("../../text.pdf");
textOnlyFileEditor.bindPdf(doc);
final Rectangle textFragmentRectangle = new Rectangle(120, 120, 120, 120);
textOnlyFileEditor.redactExactArea(1, textFragmentRectangle, java.awt.Color.BLACK);
}
Make sure to adjust the rectangle coordinates as needed for your specific use case.
If you continue to experience issues, please provide additional details about the PDF file and any other relevant code snippets, and I would be happy to assist further.
Hi there,
Check Font Availability → The pdf is provided by the clients of our application. Also this pdf was working with previous versions.
Update Your Code → Yes. The methods used are according to the Aspose documentation standards.
Use Alternative Redaction Methods → RedactionAnnotation is also throwing the same error.
Revert to Previous Version → We are facing issues regarding redaction in previous versions for other documents, which is being solved with latest versions.
@connective
Could you provide the document mentioned in your code snippet so we can check the issue?
Also, is problem document specific or it triggers on multiple occasions?
@ilyazhuykov This problem is document specific, And i cannot share the document here as it contains confidential client information
@connective
Is it possible to remove confidential information from document?