But when replacing the text on PDF file, we are getting following exception.
09:24:49.111 [http-nio-0.0.0.0-8082-exec-8] ERROR c.j.s.s.xxxxxxxxxxxxxxxx- error_sp : com.aspose.pdf.internal.l48I.I30I: Requested font type subsetting is not supported.
com.aspose.pdf.internal.l48I.I30I: Requested font type subsetting is not supported.
at com.aspose.pdf.internal.l48I.I921.l0f(Unknown Source)
at com.aspose.pdf.internal.l137.I5I.l2iF(Unknown Source)
at com.aspose.pdf.internal.l137.I44.lif(Unknown Source)
at com.aspose.pdf.internal.l13l.I0l.lif(Unknown Source)
at com.aspose.pdf.internal.l13I.I7.lif(Unknown Source)
at com.aspose.pdf.internal.l134.I01.lif(Unknown Source)
at com.aspose.pdf.TextSegment.setText(Unknown Source)
at com.aspose.pdf.TextFragment.setText(Unknown Source)
at com.aspose.pdf.facades.PdfContentEditor.replaceText(Unknown Source)
at com.aspose.pdf.facades.PdfContentEditor.replaceText(Unknown Source)
at com.aspose.pdf.facades.PdfContentEditor.replaceText(Unknown Source)
Could you please try using Aspose.PDF for Java 19.4 and in case issue still persists, please share your sample PDF document along with complete code snippet. We will test the scenario in our environment and address it accordingly.
The code works locally using standalone IDE (Eclipse/intellij) and using both (19.4 or 18.9.1) version. However when the same is executed from a CI(Continuous Integration) server hosted on Linux machine using tomcat server, it throws the error com.aspose.pdf.internal.l48I.I30I: Requested font type subsetting is not supported.
Please let us know if there are any further suggestions.
This seems like an issue related to absent fonts. Would you please make sure to install all essential fonts in your system and set the path for required fonts before converter start process.
In order to further substitute an absent font, you can use built-in monitoring for substituted fonts:
final Map<String,String> names = new HashMap<String,String>() ;
pdfDocument.FontSubstitution.add(new Document.FontSubstitutionHandler()
{
public void invoke(Font font, Font newFont)
{
//add substituted FontNames into map.
names.put(font.getFontName(), newFont.getFontName());
//or print the message into console
System.out.println("Warning: Font "+ font.getFontName() + " was substituted with another font -> " + newFont.getFontName());
}
});
In case issue still persists, please share earlier requested information with us. We will test it further in our environment and share our feedback accordingly.
We added following code after creating com.aspose.pdf.Document object.
final Map<String,String> names = new HashMap<String,String>() ;
pdfDocument.FontSubstitution.add(new Document.FontSubstitutionHandler()
{
public void invoke(Font font, Font newFont)
{
//add substituted FontNames into map.
names.put(font.getFontName(), newFont.getFontName());
//or print the message into console
System.out.println("Warning: Font "+ font.getFontName() + " was substituted with another font -> " + newFont.getFontName());
}
});
For our pdf, it shows following system out statements before it fails Warning: Font Helvetica was substituted with another font -> BPG Arial Warning: Font Symbol was substituted with another font -> BPG Arial
The original PDF file is generated using Arial Unicode font. We are using Aspose pdf to replace some Chinese text in the pdf file.
Scenario 1 :
When we try to replace the Chinese text with English characters , we get exception saying Requested Font Subsetting is not supported.
Scenario 2:
When we replace Chinese text with another Chinese characters, sometime thay are replaced correctly. Wheras sometimes we get junk characters like
This is the original file. We want to replace Chinese text in this file.
We want to replace following text. 授权签字人签字
Scenario 1 : Replace 授权签字人签字 with SANDESH BANE
We observed following exception when pdfContentEditor.replaceText(key,value) is called.
com.aspose.pdf.internal.l48I.I30I: Requested font type subsetting is not supported.
com.aspose.pdf.internal.l48I.I30I: Requested font type subsetting is not supported.
at com.aspose.pdf.internal.l48I.I921.l0f(Unknown Source)
at com.aspose.pdf.internal.l137.I5I.l2iF(Unknown Source)
at com.aspose.pdf.internal.l137.I44.lif(Unknown Source)
at com.aspose.pdf.internal.l13l.I0l.lif(Unknown Source)
at com.aspose.pdf.internal.l13I.I7.lif(Unknown Source)
at com.aspose.pdf.internal.l134.I01.lif(Unknown Source)
at com.aspose.pdf.TextSegment.setText(Unknown Source)
at com.aspose.pdf.TextFragment.setText(Unknown Source)
at com.aspose.pdf.facades.PdfContentEditor.replaceText(Unknown Source)
at com.aspose.pdf.facades.PdfContentEditor.replaceText(Unknown Source)
at com.aspose.pdf.facades.PdfContentEditor.replaceText(Unknown Source)
Scenario 2 : Replace 授权签字人签字 with 待办事项 待办事项
We did not receive any exception after calling method pdfContentEditor.replaceText(key,value).
However the replaced text is not displayed correctly.
Please find attached pdf file output. After_Replacing_with_Chinese_Characters.pdfAfter_Replacing_with_Chinese_Characters.pdf (656.9 KB)
Note : Both the scenarios work perfectly when we use aspos pdf on your local system. However, we are facing these issues when we are usinf aspos pdf on Unix machine.
Also please let us know if we can connect with you using any helpline number. Also what will be the right time to connect to you?
Or will it be possible for you to connect with us if we provide our telephone number to you?
Also can you please let us know which all fonts are supported by Aspose when editing and replacing text in pdf file?
We have logged an investigation ticket as PDFJAVA-38593 in our issue tracking system. We will further investigate the reasons behind this issue and keep you posted with the status of ticket resolution. Please be patient and spare us little time.
Please note that we appreciate providing support through our forums. In case you need to share some private information, you can send us private message by clicking over username and pressing blue Message button.
Aspose.PDF support all 14 core fonts. However, there is no such known issue that API was unable to support any font different than standard core fonts. Only condition is that font should be present in the system and path to that font should be set using FontRepository as suggested in our earlier message.
We are loading Arial Unicode font using FontRepository.openFont().
We tried creating TesxtState object as follows.
TextState textState = new TextState();
textState.setFont(FontRepository.openFont(path of arial Unicode); //This sets the font correctly
System.out.println(textState.getFont().getFontName()) //This prints Arial Unicode MS
However when we try to replace 授权签字人签字 with SANDESH BANE it throws same exception
com.aspose.pdf.internal.l48I.I30I: Requested font type subsetting is not supported
Also can you pelase confirm if following are the 14 core fonts supported by aspose or are they different?
Courier, Courier Bold, Courier Oblique, Courier Bold-Oblique
Helvetica, Helvetica Bold, Helvetica Oblique, Helvetica Bold-Oblique
Times Roman, Times Bold, Times Italic, Times Bold-Italic
Symbol
Zapf Dingbats
Above code resolved the issue where Chinese characters were displayed as . Chinese characters are displayed correctly after replacing them in pdf.
We observed that replacetext() fails when we are trying to replace any text which contains special character. For E.g.
Following strings replace failed. Sandesh_auth D’Souza