Dear Maruan,
thank you for your reply. 

The included pdf file can be found here:
https://filexchange.lhsystems.com/fileXchange_download/index.php?file=104789de603a37ed709da477e26544c2b696cb

The resulting pdf written by my program here:
https://filexchange.lhsystems.com/fileXchange_download/index.php?file=10479081a168741db7f7b9a2f85899e19b8b3f

I want to create a new document with a single page with text and a picture, 
which I import from another pdf file. The result can be one document. 

Klaus

-----Ursprüngliche Nachricht-----
Von: Maruan Sahyoun [mailto:[email protected]] 
Gesendet: Montag, 29. September 2014 15:41
An: [email protected]
Betreff: Re: importing pdf file

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

Reply via email to