MitrahSoft / lucee-cfpdfform

cfpdfform tag for Lucee Server. Read and Populate PDF Form Fields - By http://www.MitrahSoft.com
14 stars 6 forks source link

\<cfpdfform /> for Lucee

\<cfpdfform /> tag for Lucee Server. Read and Populate PDF Form Fields

WIP

PDF Box

This tag created using PDF Box

Installation

Sample usage

<cftry>

    <cfset pdfForm = ExpandPath('./my-pdf-form.pdf')>
    <cfoutput><p>#pdfForm#</p></cfoutput>

    <h4>Read</h4>
    <cfpdfform action="read" source="#pdfForm#" result="stFormFields">
    <cfdump var="#stFormFields#" label="stFormFields">

    <hr>
    <h4>Read the form field value in XML format</h4>
    <cfpdfform action="read" source="#pdfForm#" xmlData="myXMLData" result="stFormFields">
    <cfdump var="#myXMLData#" label="XMLData">

    <hr>
    <h4>Read the form field value and exported in FDF fileformat</h4>
    <cfpdfform action="read" source="#pdfForm#" fdfData="populated-pdf-form.fdf">
    <cfdump var="#myXMLData#" label="XMLData">

    <hr>
    <h4>Populate</h4>
    <cfpdfform action="populate" source="#pdfForm#" destination="#ExpandPath('./populated-pdf-form.pdf')#" >
        <cfpdfformparam name="Name"    value="CF Mitrah">
        <cfpdfformparam name="Account" value="MitrahSoft">
    </cfpdfform>

    <hr>
    <h4>Populate and remove form fields</h4>
    <cfpdfform action="populate" source="#pdfForm#" destination="#ExpandPath('./populated-pdf-form.pdf')#" flatten="true">
        <cfpdfformparam name="Name"    value="CF Mitrah">
        <cfpdfformparam name="Account" value="MitrahSoft">
    </cfpdfform>

    <hr>
    <h4>Populate & write to browser</h4>
    <cfpdfform action="populate" source="#pdfForm#">
        <cfpdfformparam name="Name"    value="CF Mitrah">
        <cfpdfformparam name="Account" value="MitrahSoft">
    </cfpdfform>

    <hr>
    <h4>Populate the form field value from XMLData string or XML file </h4>
    <cfpdfform action="populate" source="#pdfForm#" XMLData="#ExpandPath('./Example.xml')#" destination="#ExpandPath('./populated-pdf-form.pdf')#" overwrite="true">
    </cfpdfform>

    <hr>
    <h4>Populate the form field value from FDF file </h4>
    <cfpdfform action="populate" source="#pdfForm#" fdfData="populated-pdf-form.fdf" destination="#ExpandPath('./populated-pdf-form.pdf')#" overwrite="true">
    </cfpdfform>

    <hr>
    <h4>Unicode Support using embedded font</h4>
    <cfpdfform action="populate" source="#pdfForm#" font="#expandpath('./font.ttf')#" fontsize="10">
        <cfpdfformparam name="Name"    value="CF Mitrāh">
        <cfpdfformparam name="Account" value="MitrāhSoft">
    </cfpdfform>

    <cfcatch>
        <cfdump var="#cfcatch#">
    </cfcatch>
</cftry>

Contributors

Idea & base code adapted from https://github.com/webonix/lucee-cfpdfform lucee-cfpdfform is authored by CF Mitrah and everyone is welcome to contribute.

Downsides webonix cfpdfform implementation

Webonix done a very good job, but he used iText jars, which is licensed as AGPL software. Buying a license is mandatory as soon as you develop commercial activities distributing the iText software inside your product or deploying it on a network without disclosing the source code of your own applications under the AGPL license. These activities include:

Pricing of iText on Dec-2015, Reference

Server - $2,640 USD

End-user - $1,590 USD

Problems

If you experience any problems with this tag please:

Social Media

You'll find us on Twitter, Facebook and Google+.