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

MH commented on PDFBOX-854:
---------------------------

Ha! It's not the font! It's the coordinates! added some "debug" code:

-----------------------
                                contentStream.beginText();
                                
contentStream.setStrokingColor(java.awt.Color.red); //test
                                
contentStream.setNonStrokingColor(java.awt.Color.blue); //test: text 
(foreground) color
                                contentStream.drawLine(0.0f, 0.0f, 100.0f, 
200.0f); //test
                                contentStream.setFont(font, sizeOfFont);
                                
                                contentStream.moveTextPositionByAmount(xf, yf);
                                contentStream.drawString(text);
                                
                                contentStream.moveTextPositionByAmount(-xf, 
-yf); //test
                                contentStream.drawString(text+" ***"); //test
                                
                                contentStream.endText();
------------------------

And here's the result:

The "missing" text is probably not missing but drawn at the wrong place! First 
I added the colors, then the line. For the PDFs with the "visible" (correct) 
text, the line draws from the bottom left corner upwards+right. For the PDFs 
with the "missing" text, the line draws from the TOP left corner 
downwards+right!!! 

Then I added "text+***" and this text also got drawn on the problematic PDFS: 
for the "good" PDFS, the additional text is written horizontally at the bottom 
left corner. For the "bad" PDFs, the text is written VERTICALLY starting from 
the TOP left corner!

=> somehow the coordinates (system) is different in the problematic PDFs!


> PDPageContentStream.drawString() doesn't work with all PDFs
> -----------------------------------------------------------
>
>                 Key: PDFBOX-854
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-854
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.3.0
>         Environment: JDK 1.6.0_21
>            Reporter: MH
>         Attachments: Website_A4_Landscape_PDF14.zip
>
>
> I add custom text to misc exsiting PDF files. Now I wondered why my text 
> doesn't appear for a specific PDF. It is not encrypted, has the same page 
> size and adding Text with iText 2.1.7 works as expected. My code to add text 
> is:
> ----------------------------------
>                             final PDPage page = (PDPage) allPages.get(i);
>                             final PDPageContentStream contentStream = new 
> PDPageContentStream(doc, page, true, false);
>                             contentStream.beginText();
>                             contentStream.setFont(font, sizeOfFont);
>                             contentStream.moveTextPositionByAmount(xf, yf);
>                             contentStream.drawString(text);
>                             contentStream.endText();
>                             contentStream.close();
> ---------------------------------
> I tried to find differences between this PDF and other PDFs. What I noticed: 
> the PDF where I can't see the text has a PDF-Version "1.3" and was created by 
> "AFPL Ghostscript 8.54". Is there some known issue with PDFBox and such 
> "older" PDF formats?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to