Hi Everyone, I'm working on a deployment of iText that will be generating multiple reports, possibly on multiple threads. My understanding is that all of the mutable state of the document and writer objects are self-contained. If that's true, I believe that it should be fine for multiple threads to work simultaneously - so long as each thread is working on its own writer object.
One exception that I do see is the manipulation of the rtf heading paragraph styles. According to: http://itextdocs.lowagie.com/tutorial/rtf/features/styles/index.php you can change the font size, style, etc. of the paragraph headings by manipulating some global Font objects. This seems problematic - not just for multiple threads - but for generating multiple reports within the same jvm; e.g. one report assumes the defaults are set, after another has changed them. I came up with a solution - which might be an awful hack, but it seems to work. To RtfDocumentSettings.java, I added: public RtfParagraphStyle getRtfParagraphStyle(String styleName) { return this.document.getDocumentHeader().getRtfParagraphStyle(styleName); } Then (after opening the document) I can modify the heading font for a specific report with: RtfParagraphStyle headerStyle = writer.getDocumentSettings().getRtfParagraphStyle("heading 1"); headerStyle.setSize(14f); Since registerParagraphStyle clones the global object specifically for the document, this approach solves the shared object problem. I understand that there can only be one style for the entire document (last one wins I believe), and that's ok. So - I have two questions: 1. Is there a reason why the above should be avoided? 2. Are there any other known places where things might not be thread-safe? (I googled for this, and the answer was no, but want to double-check, especially in light of my unusual use case above) One other constraint is that I must use these heading styles, because I am also using them in the table of contents. Any advice is appreciated. Cheers, Scott ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ 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/
