SeamFramework.orgCommunity Documentation

Chapter 18. iText PDF generation

18.1. Using PDF Support
18.1.1. Creating a document
18.1.2. Basic Text Elements
18.1.3. Headers and Footers
18.1.4. Chapters and Sections
18.1.5. Lists
18.1.6. Tables
18.1.7. Document Constants
18.2. Charting
18.3. Bar codes
18.4. Fill-in-forms
18.5. Rendering Swing/AWT components
18.6. Configuring iText
18.7. Further documentation

Seam now includes a component set for generating documents using iText. The primary focus of Seam's iText document support is for the generation of PDF documents, but Seam also offers basic support for RTF document generation.

iText support is provided by jboss-seam-pdf.jar. This JAR contains the iText JSF controls, which are used to construct views that can render to PDF, and the DocumentStore component, which serves the rendered documents to the user. To include PDF support in your application, put jboss-seam-pdf.jar in your WEB-INF/lib directory along with the iText JAR file. There is no further configuration needed to use Seam's iText support.

The Seam iText module requires the use of Facelets as the view technology. Future versions of the library may also support the use of JSP. Additionally, it requires the use of the seam-ui package.

The examples/itext project contains an example of the PDF support in action. It demonstrates proper deployment packaging, and it contains a number examples that demonstrate the key PDF generation features current supported.

<p:document>

Description

Documents are generated by facelet XHTML files using tags in the http://jboss.com/products/seam/pdf namespace. Documents should always have the document tag at the root of the document. The document tag prepares Seam to generate a document into the DocumentStore and renders an HTML redirect to that stored content.

Attributes

  • type — The type of the document to be produced. Valid values are PDF, RTF and HTML modes. Seam defaults to PDF generation, and many of the features only work correctly when generating PDF documents.

  • pageSize — The size of the page to be generate. The most commonly used values would be LETTER and A4. A full list of supported pages sizes can be found in com.lowagie.text.PageSize class. Alternatively, pageSize can provide the width and height of the page directly. The value "612 792", for example, is equivalent to the LETTER page size.

  • orientation — The orientation of the page. Valid values are portrait and landscape. In landscape mode, the height and width page size values are reversed.

  • margins — The left, right, top and bottom margin values.

  • marginMirroring — Indicates that margin settings should be reversed an alternating pages.

  • disposition — When generating PDFs in a web browser, this determines the HTTP Content-Disposition of the document. Valid values are inline, which indicates the document should be displayed in the browser window if possible, and attachment, which indicates that the document should be treated as a download. The default value is inline.

  • fileName — For attachments, this value overrides the downloaded file name.

Metadata Attributes

  • title

  • subject

  • keywords

  • author

  • creator

Usage


<p:document xmlns:p="http://jboss.com/products/seam/pdf">                                                      
  The document goes here.                                                                                             
</p:document>

Useful documents will need to contain more than just text; however, the standard UI components are geared towards HTML generation and are not useful for generating PDF content. Instead, Seam provides a special UI components for generating suitable PDF content. Tags like <p:image> and <p:paragraph> are the basic foundations of simple documents. Tags like <p:font> provide style information to all the content surrounding them.

<p:paragraph>

Description

Most uses of text should be sectioned into paragraphs so that text fragments can be flowed, formatted and styled in logical groups.

Attributes

  • firstLineIndent

  • extraParagraphSpace

  • leading

  • multipliedLeading

  • spacingBefore — The blank space to be inserted before the element.

  • spacingAfter — The blank space to be inserted after the element.

  • indentationLeft

  • indentationRight

  • keepTogether

Usage


<p:paragraph alignment="justify">
    This is a simple document.  It isn't very fancy.
</p:paragraph>

<p:text>

Description

The text tag allows text fragments to be produced from application data using normal JSF converter mechanisms. It is very similar to the outputText tag used when rendering HTML documents.

Attributes

  • value — The value to be displayed. This will typically be a value binding expression.

Usage


<p:paragraph>
    The item costs <p:text value="#{product.price}">
        <f:convertNumber type="currency" currencySymbol="$"/>
    </p:text>
