Just wanted to follow up - sorry if this whole issue seems a little on
the fringe.

Unless there is a better solution than below, could we get the small
required change into the next release?

To com.lowagie.text.rtf.document.RtfDocumentSettings.java, I added:

public RtfParagraphStyle getRtfParagraphStyle(String styleName) {
   return this.document.getDocumentHeader().getRtfParagraphStyle(styleName);
}

Any suggestions appreciated.

Cheers,
Scott

On Wed, May 20, 2009 at 1:50 PM, Scott Miller <[email protected]> wrote:
> 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
>

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
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