You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2017/09/04 16:07:00 UTC
[jira] [Commented] (PDFBOX-3918) create report in HINDI using
PDFBox
[ https://issues.apache.org/jira/browse/PDFBOX-3918?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16152759#comment-16152759 ]
Tilman Hausherr commented on PDFBOX-3918:
-----------------------------------------
Hindi glyphs are not available in WinAnsiEncoding, see https://pdfbox.apache.org/2.0/faq.html#fontencoding .
You need to create your PDF in a different way (you used "Wondershare PDFelement"), or you must create it with PDFBox, see the CreateSimpleFormWithEmbeddedFont.java example in the source code download, and use a font that has the hindi glyphs. (I tried with ArialUni)
However I'm afraid you won't be happy: we don't support complex scripts (see PDFBOX-3550) and hindi seems to be. This means that the glyphs you see will look weird, because individual character glyphs aren't combined into a single glyph.
What you could do is to call {{acroForm.setNeedAppearances(true);}} but this would mean that people who use Adobe Reader get a dialogbox to save when opening that file. Some viewers might not render it at all.
I intend to close this as a duplicate of PDFBOX-3550.
> create report in HINDI using PDFBox
> -----------------------------------
>
> Key: PDFBOX-3918
> URL: https://issues.apache.org/jira/browse/PDFBOX-3918
> Project: PDFBox
> Issue Type: Improvement
> Components: AcroForm
> Affects Versions: 2.0.7
> Environment: Windows 10
> Reporter: Subrata Kumar Pradhan
> Fix For: 2.0.7
>
> Attachments: CPIS_test_language.pdf
>
>
> Hello
> I am getting an error while generating a report i.e. "U+0938 is not available in this font's encoding: WinAnsiEncoding" and attaching the pdf which contain some acroform and their ids are Text1, Text2 and below i am giving my java code:
> import java.io.File;
> import java.util.List;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
> import org.apache.pdfbox.pdmodel.interactive.form.PDField;
> public class PDFBoxLanguageTest {
> public static void main(String[] args) throws Exception {
>
> String formTemplate = "C:/Users/XXXX/Downloads/CPIS_test_language.pdf";
> PDDocument pdfDocument = PDDocument.load(new File(formTemplate));
> PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
> if (acroForm != null) {
> // Get field names
> List<PDField> fieldList = acroForm.getFields();
> for (PDField pdField : fieldList) {
> // Here i am passing a text in "Hindi"
> acroForm.getField(pdField.getFullyQualifiedName()).setValue("सुब्रत");
> }
> }
> pdfDocument.save("C:/Users/XXXX/Downloads/CPIS_test_language1.pdf");
> pdfDocument.close();
> System.out.println("Done");
> }
> }
> Exception:
> Exception in thread "main" java.lang.IllegalArgumentException: U+0938 is not available in this font's encoding: WinAnsiEncoding
> at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.encode(PDTrueTypeFont.java:398)
> at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:323)
> at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:352)
> at org.apache.pdfbox.pdmodel.interactive.form.PlainTextFormatter.format(PlainTextFormatter.java:195)
> at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:493)
> at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceContent(AppearanceGeneratorHelper.java:353)
> at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:226)
> at org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
> at org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField.applyChange(PDTerminalField.java:228)
> at org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDTextField.java:218)
> at com.sdrc.image.PDFBoxLanguageTest.main(PDFBoxLanguageTest.java:21)
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org