Problem solved using italicized code below. Not sure if this is the best
solution, but it works.. 

ByteArrayOutputStream baos  = new ByteArrayOutputStream();
Document document = new Document(PageSize.LETTER);
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();

// Creates a few pages of content
document = createFirstFewPages(document);

// Fetch a pdf from url and insert to the running document
PdfReader reader = new PdfReader("http://url_to_a_pdf_file";);

int ddPages = ddReader.getNumberOfPages();
                                                               
for (int i1=1; i1 <= ddPages; ++i1) {
     PdfImportedPage page = writer.getImportedPage(ddReader, i1);
     Image image = Image.getInstance(page);
     image.scalePercent(100f);
     document.add(image);                                                       
                
} 

// Creates the last pages of content
document = createLastFewPages(document); 




forusenet01 wrote:
> 
> iText-2.0.7
> 
> While creating a pdf file, i need to inject another pdf into the document
> at a certain point.
> Cant seem to figure out how to include the file.
> Thanks.
> 
> <code>
> 
> ByteArrayOutputStream baos  = new ByteArrayOutputStream();    
> Document document = new Document(PageSize.LETTER);
> PdfWriter writer = PdfWriter.getInstance(document, baos);
> document.open();
> 
> // Creates a few pages of content
> document = createFirstFewPages(document);
> 
> // Fetch a pdf from url and insert to the running document
> PdfReader reader = new PdfReader("http://url_to_a_pdf_file";);
> 
> /** HELP!!!!!!  How to inject reader data in to the document ??? **/
> 
> 
> // Creates the last pages of content
> document = createFirstFewPages(document);
> 
> // Servlet returns pdf stream to client
> document.close();     
> ServletOutputStream outs = response.getOutputStream();
> baos.writeTo(outs);
> outs.flush();
> 
> </code>
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-inject-a-pdf-from-a-url-in-to-a-document-in-construction-tp24174962p24206060.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to