Re: [iText-questions] Getting a PdfTemplate from a PdfReader
Thomas Hauk wrote: I had a single huge method generating these PDFs and it was working fine. However, I decided to refactor the 200+ line function into multiple functions, and now I've hit a compile error in my (refactored) method that should return a PdfTemplate, because it requires a PdfWriter. That's a totally different question. You were attacking iText by saying something that sounded as: it is stupid that I need a writer to get a template. Instead of trying to understand what I am doing You didn't say what you are doing. You should ask questions like this: http://www.catb.org/~esr/faqs/smart-questions.html In any case, I wrote a large part of iText, and I don't understand the problem based on your description. The way I see it: you had something that worked, and you broke it. You broke it because you made a design error. IMO this isn't really a question about iText, but rather about design. I don't understand why you can't provide a writer to the method that returns a template. -- ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
Re: [iText-questions] Getting a PdfTemplate from a PdfReader
On May 27, 2010, at 12:46 AM, Bruno Lowagie wrote: You were attacking iText by saying something that sounded as: it is stupid that I need a writer to get a template. I never said that. I said it was strange. Which it is. Generally if two objects need to co-exist then that's a code smell for a circular dependency in the class hierarchy. I didn't call you stupid. Meanwhile, you were busy saying nonsense about the sky being blue. You didn't say what you are doing. You should ask questions like this: http://www.catb.org/~esr/faqs/smart-questions.html Never gave me the chance, nor did you enquire further. I stand by my previous statements. -- Thomas Hauk Shaggy Frog Software www.shaggyfrog.com -- ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
[iText-questions] Getting a PdfTemplate from a PdfReader
Let's say I have a PdfReader object and I want to get a PdfTemplate object from it for the first page. Is the only way to do this through a PdfWriter object? pdfTemplate = writer.getImportedPage(pdfReader, 1); If not, what is the better way? If so, why do I have to create a *writer* object to get a PdfTemplate? It seems very strange to me -- I don't want to write out anything at that point. Everything's in-memory up to that point. -- Thomas Hauk Shaggy Frog Software www.shaggyfrog.com -- ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
Re: [iText-questions] Getting a PdfTemplate from a PdfReader
Thomas Hauk wrote: Let's say I have a PdfReader object and I want to get a PdfTemplate object from it for the first page. Is the only way to do this through a PdfWriter object? pdfTemplate = writer.getImportedPage(pdfReader, 1); If not, what is the better way? If so, why do I have to create a *writer* object to get a PdfTemplate? It seems very strange to me -- I don't want to write out anything at that point. Everything's in-memory up to that point. That's explained in the book. A page = a page content stream + resources When you get a PdfTemplate (containing the content stream), the resources are already copied to the writer. The PdfTemplate only keeps a reference to those resources (so that you don't have to keep MBs of images and fonts in memory). -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info -- ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
Re: [iText-questions] Getting a PdfTemplate from a PdfReader
On May 26, 2010, at 8:55 PM, 1T3XT info wrote: That's explained in the book. A page = a page content stream + resources When you get a PdfTemplate (containing the content stream), the resources are already copied to the writer. The PdfTemplate only keeps a reference to those resources (so that you don't have to keep MBs of images and fonts in memory). So, what would a method look like that takes a PdfReader object and an int for the page number, and returns back a PdfTemplate object? Or is that not possible since a PdfTemplate needs a PdfWriter object? (In which case, is that not a kind of circular dependency in the design?) -- Thomas Hauk Shaggy Frog Software www.shaggyfrog.com -- ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
Re: [iText-questions] Getting a PdfTemplate from a PdfReader
Thomas Hauk wrote: So, what would a method look like that takes a PdfReader object and an int for the page number, and returns back a PdfTemplate object? PdfTemplate can't store the resources. Or is that not possible since a PdfTemplate needs a PdfWriter object? (In which case, is that not a kind of circular dependency in the design?) Why would you want to create a PdfTemplate without a writer? That's like creating a single page PDF. Creating a single page PDF from an existing PDF is possible using iText, but it has some serious downsides in comparison with using PdfTemplate + a writer (bad resources management is the major downside). You should know more about PDF before I can give a better answer. Honestly: this is a pointless discussion. It's like asking why is the sky blue? without knowing anything about the breaking index of light that shines to a medium. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info -- ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
Re: [iText-questions] Getting a PdfTemplate from a PdfReader
On May 26, 2010, at 9:38 PM, 1T3XT info wrote: Why would you want to create a PdfTemplate without a writer? That's like creating a single page PDF. I am actually creating a single page PDF, by arranging 2 existing PDF files in a pattern on the page. (4 alternating rows of PDF A, PDF B, PDF A, PDF B.) Each PDF file may have an embedded AcroForm and I am filling that form programmatically. See my original question here: http://thread.gmane.org/gmane.comp.java.lib.itext.general/51365 I had a single huge method generating these PDFs and it was working fine. However, I decided to refactor the 200+ line function into multiple functions, and now I've hit a compile error in my (refactored) method that should return a PdfTemplate, because it requires a PdfWriter. Creating a single page PDF from an existing PDF is possible using iText, but it has some serious downsides in comparison with using PdfTemplate + a writer (bad resources management is the major downside). You should know more about PDF before I can give a better answer. Honestly: this is a pointless discussion. It's like asking why is the sky blue? without knowing anything about the breaking index of light that shines to a medium. In a sense, I am coming here asking questions about iText, to which you are saying, I need to know more about iText first. No kidding. The problem is not with what I am asking, but rather, with how you are answering it. Instead of trying to understand what I am doing or what I need, you have quickly fired off some kind of insulting comment. The only other time I asked a question to this list, you scoffed at it, told me it was impossible, and left it to another user to not only explain to me how what I wanted *was* possible, but even gave me example code showing me how to do it. The reason I am using a PdfTemplate object is because that's what I need for the aforementioned solution I got via this mailing list. Which was successful, until I refactored, my program and discovered this object dependency between PdfTemplate and PdfWriter. In conclusion, I'm not sure who you are, but if you represent the iText project, you come across in a really condescending manner, and you should reconsider the way you answer questions. P.S. If a 10-year old asked me why is the sky blue? my first response wouldn't be to mock their ignorance of light scattering. -- Thomas Hauk Shaggy Frog Software www.shaggyfrog.com -- ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/