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

The font gets gibbrish when adding a line of text to an existing PDF with a table

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.2
    • 1.8.3, 2.0.0
    • PDModel
    • None
    • Windows 7

    Description

      When trying to add a line to the existing PDF document with a table the table headers appear gibberish.
      the table header used to be PMITS Asset ID and after adding the header it reads as: 3 0 , 7 6 $ V V H W. some gibberish characters. Here is my code:
      // the document
      PDDocument doc = null;
      try
      {
      doc = PDDocument.load( file );

      List allPages = doc.getDocumentCatalog().getAllPages();
      //PDFont font = PDType1Font.HELVETICA_BOLD;

      for( int i=0; i<allPages.size(); i++ )

      { PDPage page = (PDPage)allPages.get( i ); PDRectangle pageSize = page.findMediaBox(); PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true,true); PDFont font = PDType1Font.TIMES_ROMAN; float fontSize = 15.0f; contentStream.beginText(); // set font and font size contentStream.setFont( font, fontSize); contentStream.moveTextPositionByAmount(700, 1150); contentStream.drawString( message); contentStream.endText(); //contentStream. contentStream.close();}

      doc.save( outfile );
      }
      finally
      {
      if( doc != null )

      { doc.close(); }

      }
      }
      Stack overflow has a lot of discussion about this issue and explained by user MLK
      http://stackoverflow.com/questions/19322553/adding-header-to-existing-pdf-file-using-pdfbox
      I am not sure how to attache the test PDF to this issue.

      Attachments

        Activity

          People

            lehmi Andreas Lehmkühler
            kulkarni Anita Kulkarni
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 336h
                336h
                Remaining:
                Remaining Estimate - 336h
                336h
                Logged:
                Time Spent - Not Specified
                Not Specified