Author: norman.richards(a)jboss.com
Date: 2008-01-28 18:40:13 -0500 (Mon, 28 Jan 2008)
New Revision: 7274
Added:
trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java
trunk/examples/itext/view/html.xhtml
trunk/examples/itext/view/swing.xhtml
Modified:
trunk/doc/reference/en/modules/itext.xml
trunk/examples/itext/resources/WEB-INF/components.xml
trunk/examples/itext/view/index.xhtml
trunk/src/main/org/jboss/seam/core/SeamResourceBundle.java
trunk/src/pdf/org/jboss/seam/pdf/DocumentData.java
Log:
merge 2.0 branch changes
Modified: trunk/doc/reference/en/modules/itext.xml
===================================================================
--- trunk/doc/reference/en/modules/itext.xml 2008-01-28 23:21:19 UTC (rev 7273)
+++ trunk/doc/reference/en/modules/itext.xml 2008-01-28 23:40:13 UTC (rev 7274)
@@ -1,6 +1,6 @@
<chapter id="itext">
<title>iText PDF generation</title>
- <para>Seam now includes an component set for generating documents using iText.
The primary focus of Seam's iText
+ <para>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 doucuments, but Seam also offers
basic support for RTF document
generation.</para>
@@ -38,7 +38,7 @@
<para>
<emphasis>Description</emphasis>
</para>
- <para> Documents are generated by facelets
documents using tags in the
+ <para> Documents are generated by facelet XHTML
files using tags in the
<
literal>http://jboss.com/products/seam/pdf</literal> namespace. Documents
should always have the
<literal>document</literal> tag at the root of the document.
The <literal>document</literal> tag
prepares Seam to generate a document into the
@@ -87,6 +87,15 @@
<literal>marginMirroring</literal> — Indicates that margin
settings should be reversed an alternating
pages.</para>
</listitem>
+
+ <listitem>
+ <para>
+ <literal>disposition</literal>
— When generating PDFs in a web browser, this determines the HTTP
+
<literal>Content-Disposition</literal> of the document. Valid values are
<literal>inline</literal>, which
+ indicates the document should be displayed in
the browser window if possible,
+ and
<literal>attachment</literal>, which indicates that the document should be
treated as a download.
+ The default value is
<literal>inline</literal>.</para>
+ </listitem>
</itemizedlist>
@@ -288,7 +297,64 @@
</informaltable>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*"/>
+ <colspec colnum="2" colwidth="3*"/>
+ <tbody>
+ <row>
+ <entry valign="top">
+ <para>
+
<literal><p:html></literal>
+ </para>
+ </entry>
+ <entry valign="top">
+ <para>
+ <emphasis>Description</emphasis>
+ </para>
+
+ <para> The <literal>html</literal> tag
renders HTML content into the PDF.
+ </para>
+
+ <para>
+ <emphasis>Attributes</emphasis>
+ </para>
+
+
+ <itemizedlist>
+ <listitem>
+ <para><literal>value</literal>
— The text to be displayed.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ <emphasis>Usage</emphasis>
+ </para>
+
+ <programlisting>
+<p:html value="This is HTML with &lt;b&gt;some
markup&lt;/b&gt;." />
+<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>
+</programlisting>
+
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
<informaltable>
<tgroup cols="2">
<colspec colnum="1" colwidth="1*"/>
@@ -341,7 +407,7 @@
<emphasis>Usage</emphasis>
</para>
- <programlisting><p:font
family="courier" style="bold"
size="24">
+ <programlisting><p:font
name="courier" style="bold"
size="24">
<p:paragraph>My Title</p:paragraph>
</p:font></programlisting>
@@ -1443,11 +1509,11 @@
<section id="itext.charting">
<title>Charting</title>
- <para> Charting support is also provided with
<literal>jboss-seam-pdf.jar</literal>. Charts can be used in
- PDF documents or can be used as images in an HTML page.
- Charting requires the JFreeChart library
(<literal>jfreechart.jar</literal> and
<literal>jcommon.jar</literal>) to be added to the
- <literal>WEB-INF/lib</literal> directory. Three types of charts
are currently supported: pie charts, bar charts and line charts.
- </para>
+ <para> Charting support is also provided with
<literal>jboss-seam-pdf.jar</literal>. Charts can be used in PDF
+ documents or can be used as images in an HTML page. Charting requires the
JFreeChart library
+ (<literal>jfreechart.jar</literal> and
<literal>jcommon.jar</literal>) to be added to the
+ <literal>WEB-INF/lib</literal> directory. Three types of
charts are currently supported: pie charts, bar
+ charts and line charts. </para>
<informaltable id="itext.barchart">
<tgroup cols="2">
@@ -1895,8 +1961,7 @@
<listitem>
<para>
- <literal>title</literal>—
The chart title text.
- </para>
+ <literal>title</literal>—
The chart title text. </para>
</listitem>
<listitem>
<para>
@@ -1905,13 +1970,13 @@
</listitem>
<listitem>
<para>
- <literal>legend</literal>—
A boolean value indicating whether or not the chart should include a legend. Default value
is true
- </para>
+ <literal>legend</literal>—
A boolean value indicating whether or not
+ the chart should include a legend. Default value
is true </para>
</listitem>
<listitem>
<para>
- <literal>is3D</literal>—A
boolean value indicating that the chart should be rendered in 3D instead of 2D.
- </para>
+ <literal>is3D</literal>—A
boolean value indicating that the chart
+ should be rendered in 3D instead of 2D.
</para>
</listitem>
<listitem>
<para>
@@ -1920,98 +1985,97 @@
</listitem>
<listitem>
<para>
-
<literal>labelLinkPaint</literal>— The paint used for the label
linking lines.
- </para>
+
<literal>labelLinkPaint</literal>— The paint used for the label
+ linking lines. </para>
</listitem>
<listitem>
<para>
-
<literal>labelLinkStroke</literal>— he stroke used for the label
linking lines.
- </para>
+
<literal>labelLinkStroke</literal>— he stroke used for the label
+ linking lines. </para>
</listitem>
<listitem>
<para>
-
<literal>labelLinksVisible</literal>— A flag that controls whether
or not the label links are drawn.
- </para>
+
<literal>labelLinksVisible</literal>— A flag that controls whether
or
+ not the label links are drawn. </para>
</listitem>
<listitem>
<para>
-
<literal>labelOutlinePaint</literal>— The paint used to draw the
outline of the section labels.
- </para>
+
<literal>labelOutlinePaint</literal>— The paint used to draw the
+ outline of the section labels. </para>
</listitem>
<listitem>
<para>
-
<literal>labelOutlineStroke</literal>— The stroke used to draw the
outline of the section labels.
- </para>
+
<literal>labelOutlineStroke</literal>— The stroke used to draw the
+ outline of the section labels. </para>
</listitem>
<listitem>
<para>
-
<literal>labelShadowPaint</literal>— The paint used to draw the
shadow for the section labels.
- </para>
+
<literal>labelShadowPaint</literal>— The paint used to draw the
shadow
+ for the section labels. </para>
</listitem>
<listitem>
<para>
-
<literal>labelPaint</literal>— The color used to draw the section
labels
- </para>
+
<literal>labelPaint</literal>— The color used to draw the section
+ labels </para>
</listitem>
<listitem>
<para>
-
<literal>labelGap</literal>— The gap between the labels and the plot
as a percentage of the plot width.
- </para>
+
<literal>labelGap</literal>— The gap between the labels and the
plot
+ as a percentage of the plot width. </para>
</listitem>
<listitem>
<para>
-
<literal>labelBackgroundPaint</literal>— The color used to draw the
background of the section labels. If this is null, the background is not filled.
+
<literal>labelBackgroundPaint</literal>— The color used to draw the
+ background of the section labels. If this is
null, the background is not filled.
</para>
</listitem>
<listitem>
<para>
-
<literal>startAngle</literal>— The starting angle of the first
section.
- </para>
+
<literal>startAngle</literal>— The starting angle of the first
+ section. </para>
</listitem>
<listitem>
<para>
-
<literal>circular</literal>— 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.
- </para>
+
<literal>circular</literal>— 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. </para>
</listitem>
<listitem>
<para>
-
<literal>direction</literal>—
- The direction the pie section are drawn. One of:
<literal>clockwise</literal> or <literal>anticlockwise</literal>.
- The default is
<literal>clockwise</literal>.
- </para>
+
<literal>direction</literal>— The direction the pie section are
drawn.
+ One of: <literal>clockwise</literal>
or <literal>anticlockwise</literal>. The
+ default is
<literal>clockwise</literal>. </para>
</listitem>
<listitem>
<para>
-
<literal>sectionOutlinePaint</literal>— The outline paint for all
sections.
- </para>
+
<literal>sectionOutlinePaint</literal>— The outline paint for all
+ sections. </para>
</listitem>
<listitem>
<para>
-
<literal>sectionOutlineStroke</literal>— The outline stroke for all
sections
- </para>
+
<literal>sectionOutlineStroke</literal>— The outline stroke for all
+ sections </para>
</listitem>
<listitem>
<para>
-
<literal>sectionOutlinesVisible</literal>— Indicates whether an
outline is drawn for each section in the plot.
- </para>
+
<literal>sectionOutlinesVisible</literal>— Indicates whether an
+ outline is drawn for each section in the plot.
</para>
</listitem>
<listitem>
<para>
-
<literal>baseSectionOutlinePaint</literal>— The base section outline
paint.
- </para>
+
<literal>baseSectionOutlinePaint</literal>— The base section
outline
+ paint. </para>
</listitem>
<listitem>
<para>
-
<literal>baseSectionPaint</literal>— The base section paint.
- </para>
+
<literal>baseSectionPaint</literal>— The base section paint.
</para>
</listitem>
<listitem>
<para>
-
<literal>baseSectionOutlineStroke</literal>— The base section
outline stroke.
- </para>
+
<literal>baseSectionOutlineStroke</literal>— The base section
outline
+ stroke. </para>
</listitem>
</itemizedlist>
<para>
@@ -2167,15 +2231,18 @@
<listitem>
<para>
-
<literal>sectionOutlinePaint</literal> — For bar charts, the color
of the section outline.</para>
+
<literal>sectionOutlinePaint</literal> — For bar charts, the color
of
+ the section outline.</para>
</listitem>
<listitem>
<para>
-
<literal>sectionOutlineStroke</literal> — For bar charts, the stroke
type for the section outline.</para>
+
<literal>sectionOutlineStroke</literal> — For bar charts, the
stroke
+ type for the section outline.</para>
</listitem>
<listitem>
<para>
- <literal>sectionPaint</literal>
— For bar charts, the color of the section.</para>
+ <literal>sectionPaint</literal>
— For bar charts, the color of the
+ section.</para>
</listitem>
</itemizedlist>
<para>
@@ -2333,7 +2400,10 @@
<section id="itext.barcodes">
<title>Bar codes</title>
- <para>...</para>
+ <para>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.
+ </para>
<informaltable id="itext.barcode">
<tgroup cols="2">
@@ -2351,7 +2421,8 @@
<para>
<emphasis>Description</emphasis>
</para>
- <para/>
+ <para>Displays a barcode image.</para>
+
<para>
<emphasis>Attributes</emphasis>
</para>
@@ -2360,15 +2431,13 @@
<listitem>
<para>
- <literal>type</literal> —
A barcode type supported by iText.
- Valid values include:
- <literal>EAN13</literal>,
<literal>EAN8</literal>, <literal>UPCA</literal>,
- <literal>UPCE</literal>,
- <literal>SUPP2</literal>,
<literal>SUPP5</literal>, <literal>POSTNET</literal>,
+ <literal>type</literal> — A
barcode type supported by iText. Valid
+ values include:
<literal>EAN13</literal>, <literal>EAN8</literal>,
+ <literal>UPCA</literal>,
<literal>UPCE</literal>, <literal>SUPP2</literal>,
+ <literal>SUPP5</literal>,
<literal>POSTNET</literal>,
<literal>PLANET</literal>,
<literal>CODE128</literal>,
- <literal>CODE128_UCC</literal>,
<literal>CODE128_RAW</literal> and <literal>CODABAR</literal>.
-
- </para>
+ <literal>CODE128_UCC</literal>,
<literal>CODE128_RAW</literal> and
+ <literal>CODABAR</literal>.
</para>
</listitem>
<listitem>
<para>
@@ -2377,18 +2446,18 @@
</listitem>
<listitem>
<para>
- <literal>xpos</literal>—
For PDFs, the absolute y position of the barcode on the page.
- </para>
+ <literal>xpos</literal>—
For PDFs, the absolute y position of the
+ barcode on the page. </para>
</listitem>
<listitem>
<para>
- <literal>ypos</literal>—
For PDFs, the absolute y position of the barcode on the page.
- </para>
+ <literal>ypos</literal>—
For PDFs, the absolute y position of the
+ barcode on the page. </para>
</listitem>
<listitem>
<para>
- <literal>rotDegrees</literal>
— For PDFs, the rotation factor of the barcode in degrees.
- </para>
+ <literal>rotDegrees</literal>
— For PDFs, the rotation factor of the
+ barcode in degrees. </para>
</listitem>
<listitem>
<para>
@@ -2398,34 +2467,36 @@
<listitem>
<para>
- <literal>minBarWidth</literal>
— The minimum bar width.
- </para>
+ <literal>minBarWidth</literal>
— The minimum bar width. </para>
</listitem>
<listitem>
<para>
- <literal>barMultiplier</literal>
— The bar multiplier for wide bars or the
- distance between bars for
<literal>POSTNET</literal> and <literal>PLANET</literal> code.
-
- </para>
+ <literal>barMultiplier</literal>
— The bar multiplier for wide bars or
+ the distance between bars for
<literal>POSTNET</literal> and
+ <literal>PLANET</literal> code.
</para>
</listitem>
<listitem>
<para>
- <literal>barColor</literal>
— The color to draw the bars.
- </para>
- </listitem>
-
+ <literal>barColor</literal>
— The color to draw the bars. </para>
+ </listitem>
+
<listitem>
<para>
- <literal>textColor</literal>
— The color of any text on the barcode.
+ <literal>textColor</literal>
— The color of any text on the barcode.
</para>
</listitem>
- <listitem>
+ <listitem>
<para>
<literal>textSize</literal>
— The size of the barcode text, if any.
</para>
</listitem>
-
-
+ <listitem>
+ <para>
+ <literal>altText</literal>
— The <literal>alt</literal> text for HTML image links.
+ </para>
+ </listitem>
+
+
</itemizedlist>
<para>
<emphasis>Usage</emphasis>
@@ -2446,7 +2517,66 @@
</section>
+ <section id="itext.swingcomponents">
+ <title>Rendering Swing/AWT components</title>
+ <para>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.
+ </para>
+ <informaltable id="itext.swing">
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*"/>
+ <colspec colnum="2" colwidth="3*"/>
+
+ <tbody>
+ <row>
+ <entry valign="top">
+ <para>
+ <literal><p:swing></literal>
+ </para>
+ </entry>
+ <entry valign="top">
+ <para>
+ <emphasis>Description</emphasis>
+ </para>
+
+ <para>Renders a Swing component into a PDF
document.</para>
+ <para>
+ <emphasis>Attributes</emphasis>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>width</literal> —
The width of the component to be rendered. </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>height</literal> —
..The height of the component to be rendered. </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>component</literal>
— An expression whose value is a Swing or AWT component. </para>
+ </listitem>
+
+ </itemizedlist>
+ <para>
+ <emphasis>Usage</emphasis>
+ </para>
+ <programlisting>
+<p:swing width="310" height="120"
component="#{aButton}" />
+ </programlisting>
+
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+
+
<section id="itext.links">
<title>Further documentation</title>
Modified: trunk/examples/itext/resources/WEB-INF/components.xml
===================================================================
--- trunk/examples/itext/resources/WEB-INF/components.xml 2008-01-28 23:21:19 UTC (rev
7273)
+++ trunk/examples/itext/resources/WEB-INF/components.xml 2008-01-28 23:40:13 UTC (rev
7274)
@@ -17,4 +17,7 @@
<core:init debug="true" jndi-pattern="@jndiPattern@" />
+ <component name="sampleButton"
class="javax.swing.JButton">
+ <property name="label">A JButton!</property>
+ </component>
</components>
Copied: trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java (from rev
7271,
branches/Seam_2_0/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java)
===================================================================
--- trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java
(rev 0)
+++ trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java 2008-01-28
23:40:13 UTC (rev 7274)
@@ -0,0 +1,29 @@
+package org.jboss.seam.example.pdf;
+
+import java.awt.*;
+import javax.swing.*;
+
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Name;
+
+@Name("swing")
+public class SwingComponent
+{
+ @Create
+ public void init() {
+ try {
+ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
+ } catch(Exception e) {
+ System.out.println("Error setting Java LAF: " + e);
+ }
+
+ System.out.println("** " + UIManager.getLookAndFeel());
+ }
+
+ public Component getButton() {
+ JLabel label = new JLabel("Hello, Seam", SwingConstants.CENTER);
+
+ return label;
+ }
+
+}
Copied: trunk/examples/itext/view/html.xhtml (from rev 7271,
branches/Seam_2_0/examples/itext/view/html.xhtml)
===================================================================
--- trunk/examples/itext/view/html.xhtml (rev 0)
+++ trunk/examples/itext/view/html.xhtml 2008-01-28 23:40:13 UTC (rev 7274)
@@ -0,0 +1,29 @@
+<p:document
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:p="http://jboss.com/products/seam/pdf">
+
+ <p:paragraph>This is a regular paragraph.</p:paragraph>
+
+
+ <p:html value="This is HTML that is just plain text." />
+ <p:html value="This is HTML with <b>some
markup</b>." />
+
+ <p:html>
+ This is HTML with text with text in the <b>body</b>.
+ </p:html>
+
+
+ <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:document>
Modified: trunk/examples/itext/view/index.xhtml
===================================================================
--- trunk/examples/itext/view/index.xhtml 2008-01-28 23:21:19 UTC (rev 7273)
+++ trunk/examples/itext/view/index.xhtml 2008-01-28 23:40:13 UTC (rev 7274)
@@ -34,6 +34,8 @@
<li><s:link view="/table.xhtml" value="Tables"
/></li>
<li><s:link view="/nested.xhtml" value="Nested
Tables" /></li>
<li><s:link view="/html.xhtml" value="HTML
Conversion" /></li>
+ <li><s:link view="/swing.xhtml" value="Swing
Component" /></li>
+
<li><s:link view="/chart.xhtml"
value="JFreeChart" />
[<s:link view="/chartimage.xhtml" value="HTML" />]
</li>
@@ -42,9 +44,9 @@
<li><s:link view="/barcode.xhtml" value="Bar Code"
/>
[<s:link view="/barcodeimage.xhtml" value="HTML"
/>]
</li>
+ <li><s:link view="/swing.xhtml" value="Swing
Component" /></li>
-
<ui:remove>
<li><s:link view="/images.xhtml" value="Dynamic
Images" /></li>
</ui:remove>
Copied: trunk/examples/itext/view/swing.xhtml (from rev 7271,
branches/Seam_2_0/examples/itext/view/swing.xhtml)
===================================================================
--- trunk/examples/itext/view/swing.xhtml (rev 0)
+++ trunk/examples/itext/view/swing.xhtml 2008-01-28 23:40:13 UTC (rev 7274)
@@ -0,0 +1,12 @@
+<p:document
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:p="http://jboss.com/products/seam/pdf">
+
+
+ <p:paragraph>A JLabel, from Java: </p:paragraph>
+ <p:swing width="310" height="120"
component="#{swing.button}" />
+
+ <p:paragraph>A JButton, defined in components.xml: </p:paragraph>
+ <p:swing width="310" height="120"
component="#{sampleButton}" />
+
+</p:document>
Modified: trunk/src/main/org/jboss/seam/core/SeamResourceBundle.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/SeamResourceBundle.java 2008-01-28 23:21:19 UTC
(rev 7273)
+++ trunk/src/main/org/jboss/seam/core/SeamResourceBundle.java 2008-01-28 23:40:13 UTC
(rev 7274)
@@ -80,15 +80,16 @@
List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
List<ResourceBundle> bundles = getBundlesForCurrentLocale();
Enumeration<String>[] enumerations = new Enumeration[bundles.size() +
pageBundles.size()];
+
int i = 0;
- for (; i < pageBundles.size(); i++)
- {
- enumerations[i++] = pageBundles.get(i).getKeys();
+ for (java.util.ResourceBundle bundle: pageBundles) {
+ enumerations[i++] = bundle.getKeys();
}
- for (; i < bundles.size(); i++)
- {
- enumerations[i] = bundles.get(i).getKeys();
+
+ for (ResourceBundle bundle: bundles) {
+ enumerations[i++] = bundle.getKeys();
}
+
return new EnumerationEnumeration<String>(enumerations);
}
@@ -150,4 +151,4 @@
return org.jboss.seam.core.Locale.instance();
}
-}
\ No newline at end of file
+}
Modified: trunk/src/pdf/org/jboss/seam/pdf/DocumentData.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/DocumentData.java 2008-01-28 23:21:19 UTC (rev 7273)
+++ trunk/src/pdf/org/jboss/seam/pdf/DocumentData.java 2008-01-28 23:40:13 UTC (rev 7274)
@@ -1,6 +1,10 @@
package org.jboss.seam.pdf;
-public class DocumentData {
+import java.io.Serializable;
+
+public class DocumentData
+ implements Serializable
+{
byte[] data;
DocumentType documentType;
String baseName;