</p:paragraph>

<p:html>

Description

The html tag renders HTML content into the PDF.

Attributes

  • value — The text to be displayed.

Usage



<p:html value="This is HTML with <b>some markup</b>." />
<p:html>
    <h1>This is more complex HTML</h1>
    <ul>
        <li>one</li>
        <li>two</li>
        <li>three</li>
    </ul>
</p:html>

<p:html>
    <s:formattedText value="*This* is |Seam Text| as HTML.  It's very^cool^." />
</p:html>                                    

<p:font>

Description

The font tag defines the default font to be used for all text inside of it.

Attributes

  • name — The font name, for example: COURIER, HELVETICA, TIMES-ROMAN, SYMBOL or ZAPFDINGBATS.

  • size — The point size of the font.

  • style — The font styles. Any combination of : NORMAL, BOLD, ITALIC, OBLIQUE, UNDERLINE, LINE-THROUGH

  • color — The font color. (see Section 18.1.7.1, “Color Values” for color values)

  • encoding — The character set encoding.

Usage


<p:font name="courier" style="bold" size="24">
    <p:paragraph>My Title</p:paragraph>
</p:font>

<p:newPage>

Description

p:newPage inserts a page break.

Usage


<p:newPage />

<p:image>

Description

p:image inserts an image into the document. Images can be loaded from the classpath or from the web application context using the value attribute.

Resources can also be dynamically generated by application code. The imageData attribute can specify a value binding expression whose value is a java.awt.Image object.

Attributes

  • value — A resource name or a method expression binding to an application-generated image.

  • rotation — The rotation of the image in degrees.

  • height — The height of the image.

  • width — The width of the image.

  • alignment— The alignment of the image. (see Section 18.1.7.2, “Alignment Values” for possible values)

  • alt — Alternative text representation for the image.

  • indentationLeft

  • indentationRight

  • spacingBefore — The blank space to be inserted before the element.

  • spacingAfter — The blank space to be inserted after the element.

  • widthPercentage

  • initialRotation

  • dpi

  • scalePercent — The scaling factor (as a percentage) to use for the image. This can be expressed as a single percentage value or as two percentage values representing separate x and y scaling percentages.

  • scaleToFit — Specifies the X any Y size to scale the image to. The image will be scale to fit those dimensions as closely as possible while preserving the XY ratio of the image.

  • wrap

  • underlying

Usage


<p:image value="/jboss.jpg" />

<p:image value="#{images.chart}" />

<p:anchor>

Description

p:anchor defines clickable links from a document. It supports the following attributes:

Attributes

  • name — The name of an in-document anchor destination.

  • reference — The destination the link refers to. Links to other points in the document should begin with a "#". For example, "#link1" to refer to an anchor position with a name of link1. Links may also be a full URL to point to a resource outside of the document.

Usage


<p:listItem><p:anchor reference="#reason1">Reason 1</p:anchor></p:listItem> 
...
<p:paragraph>
    <p:anchor name="reason1">It's the quickest way to get "rich"</p:anchor> 
    ... 
</p:paragraph>

<p:header>

<p:footer>

Description

The p:header and p:footer components provide the ability to place header and footer text on each page of a generated document. Header and footer declarations should appear at the beginning of a document.

Attributes

  • alignment — The alignment of the header/footer box section. (see Section 18.1.7.2, “Alignment Values” for alignment values)

  • backgroundColor — The background color of the header/footer box. (see Section 18.1.7.1, “Color Values” for color values)

  • borderColor — The border color of the header/footer box. Individual border sides can be set using borderColorLeft, borderColorRight, borderColorTop and borderColorBottom.(see Section 18.1.7.1, “Color Values” for color values)

  • borderWidth — The width of the border. Individual border sides can be specified using borderWidthLeft, borderWidthRight, borderWidthTop and borderWidthBottom.

Usage


<f:facet name="header">
  <p:font size="12">
    <p:footer borderWidthTop="1" borderColorTop="blue" 
              borderWidthBottom="0" alignment="center">
        Why Seam? [<p:pageNumber />]
    </p:footer>
  </p:font>
