Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-854

PDPageContentStream.drawString() doesn't work with all PDFs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.1
    • 1.4.0
    • PDModel
    • None
    • JDK 1.6.0_21

    Description

      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;
      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?

      Attachments

        1. Website_A4_Landscape_PDF14_addedText.pdf
          85 kB
          Andreas Lehmkühler
        2. Text_Added_With_iText.zip
          81 kB
          MH
        3. Website_A4_Landscape_PDF14.zip
          76 kB
          MH

        Activity

          People

            lehmi Andreas Lehmkühler
            mhilpert MH
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: