Dear Klaus, I’m guessing from your code that
a) you would like to generate a new document with a single page and some text and b) overlay another document on top of that page Is that correct? Unfortunately due to restrictions of the mailing list the attachments are not available. Could you upload these to a public location? BR Maruan Sahyoun FileAffairs GmbH Josef-Schappe-Straße 21 40882 Ratingen Tel: +49 (2102) 89497 88 Fax: +49 (2102) 89497 91 [email protected] www.fileaffairs.de Geschäftsführer: Maruan Sahyoun Handelsregister: AG Düsseldorf, HRB 53837 UST.-ID: DE248275827 Am 29.09.2014 um 15:05 schrieb <[email protected]> <[email protected]>: > Hello, > I’m validating the use of pdfbox 1.8.6 for the creation of a pdf file for an > editor. Therefore I need the possibility to include a pdf file (picture). > > I tried some coding, but it is not fully readable with Acrobat Reader. I’m > not sure, if I use the wrong concept for this or if it is simple a mistake in > pdfbox. > > Please can you give me a hint. > > My coding: > > public static void main(String[] args) { > > try > { > float width = 150.0f; > float height = 400.0f; > PDRectangle sizePDF = new PDRectangle(width,height); > PDDocument aDoc = new PDDocument(); > PDPage aPage = new PDPage(sizePDF); > aDoc.addPage( aPage ); > PDPageContentStream aContent = new PDPageContentStream(aDoc, > aPage); > > PDFont font = PDType1Font.HELVETICA_BOLD; > aContent.beginText(); > aContent.setFont( font, 12 ); > aContent.moveTextPositionByAmount( 2, 5 ); > aContent.drawString( "Import a pdf file:" ); > aContent.endText(); > > File aFile = new File("c:\\hallo.pdf"); > byte buffer[] = new byte[(int) aFile.length()]; > FileInputStream In = new FileInputStream(aFile); > In.read(buffer); > In.close(); > > ByteArrayInputStream in = new ByteArrayInputStream(buffer); > PDStream aStream = new PDStream (aDoc, in); > PDXObjectForm aObject = new PDXObjectForm( aStream ); > aContent.drawXObject(aObject,2,30,150,150); > > aContent.close(); > aDoc.save( "c:\\pdftest.pdf"); > aDoc.close(); > } > catch (Exception e) > { > System.out.println(" error creating pdf file." > + e.toString()); > } > } > } > > The used data and the output is attached to the mail. > > Thanks > Klaus Graaf