</f:facet>

<p:pageNumber>

Description

The current page number can be placed inside of a header or footer using the p:pageNumber tag. The page number tag can only be used in the context of a header or footer and can only be used once.

Usage


<p:footer borderWidthTop="1" borderColorTop="blue" 
          borderWidthBottom="0" alignment="center">
    Why Seam? [<p:pageNumber />]
</p:footer>

<p:chapter>

<p:section>

Description

If the generated document follows a book/article structure, the p:chapter and p:section tags can be used to provide the necessary structure. Sections can only be used inside of chapters, but they may be nested arbitrarily deep. Most PDF viewers provide easy navigation between chapters and sections in a document.

Attributes

  • alignment — The alignment of the header/footer box section. (see Section 18.1.7.2, “Alignment Values” for alignment values)

  • number — The chapter number. Every chapter should be assigned a chapter number.

  • numberDepth — The depth of numbering for section. All sections are numbered relative to their surrounding chapter/sections. The fourth section of the first section of chapter three would be section 3.1.4, if displayed at the default number depth of three. To omit the chapter number, a number depth of 2 should be used. In that case, the section number would be displayed as 1.4.

Usage


<p:document xmlns:p="http://jboss.com/products/seam/pdf"
            title="Hello">

   <p:chapter number="1">
      <p:title><p:paragraph>Hello</p:paragraph></p:title>
      <p:paragraph>Hello #{user.name}!</p:paragraph>
   </p:chapter>

   <p:chapter number="2">
      <p:title><p:paragraph>Goodbye</p:paragraph></p:title>
      <p:paragraph>Goodbye #{user.name}.</p:paragraph>
   </p:chapter>

</p:document> 

<p:header>

Description

Any chapter or section can contain a p:title. The title will be displayed next to the chapter/section number. The body of the title may contain raw text or may be a p:paragraph.

List structures can be displayed using the p:list and p:listItem tags. Lists may contain arbitrarily-nested sublists. List items may not be used outside of a list. The following document uses the ui:repeat tag to to display a list of values retrieved from a Seam component.


<p:document xmlns:p="http://jboss.com/products/seam/pdf"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            title="Hello">
   <p:list style="numbered">
      <ui:repeat value="#{documents}" var="doc">
         <p:listItem>#{doc.name}</p:listItem>
      </ui:repeat>
   </p:list>
</p:document>

<p:list>

Attributes

  • style — The ordering/bulleting style of list. One of: NUMBERED, LETTERED, GREEK, ROMAN, ZAPFDINGBATS, ZAPFDINGBATS_NUMBER. If no style is given, the list items are bulleted.

  • listSymbol — For bulleted lists, specifies the bullet symbol.

  • indent — The indentation level of the list.

  • lowerCase — For list styles using letters, indicates whether the letters should be lower case.

  • charNumber — For ZAPFDINGBATS, indicates the character code of the bullet character.

  • numberType — For ZAPFDINGBATS_NUMBER, indicates the numbering style.

Usage


<p:list style="numbered">
  <ui:repeat value="#{documents}" var="doc">
    <p:listItem>#{doc.name}</p:listItem>
  </ui:repeat>
</p:list>

<p:listItem>

Description

p:listItem supports the following attributes:

Attributes

  • alignment — The alignment of the header/footer box section. (see Section 18.1.7.2, “Alignment Values” for alignment values)

  • alignment — The alignment of the list item. (See Section 18.1.7.2, “Alignment Values” for possible values)

  • indentationLeft — The left indentation amount.

  • indentationRight — The right indentation amount.

  • listSymbol — Overrides the default list symbol for this list item.

Usage


...

Table structures can be created using the p:table and p:cell tags. Unlike many table structures, there is no explicit row declaration. If a table has 3 columns, then every 3 cells will automatically form a row. Header and footer rows can be declared, and the headers and footers will be repeated in the event a table structure spans multiple pages.

<p:table>

Description

p:table supports the following attributes.

