Please post the files from Writer and Draw, as well as the output from your program.
PS: Which version of iText are you using. --Mark Storer Senior Software Engineer Cardiff.com #include <disclaimer> typedef std::Disclaimer<Cardiff> DisCard; > -----Original Message----- > From: Harri T. [mailto:haba...@gmail.com] > Sent: Tuesday, November 10, 2009 12:44 PM > To: itext-questions@lists.sourceforge.net > Subject: [iText-questions] Merging content with a pdf created > withOpenOffice.org Draw > > > Hi! I should implement a program that uses PDF document as a template > and adds content from text file over the template. The current > implementation below works if template is made with OO3 > Writer. However, > if the template pdf is created with OO3 Draw, only the > template content > is displayed in the resulting pdf. > > I tried also layers but result is the same. Even if the > template is in a > "lower" layer and text content in a "higher" layer, the text > content is > displayed in Adobe Reader only if the lower layer is hidden. > > So, how should I change the program to make work also with a template > pdf created with OO3 Draw? > > Harri > > public static void main(String[] args) throws Exception { > if (args.length != 3) { > System.err.println("Usage: java -jar merge.jar > pdf_in txt_in pdf_out"); > } > String pdfIn = args[0]; > String textIn = args[1]; > String pdfOut = args[2]; > > PdfReader reader = new PdfReader(pdfIn); > Document document = new Document(PageSize.A4); > PdfWriter writer = PdfWriter.getInstance(document, > new FileOutputStream(pdfOut)); > document.open(); > PdfContentByte cb = writer.getDirectContent(); > > document.newPage(); > > PdfImportedPage page1 = writer.getImportedPage(reader, 1); > cb.addTemplate(page1, 1, 0, 0, 1, 0, 0); > > Paragraph paragraph = new Paragraph(); > paragraph.setLeading(0.5f, 0.5f); > File file = new File(textIn); > BufferedReader in = new BufferedReader(new FileReader(file)); > String line; > StringBuffer buffer = new StringBuffer((int) file.length()); > while ((line = in.readLine()) != null) { > buffer.append(line); > buffer.append('\n'); > } > paragraph.add(new Chunk(buffer.toString(), new > Font(Font.COURIER, 7, Font.NORMAL))); > document.add(paragraph); > > document.close(); > } > > > -------------------------------------------------------------- > ---------------- > Let Crystal Reports handle the reporting - Free Crystal > Reports 2008 30-Day > trial. Simplify your report design, integration and > deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > 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/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net 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/