- Some PDFs render correctly, but extracted text has broken Unicode because of embedded subset TrueType fonts and missing or invalid
ToUnicode/ font encoding. - We also need a reliable way to detect micro-spaces or invisible whitespace fragments and get their geometry / visibility state.
The important part is that we need an API-level answer from Aspose. We are not looking for word replacements or cleanup rules for one document.
If they ask for samples, we can provide the PDFs and extraction output.
Thanks.
Text letter:
Subject: Aspose.PDF for Java 26.5: Unicode extraction and invisible whitespace detection in PDFs
Hello Aspose Support,
We use Aspose.PDF for Java 26.5 (aspose-pdf-26.5.jar) in a Java service that extracts PDF text and text geometry.
We are seeing two PDF text extraction issues. I am grouping them in one request because both affect the same extraction flow, but they are separate cases.
Issue 1: incorrect Unicode from embedded subset TrueType fonts
We have a PDF that renders correctly in viewers, but Aspose extracts corrupted text in some places. The affected text appears to use embedded subset TrueType fonts. From what we can see, the PDF likely has missing or invalid ToUnicode / custom font encoding data.
Examples:
Wstępis extracted asWstpKolędyis sometimes extracted asKoldyZakończenieis sometimes extracted asZakoMczenie- Other fragments contain values such as
wstampujemyA,pojechaˇ,V(W, or substitutions like9,2,A,H
Minimal reproduction:
com.aspose.pdf.Document document = new com.aspose.pdf.Document(inputPdfPath);
try {
com.aspose.pdf.TextAbsorber absorber = new com.aspose.pdf.TextAbsorber();
document.getPages().accept(absorber);
System.out.println(absorber.getText());
} finally {
document.close();
}
What we need to know:
- Is this expected behavior when
ToUnicodeis missing or invalid? - Can Aspose.PDF for Java recover Unicode from the embedded font program, glyph names, or font encoding?
- Is there any Java API to inspect the mapping Aspose uses, for example PDF character code → glyph id → Unicode?
- Should we attach our PDF as a new issue, or can this be linked to an existing ticket?
Closest related threads:
-
PDFJAVA-36721: font encoding information is not exposed / not resolved
Get Font Type and Encoding Type from PDF File -
PDFJAVA-37682: garbage text extraction for PDFs with custom encoding
Text extraction for PDFs with custom encoding -
PDFJAVA-37691: custom-encoded text exported as images instead of text
Text extraction for PDFs with custom encoding -
PDFJAVA-38015: part of extracted text has bad encoding
Bad encoding part of text
Issue 2: micro-spaces / invisible whitespace fragments
We also need to detect micro-spaces or invisible spacing markers in PDFs. In Aspose terms, this seems close to zero-width, hidden, invisible, or not-rendered whitespace/text fragments.
For these fragments we need to:
- detect them reliably;
- get their page position / geometry;
- distinguish them from normal visible text;
- know whether they are hidden, transparent, zero-width, not rendered, or visible.
TextState.Invisible does not seem to cover all cases, based on the public threads below. Please confirm whether this property is expected to cover all hidden/invisible text cases, or only specific rendering modes.
Closest related threads:
-
PDFNET-55908: invisible text is not reliably distinguishable from normal text
How to Detect “Invisible” Characters -
PDFNET-47203: hidden/invisible text is extracted even though it is not displayed in the PDF
How to extract Pdf to text ignore hidden text? -
PDFNET-59288: not-rendered / invisible Unicode characters are not found through the usual
TextFragmentAbsorberapproach
How to find not rendered characters in PDF? -
WORDSNET-7585: zero-width space
U+200Bbehavior in Word-to-PDF conversion
Invisible (zero-width) space characters not causing line breaks in PDF converted from DOCX file -
PDFNET-43334 / PDFNET-43341: extra spaces / segment gaps during PDF text extraction
TextAbsorber adds extra spaces when extracting from a french pdf
For both issues, we are not looking for document-specific word replacements or cleanup rules. We need an API-level approach at the font/text-fragment level.
We can provide sample PDFs and extraction output if needed. Please let us know what diagnostic data would be useful.
Thank you.