Attributes

  • columns — The number of columns (cells) that make up a table row.

  • widths — The relative widths of each column. There should be one value for each column. For example: widths="2 1 1" would indicate that there are 3 columns and the first column should be twice the size of the second and third column.

  • headerRows — The initial number of rows which are considered to be headers or footer rows and should be repeated if the table spans multiple pages.

  • footerRows — The number of rows that are considered to be footer rows. This value is subtracted from the headerRows value. If document has 2 rows which make up the header and one row that makes up the footer, headerRows should be set to 3 and footerRows should be set to 1

  • widthPercentage — The percentage of the page width that the table spans.

  • horizontalAlignment — The horizontal alignment of the table. (See Section 18.1.7.2, “Alignment Values” for possible values)

  • skipFirstHeader

  • runDirection

  • lockedWidth

  • splitRows

  • spacingBefore — The blank space to be inserted before the element.

  • spacingAfter — The blank space to be inserted after the element.

  • extendLastRow

  • headersInEvent

  • splitLate

  • keepTogether

Usage


<p:table columns="3" headerRows="1">
  <p:cell>name</p:cell>
  <p:cell>owner</p:cell>
  <p:cell>size</p:cell>
  <ui:repeat value="#{documents}" var="doc">
    <p:cell>#{doc.name}</p:cell>
    <p:cell>#{doc.user.name}</p:cell>
    <p:cell>#{doc.size}</p:cell>
  </ui:repeat>
</p:table>

<p:cell>

Description

p:cell supports the following attributes.

Attributes

  • colspan — Cells can span more than one column by declaring a colspan greater than 1. Tables do not have the ability to span across multiple rows.

  • horizontalAlignment — The horizontal alignment of the cell. (see Section 18.1.7.2, “Alignment Values” for possible values)

  • verticalAlignment — The vertical alignment of the cell. (see Section 18.1.7.2, “Alignment Values” for possible values)

  • padding — Padding on a given side can also be specified using paddingLeft, paddingRight, paddingTop and paddingBottom.

  • useBorderPadding

  • leading

  • multipliedLeading

  • indent

  • verticalAlignment

  • extraParagraphSpace

  • fixedHeight

  • noWrap

  • minimumHeight

  • followingIndent

  • rightIndent

  • spaceCharRatio

  • runDirection

  • arabicOptions

  • useAscender

  • grayFill

  • rotation

Usage


<p:cell>...</p:cell>

Charting support is also provided with jboss-seam-pdf.jar. Charts can be used in PDF documents or can be used as images in an HTML page. Charting requires the JFreeChart library (jfreechart.jar and jcommon.jar) to be added to the WEB-INF/lib directory. Four types of charts are currently supported: pie charts, bar charts and line charts. Where greater variety or control is needed, it is possible to construct charts using Java code.

<p:chart>

Description

Displays a chart created in Java by a Seam component.

Attributes

  • chart — The chart object to display.

  • height — The height of the chart.

  • width — The width of the chart.

Usage


<p:chart chart="#{mycomponent.chart}" width="500" height="500" />
         

<p:barchart>

Description

Displays a bar chart.

