In Seam 1.1.1 a PDF view is just like any other page in the application: a facelets template containing EL expressions that bind values from the underlying Seam components onto the page. So if you already know Seam, producing PDF just involves learning the new iText-specific tags.
Here's a simple Hello example in Seam PDF:
<p:document [=>xmlns:p=]"=>http://jboss.com/products/seam/pdf"
title="Hello">
<p:paragraph>Hello #{user.name}!</p:paragraph>
</p:document>
Just throw this document in your docroot directory of a Seam project, and access the page like you would any other facelets page. What could be easier?
For larger documents, we'll probably want to break our document up into chapters:
<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>
Of course, the real usefulness of this feature is for reporting, so I bet you want to know how to render dynamic lists and tables. Well, here's a list:
<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>
And here's a table:
<p:document [=>xmlns:p=]"=>http://jboss.com/products/seam/pdf"
[=>xmlns:ui=]"=>http://java.sun.com/jsf/facelets"
title="Hello">
<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:document>
Of course, there's much more functionality available: sections, anchors, fonts, etc, but that should be enough to give you the flavor of this new stuff. Check out the examples in Seam 1.1.1 for more information.
I'm trying to use <p:newPage> tag with <ptable> :(
<p:table columns="3"> <!-- this for each row --> <p:newPage /> </p:table>
But it doesn´t works :(.
<!-- Example of my code I need newPage for each row or tableList.resultList --> <p:table columns="3" widthPercentage="100"> <ui:repeat value="#{tableList.resultList}" var="table"> <p:cell> <!-- some code here --> </p:cell> <ui:repeat value="#{tableList.subTables}" var="subTables"> <!-- some code here --> </ui:repeat> <!-- newPage for each table row --> <p:newPage /> </ui:repeat> </p:table>
Hallo,
I have a question: If we have the whole content of the pdf in the database how can we format it?? Let me give an example: Let's say that we have the following:
<p:document [=>xmlns:p=]"=>http://jboss.com/products/seam/pdf" title="Hello"> #{resource.myDocument} </p\\:document>Now if the myDocument content consists of 2 paragraphs how can we format it to be properly split in two paragraphs in the pdf?? One way is to have html content. Is there any other way?
Thank you!
i created seam pdf but i've got wierd result
text must appear sth like this
اميد پورهادي
but it appears this
ا م ي د پ و ر ه ا د ي
words seperate from each other
[CODE]<p:font name="c:\\windows\\fonts\\arial.ttf" encoding="Identity-H" embedded="true" >
اميد پورهادي
</p:font>
[/CODE]
I'm using JBOSS AS 6 and SEAM 2.2.1CR3