You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Anita Kulkarni (JIRA)" <ji...@apache.org> on 2013/10/22 16:55:42 UTC

[jira] [Created] (PDFBOX-1753) The font gets gibbrish when adding a line of text to an existing PDF with a table

Anita Kulkarni created PDFBOX-1753:
--------------------------------------

             Summary: The font gets gibbrish when adding a line of text to an existing PDF with a table
                 Key: PDFBOX-1753
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1753
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 1.8.2
         Environment: Windows 7
            Reporter: Anita Kulkarni


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();
        }
    }
}
and the PDF is attached.



--
This message was sent by Atlassian JIRA
(v6.1#6144)