Attributes

  • chart — The chart object to display, if programmatic chart creation is being used.

  • dataset — The dataset to be displayed, if programmatic dataset is being used.

  • borderVisible — Controls whether or not a border is displayed around the entire chart.

  • borderPaint — The color of the border, if visible;

  • borderBackgroundPaint — The default background color of the chart.

  • borderStroke

  • domainAxisLabel — The text label for the domain axis.

  • domainLabelPosition — The angle of the domain axis category labels. Valid values are STANDARD, UP_45, UP_90, DOWN_45 and DOWN_90. Alternatively, the value can the positive or negative angle in radians.

  • domainAxisPaint — The color of the domain axis label.

  • domainGridlinesVisible— Controls whether or not gridlines for the domain axis are shown on the chart.

  • domainGridlinePaint— The color of the domain gridlines, if visible.

  • domainGridlineStroke — The stroke style of the domain gridlines, if visible.

  • height — The height of the chart.

  • width — The width of the chart.

  • is3D — A boolean value indicating that the chart should be rendered in 3D instead of 2D.

  • legend — A boolean value indicating whether or not the chart should include a legend.

  • legendItemPaint— The default color of the text labels in the legend.

  • legendItemBackgoundPaint— The background color for the legend, if different from the chart background color.

  • legendOutlinePaint— The color of the border around the legend.

  • orientation — The orientation of the plot, either vertical (the default) or horizontal.

  • plotBackgroundPaint— The color of the plot background.

  • plotBackgroundAlpha— The alpha (transparency) level of the plot background. It should be a number between 0 (completely transparent) and 1 (completely opaque).

  • plotForegroundAlpha— The alpha (transparency) level of the plot. It should be a number between 0 (completely transparent) and 1 (completely opaque).

  • plotOutlinePaint— The color of the range gridlines, if visible.

  • plotOutlineStroke — The stroke style of the range gridlines, if visible.

  • rangeAxisLabel — The text label for the range axis.

  • rangeAxisPaint — The color of the range axis label.

  • rangeGridlinesVisible— Controls whether or not gridlines for the range axis are shown on the chart.

  • rangeGridlinePaint— The color of the range gridlines, if visible.

  • rangeGridlineStroke — The stroke style of the range gridlines, if visible.

  • title — The chart title text.

  • titlePaint— The color of the chart title text.

  • titleBackgroundPaint— The background color around the chart title.

  • width — The width of the chart.

Usage


<p:barchart title="Bar Chart" legend="true"
            width="500" height="500">
    <p:series key="Last Year">
        <p:data columnKey="Joe" value="100" />
        <p:data columnKey="Bob" value="120" />
    </p:series>        <p:series key="This Year">
        <p:data columnKey="Joe" value="125" />
        <p:data columnKey="Bob" value="115" />
    </p:series>
</p:barchart>

<p:linechart>

Description

Displays a line chart.

Attributes

  • chart — The chart object to display, if programmatic chart creation is being used.

  • dataset — The dataset to be displayed, if programmatic dataset is being used.

  • borderVisible — Controls whether or not a border is displayed around the entire chart.

  • borderPaint — The color of the border, if visible;

  • borderBackgroundPaint — The default background color of the chart.

  • borderStroke

  • domainAxisLabel — The text label for the domain axis.

  • domainLabelPosition — The angle of the domain axis category labels. Valid values are STANDARD, UP_45, UP_90, DOWN_45 and DOWN_90. Alternatively, the value can the positive or negative angle in radians.

  • domainAxisPaint — The color of the domain axis label.

  • domainGridlinesVisible— Controls whether or not gridlines for the domain axis are shown on the chart.

  • domainGridlinePaint— The color of the domain gridlines, if visible.

  • domainGridlineStroke — The stroke style of the domain gridlines, if visible.

  • height — The height of the chart.

  • width — The width of the chart.

  • is3D — A boolean value indicating that the chart should be rendered in 3D instead of 2D.

  • legend — A boolean value indicating whether or not the chart should include a legend.

  • legendItemPaint — The default color of the text labels in the legend.

  • legendItemBackgoundPaint — The background color for the legend, if different from the chart background color.

  • legendOutlinePaint — The color of the border around the legend.

  • orientation — The orientation of the plot, either vertical (the default) or horizontal.

  • plotBackgroundPaint — The color of the plot background.

  • plotBackgroundAlpha — The alpha (transparency) level of the plot background. It should be a number between 0 (completely transparent) and 1 (completely opaque).

  • plotForegroundAlpha — The alpha (transparency) level of the plot. It should be a number between 0 (completely transparent) and 1 (completely opaque).

  • plotOutlinePaint — The color of the range gridlines, if visible.

  • plotOutlineStroke — The stroke style of the range gridlines, if visible.

  • rangeAxisLabel — The text label for the range axis.

  • rangeAxisPaint — The color of the range axis label.

  • rangeGridlinesVisible — Controls whether or not gridlines for the range axis are shown on the chart.

  • rangeGridlinePaint — The color of the range gridlines, if visible.

  • rangeGridlineStroke — The stroke style of the range gridlines, if visible.

  • title — The chart title text.

  • titlePaint — The color of the chart title text.

  • titleBackgroundPaint — The background color around the chart title.

  • width — The width of the chart.

