GitHub user jknight opened a pull request:

    https://github.com/apache/pdfbox/pull/36

    Update PDPageContentStream.java

    This  function writes bytes as ascii characters directly to the page. 
    
    For use cases where only ascii text needs to be written, this solves a few 
problems:
    1) Avoids the "No glyph for X" issue (eg 
https://stackoverflow.com/questions/42228567/remove-illegal-characters-from-string-with-pdfbox).
    2) While it's possible to pre-process text before using showText(), this 
means the data will be looped through at least twice since PDFont.encode() 
loops the text.
    3) Preforms better. Everything can be kept as bytes without having to go to 
text
    
    Benchmarks vs showText():
    2000 page pdf: showText(): 579ms / writeAscii(): 419ms
    1000 page pdf: showText(): 283ms / writeAscii(): 193ms

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jknight/pdfbox patch-3

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/pdfbox/pull/36.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #36
    
----
commit c21df66774ce850b2eae5cdd9e382859ed17aa73
Author: Jeffrey Knight <[email protected]>
Date:   2017-04-20T13:17:29Z

    Update PDPageContentStream.java
    
    This  function writes bytes as ascii characters directly to the page. 
    
    For use cases where only ascii text needs to be written, this solves a few 
problems:
    1) Avoids the "No glyph for X" issue (eg 
https://stackoverflow.com/questions/42228567/remove-illegal-characters-from-string-with-pdfbox).
    2) While it's possible to pre-process text before using showText(), this 
means the data will be looped through at least twice since PDFont.encode() 
loops the text.
    3) Preforms better. Everything can be kept as bytes without having to go to 
text
    
    Benchmarks vs showText():
    2000 page pdf: showText(): 579ms / writeAscii(): 419ms
    1000 page pdf: showText(): 283ms / writeAscii(): 193ms

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to