cancel
Showing results for 
Search instead for 
Did you mean: 

How to create pdf using web form?

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I am using Alfresco 3.3 WCM . I created a sample project & able to create content in .html & .xml formats. Now I want to create a pdf of content created using above mentioned web form & store it along with .html or .xml content in user sandbox. How can i do it?

Any help will be highly appreciated.
1 REPLY 1

sujaypillai
Confirmed Champ
Confirmed Champ
Hello Lalit,

To create pdf's out of webform you need to work with XSL-FO. I just created a simple webform with two fields in it and the required xsl which is as below:
XSD
===
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:alf="http://www.alfresco.org" >
<xs:element name="article">
    <xs:complexType>
      <xs:sequence>
      <xs:element name="title" type="xs:normalizedString"/>
      <xs:element name="description" type="xs:string">
         <xs:annotation>
            <xs:appinfo>
               <alf:appearance>minimal</alf:appearance>
            </xs:appinfo>
         </xs:annotation>
      </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSL
===
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                        xmlns:fo="http://www.w3.org/1999/XSL/Format">
   <xsl:template match="/">
      <fo:root>
         <fo:layout-master-set>
            <fo:simple-page-master master-name="A4">
               <fo:region-body />
            </fo:simple-page-master>
         </fo:layout-master-set>
         <foSmiley Tongueage-sequence master-reference="A4">
            <fo:flow flow-name="xsl-region-body">
               <fo:block><xsl:value-of select="article/title"/></fo:block>
               <fo:block><xsl:value-of select="article/description"/></fo:block>
            </fo:flow>
         </foSmiley Tongueage-sequence>
      </fo:root>
   </xsl:template>
</xsl:stylesheet>

Once you configure the above webform with the xsl attached to it and consume it in a webproject you should get the required result.

Note that when attaching the xsl[Step Two - Configure Templates] you should have the following options selected:
Rendition mimetype:    application/pdf
Output path pattern:    ${name}.${extension}

For more details on XSL-FO visit http://www.w3schools.com/xslfo/default.asp.

Hope so that helps you.

Thanks,