Usage


<p:linechart title="Line Chart"
            width="500" height="500">
    <p:series key="Prices">
        <p:data columnKey="2003" value="7.36" />
        <p:data columnKey="2004" value="11.50" />
        <p:data columnKey="2005" value="34.625" />
        <p:data columnKey="2006" value="76.30" />
        <p:data columnKey="2007" value="85.05" />
    </p:series>
</p:linechart>

<p:piechart>

Description

Displays a pie chart.

Attributes

  • title — The chart title text.

  • chart — The chart object to display, if programmatic chart creation is being used.

  • dataset — The dataset to be displayed, if programmatic dataset is being used.

  • label — The default label text for pie sections.

  • legend — A boolean value indicating whether or not the chart should include a legend. Default value is true

  • is3D —A boolean value indicating that the chart should be rendered in 3D instead of 2D.

  • labelLinkMargin — The link margin for labels.

  • labelLinkPaint — The paint used for the label linking lines.

  • labelLinkStroke — he stroke used for the label linking lines.

  • labelLinksVisible — A flag that controls whether or not the label links are drawn.

  • labelOutlinePaint — The paint used to draw the outline of the section labels.

  • labelOutlineStroke — The stroke used to draw the outline of the section labels.

  • labelShadowPaint — The paint used to draw the shadow for the section labels.

  • labelPaint — The color used to draw the section labels

  • labelGap — The gap between the labels and the plot as a percentage of the plot width.

  • labelBackgroundPaint — The color used to draw the background of the section labels. If this is null, the background is not filled.

  • startAngle — The starting angle of the first section.

  • circular — A boolean value indicating that the chart should be drawn as a circle. If false, the chart is drawn as an ellipse. The default is true.

  • direction — The direction the pie section are drawn. One of: clockwise or anticlockwise. The default is clockwise.

  • sectionOutlinePaint — The outline paint for all sections.

  • sectionOutlineStroke — The outline stroke for all sections

  • sectionOutlinesVisible — Indicates whether an outline is drawn for each section in the plot.

  • baseSectionOutlinePaint — The base section outline paint.

  • baseSectionPaint — The base section paint.

  • baseSectionOutlineStroke — The base section outline stroke.

Usage


<p:piechart title="Pie Chart" circular="false" direction="anticlockwise" 
    startAngle="30" labelGap="0.1" labelLinkPaint="red">    
    <p:series key="Prices"> 
        <p:data key="2003" columnKey="2003" value="7.36" /> 
        <p:data key="2004" columnKey="2004" value="11.50" /> 
        <p:data key="2005" columnKey="2005" value="34.625" /> 
        <p:data key="2006" columnKey="2006" value="76.30" /> 
        <p:data key="2007" columnKey="2007" value="85.05" /> 
    </p:series> 
</p:piechart>

<p:series>

Description

Category data can be broken down into series. The series tag is used to categorize a set of data with a series and apply styling to the entire series.

Attributes

  • key — The series name.

  • seriesPaint — The color of each item in the series

  • seriesOutlinePaint — The outline color for each item in the series.

  • seriesOutlineStroke — The stroke used to draw each item in the series.

  • seriesVisible — A boolean indicating if the series should be displayed.

  • seriesVisibleInLegend — A boolean indicating if the series should be listed in the legend.

Usage


<p:series key="data1">
    <ui:repeat value="#{data.pieData1}" var="item">
        <p:data columnKey="#{item.name}" value="#{item.value}" />
    </ui:repeat>
</p:series>

<p:data>

Description

The data tag describes each data point to be displayed in the graph.

Attributes

  • key — The name of the data item.

  • series — The series name, when not embedded inside a <p:series>.

  • value — The numeric data value.

  • explodedPercent — For pie charts, indicates how exploded a from the pie a piece is.

  • sectionOutlinePaint — For bar charts, the color of the section outline.

  • sectionOutlineStroke — For bar charts, the stroke type for the section outline.

  • sectionPaint — For bar charts, the color of the section.

