PDF convert to jpg text unrecognized
aspose.pdf 19.4
Mac OS 10.14.4
java version “1.8.0_181”
Java™ SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot™ 64-Bit Server VM (build 25.181-b13, mixed mode)
Would you please make sure that necessary fonts (minimum all Microsoft Essential Fonts) are installed on the system you are working. In case issue still persists, please let us know. We will further proceed to assist you accordingly.
We were able to replicate the issue in our environment and logged it as PDFJAVA-38596 in our issue tracking system. We will further look into details of the issue and keep you posted with the status of its resolution. Please be patient and spare us little time.
You may keep an eye over release notes section which will include this ticket ID once resolved. Moreover, we will also notify you here as soon as it will be resolved.
We have completed the investigation of the earlier logged ticket.
The 报关资料__BFC1190110008的副本.pdf is converted fine cause all used fonts are embedded inside the document. In 报关资料__BFC1190110008 (1).pdf most of the fonts are not embedded and when they are not installed in OS then the default font is used. The default font has not all glyphs for Chinese.
There are two ways for correct rendering:
1- Install absent fonts: “STSong-Light, STSong-Light-Bold-UniGB-UCS2-H” or set path to the fonts by the code FontRepository.addLocalFontPath(PATH_TO_FONTS);
2- Substitute absent fonts with some other compatible font by the code below (tested with STSong.ttf font that has been installed before the conversion).
FontRepository.getSubstitutions().add(new FontSubstitute());
Document pdfDocument = new Document(dataDir + "报关资料__BFC1190110008 (1).pdf");
...
public class FontSubstitute extends CustomFontSubstitutionBase {
public boolean trySubstitute(OriginalFontSpecification originalFontSpecification, com.aspose.pdf.Font[] substitutionFont) {
System.out.println(originalFontSpecification.getOriginalFontName());
if (originalFontSpecification.getOriginalFontName().contains("Song")) {
substitutionFont[0] = FontRepository.findFont("STSong");
System.out.println("was changed on " + substitutionFont[0].getFontName());
return true;
}
return false;
}
}