[ https://issues.apache.org/jira/browse/PDFBOX-1753?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Anita Kulkarni updated PDFBOX-1753: ----------------------------------- 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. was: 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. > 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 > Original Estimate: 336h > Remaining Estimate: 336h > > 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. -- This message was sent by Atlassian JIRA (v6.1#6144)