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 2019/04/06 09:17:00 UTC

[jira] [Commented] (PDFBOX-4508) Unexpected slowness filling forms with CJK

    [ https://issues.apache.org/jira/browse/PDFBOX-4508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16811520#comment-16811520 ] 

Tilman Hausherr commented on PDFBOX-4508:
-----------------------------------------

I looked at it with the profiler, which showed that the font is created each time. Then I looked at it with the debugger, PDFormXObject is initialized without resource cache, because PDAppearanceStream doesn't pass it (it can't).

> Unexpected slowness filling forms with CJK
> ------------------------------------------
>
>                 Key: PDFBOX-4508
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4508
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: AcroForm
>    Affects Versions: 2.0.14
>            Reporter: Tilman Hausherr
>            Priority: Major
>              Labels: Optimization
>         Attachments: NotoSansCJKsc-Medium.ttf, i-130.pdf
>
>
> As reported by William Pietri in the users mailing list:
> {quote}If I go through this and fill every field with roman text using the default font, it takes circa 2 seconds, which is fine. If I fill it with an added Arabic font, it takes circa 7 seconds. And if I use a CJK font, it takes circa 140 seconds, which seems like a lot. This is with PDFBox 2.0.14 and the Oracle 1.8.201 JDK on Linux.
> {quote}
> And the message "OpenType Layout tables used in font NotoSansCJKsc-Medium are not implemented in PDFBox and will be ignored " comes up for every field, which suggests that the font is opened each time.
> I can confirm this, also with a different font (ArialUni).
> {code:java}
> PDDocument doc = PDDocument.load(new File("i-130.pdf"));
> PDResources res = doc.getDocumentCatalog().getAcroForm().getDefaultResources();
> PDFont font = PDType0Font.load(doc, new FileInputStream(new File("NotoSansCJKsc-Medium.ttf")), false);
> String fontName = res.add(font).getName();
> long start = System.currentTimeMillis();
> for (Iterator<PDField> it = doc.getDocumentCatalog().getAcroForm().getFieldIterator(); it.hasNext();)
> {
>     PDField field = it.next();
>     if (field instanceof PDTextField)
>     {
>         PDTextField textField = (PDTextField) field;
>         textField.setDefaultAppearance("/" + fontName + " 0 Tf 0 g");
>         textField.setValue("中国");
>         long end = System.currentTimeMillis();
>         System.out.println("Filled " + textField.getFullyQualifiedName() + " in " + (end - start) + "ms");
>         start = end;
>     }
> }
> doc.save(new File("i-130-filled.pdf"));
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org