Skip to main content
marcosomething12321
Participant
March 19, 2026
Question

PDF text element shown in browser but not in Acrobat Reader

  • March 19, 2026
  • 3 replies
  • 27 views

I created a pdf using the perl library PDF::API2. It adds text to a pdf file in the bottom left. When I open the pdf in the browser (Chrome/Edge) or even PDF24, the text is shown. 
But when I open the pdf in Acrobat Reader, it isn’t shown. 

Please help me try to explain this

    3 replies

    MikelKlink
    Participating Frequently
    March 20, 2026

    Ok, the cause is that there are multiple errors in the page content streams of the file. Luke’s “preflight fix to embed the fonts” not only embedded the fonts but also fixed the errors (actually somewhat overeagerly).

    In detail:

    The main error: The text showing instructions were not executed inside a text object but at content stream level.

    In blank.pdf there is

    /HelvCBB~1773914601 9 Tf
    0 0 0 rg
    q
    0 1 -1 0 15 5 cm
    (Test! - 19.03.2026) Tj
    Q

    As you see, no BT / ET envelops the text object. If you put the text showing instruction into a text object like this:

    /HelvCBB~1773914601 9 Tf
    0 0 0 rg
    q
    0 1 -1 0 15 5 cm
    BT
    (Test! - 19.03.2026) Tj
    ET
    Q

    the text appears on the page!

    I assume the OP simply forgot to use PDF::API2 calls that would have started and finished a text object like this.

    Another error: Before drawing the text an attempt was made to draw a white rectangle (to get a white background for the added text, I assume). In blank.pdf this is done like this:

    0 0 73.044 8.325 re
    1 1 1 rg
    q
    0 1 -1 0 15 5 cm
    f
    Q

    The error here: after defining a path (as done here in the first instruction) it must immediately be drawn (e.g. filled using the f instruction). At most clipping operators may be added in-between. But in particular neither a color can be set (like here in 1 1 1 rg) nor the graphics state can be saved (q) nor the transformation matrix can be changed (0 1 -1 0 15 5 cm).

    This instruction sequence can be fixed to something like this:

    q
    1 1 1 rg
    0 1 -1 0 15 5 cm
    0 0 73.044 8.325 re
    f
    Q

    I assume the OP did not know that there are certain rules to the order of instructions used on a page content and used PDF::API2 calls in the wrong order.

    leo.r
    Community Expert
    Community Expert
    March 19, 2026

    I created a pdf using the perl library PDF::API2

     

    You can report this bug to metacpan.org (the developers of the library.)

     

    Or maybe there are already settings for font embedding in the library, as mentioned by others here, that you’re not using.

    william954
    Participating Frequently
    March 19, 2026

    Acrobat is stricter than browsers. Your text is likely written in a way that’s technically wrong but still tolerated elsewhere.

    Most likely causes:

    • Text outside page bounds

    • Font not embedded or defined properly

    • Invisible render mode or transparency

    • Wrong layer or optional content

    Quick fix: use a standard font like Helvetica, set fill color to black, and make sure coordinates are inside the page.

    Luke Jennings3
    Community Expert
    Community Expert
    March 19, 2026

    William is correct, the font is not embedded. A preflight fix to embed the fonts will make it appear in Acrobat and Reader. Try adjusting the settings when making your pdf (don’t select smallest file size), if this is not possible, you can create an Acrobat action to batch embed the fonts in a folder of pdfs.