6 Replies Latest reply on Apr 5, 2007 1:16 PM by norman.richards

    PDF Font Colour (Color for some...)

    damianharvey

      I am creating a PDF using the Seam iText PDF Generation components and trying to set the colour of a table cell via the p:font tag. As I see it the 'color' attribute is missing from the Seam code but is present in com.Iowagie.text.Font.

      Is there another way to set the colour or does org.jboss.seam.pdf.ui.UIFont need a bit of code like below?

      color = (Color) valueBinding(context, "color", color);
      if (color != null) {
       font.setColor(color);
      }
      


      I tried changing the code but ran into an error "Component property color is not writable" at which point I had to move on.

      Cheers,

      Damian.

        • 1. Re: PDF Font Colour (Color for some...)
          pmuir

          Looks to me like this needs a feature request in JIRA

          • 2. Re: PDF Font Colour (Color for some...)

            I've added a color option to UIFont. Let me know if you have any problems with it.

            • 3. Re: PDF Font Colour (Color for some...)
              damianharvey

              Thanks for that. The good news is that colors now work. The bad news is that <p:image> is broken. It gives a NPE.

              SEVERE: Error Rendering View[/public/TestPDF.xhtml]
              java.lang.NullPointerException
               at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)
               at com.lowagie.text.Image.getInstance(Image.java:460)
               at org.jboss.seam.pdf.ui.UIImage.createITextObject(UIImage.java:145)
               at org.jboss.seam.pdf.ui.ITextComponent.encodeBegin(ITextComponent.java:169)
               at org.jboss.seam.pdf.ui.ITextComponent.encode(ITextComponent.java:232)
               at org.jboss.seam.pdf.ui.ITextComponent.encodeChildren(ITextComponent.java:201)


              Replacing the jboss-seam-pdf.jar with the one from 1.2.1 lets image work again, but of course not color.

              Cheers,

              Damian.

              • 4. Re: PDF Font Colour (Color for some...)

                p:image has changed for 1.3. It would now uses the value attribute for all types of values:

                <p:image alignment="right" wrap="true" value="/jboss.jpg" />
                <p:image alignment="center" value="#{images.chart}" />

                It also accepts seam image transforms::

                <p:image alignment="center" value="#{images.chart}">
                <s:transformImageBlur radius="3" />
                </p:image>

                • 5. Re: PDF Font Colour (Color for some...)
                  damianharvey

                  If I try to use the value attribute on what was a resource it throws an error:

                  java.lang.IllegalArgumentException: Cannot convert /img/myimage.jpg of type class java.lang.String to class java.awt.Image


                  Looking at the UIImage code I can't see how it could ever take a path to an image. Or am I missing something?

                  Thanks,

                  Damian.

                  • 6. Re: PDF Font Colour (Color for some...)

                    The above code fragments are from the itext example. You'll need to provide more details.