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 )
}
}
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.