Usage


<p:data key="foo" value="20" sectionPaint="#111111" 
        explodedPercent=".2" />
<p:data key="bar" value="30" sectionPaint="#333333" />
<p:data key="baz" value="40" sectionPaint="#555555" 
        sectionOutlineStroke="my-dot-style" />

<p:color>

Description

The color component declares a color or gradient than can be referenced when drawing filled shapes.

Attributes

  • color — The color value. For gradient colors, this the starting color. Section 18.1.7.1, “Color Values”

  • color2 — For gradient colors, this is the color that ends the gradient.

  • point — The co-ordinates where the gradient color begins.

  • point2 — The co-ordinates where the gradient color ends.

Usage


<p:color id="foo" color="#0ff00f"/>
<p:color id="bar" color="#ff00ff" color2="#00ff00" 
                  point="50 50" point2="300 300"/>

<p:stroke>

Description

Describes a stroke used to draw lines in a chart.

Attributes

  • width — The width of the stroke.

  • cap — The line cap type. Valid values are butt, round and square

  • join — The line join type. Valid values are miter, round and bevel

  • miterLimit — For miter joins, this value is the limit of the size of the join.

  • dash — The dash value sets the dash pattern to be used to draw the line. The space separated integers indicate the length of each alternating drawn and undrawn segments.

  • dashPhase — The dash phase indicates the offset into the dash pattern that the line should be drawn with.

Usage


<p:stroke id="dot2" width="2" cap="round" join="bevel" dash="2 3" />

Seam can use iText to generate barcodes in a wide variety of formats. These barcodes can be embedded in a PDF document or displayed as an image on a web page. Note that when used with HTML images, barcodes can not currently display barcode text in the barcode.

If you have a complex, pre-generated PDF with named fields, you can easily fill in the values from your application and present it to the user.

<p:form>

Description

Defines a form template to populate

Attributes

  • URL — An URL pointing to the PDF file to use as a template. If the value has no protocol part (://), the file is read locally.

  • filename — The filename to use for the generated PDF file.

  • exportKey — Place the generated PDF file in a DocumentData object under the specified key in the event context. If set, no redirect will occur.

<p:field>

Description

Connects a field name to its value

Attributes

  • name — The name of the field

  • value — The value of the field

  • readOnly — Should the field be read-only? Defaults to true.



            
                <p:form
                    xmlns:p="http://jboss.com/products/seam/pdf"
                    URL="http://localhost/Concept/form.pdf">
                    <p:field name="person.name" value="Me, myself and I"/>
                </p:form>
            
        

Seam now provides experimental support for rendering Swing components to into a PDF image. Some Swing look and feels supports, notably ones that use native widgets, will not render correctly.

Document generation works out of the box with no additional configuration needed. However, there are a few points of configuration that are needed for more serious applications.

The default implementation serves PDF documents from a generic URL, /seam-doc.seam. Many browsers (and users) would prefer to see URLs that contain the actual PDF name like /myDocument.pdf. This capability requires some configuration. To serve PDF files, all *.pdf resources should be mapped to the DocumentStoreServlet:


<servlet>
    <servlet-name>Document Store Servlet</servlet-name>
    <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>Document Store Servlet</servlet-name>
    <url-pattern>*.pdf</url-pattern>
</servlet-mapping>

The use-extensions option on the document store component completes the functionality by instructing the document store to generate URLs with the correct filename extension for the document type being generated.


<components xmlns="http://jboss.com/products/seam/components"
    xmlns:document="http://jboss.com/products/seam/document"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://jboss.com/products/seam/document http://jboss.com/products/seam/document-2.2.xsd
        http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd">
    <document:document-store use-extensions="true"/>
</components>

The document store stores documents in conversation scope, and documents will expire when the conversation ends. At that point, references to the document will be invalid. You can specify a default view to be shown when a document does not exist using the error-page property of the documentStore.


<document:document-store use-extensions="true" error-page="/documentMissing.seam" />

For further information on iText, see: