I have been messing with iText 5.5.6
and can get pdf form fields and field values,
and populate form fields to create new pdf
If some one can point me to some resources for Lucee 5 I will have a crack
and creating a tag to wrap it up.
Things I would like to know
- best way to handle 3rd party JARs
- where to store them
- loaded them into server scope?
- ensure they JARs are easy to update
- how to create a tag
- how to create a script version of a tag
- inc tag params eg cfpdfformparam
- namespacing tags in Lucee 5 (dropping cf? appending l or lc??)
- if the tag is not going to be compatible with ACF (all be
it incomplete), should I give the tag a different name
- may not be an issue if namespace is lc eg lcpdfform
- creating extensions in Lucee 5
This is just enough to get me moving today, but if anyone can’t wait for
‘official’ tag
com/itext/pdform.cfc
/* References / Thanks to*
VARIABLES.reader = createObject(“java”,“com.itextpdf.text.pdf.PdfReader”,
“lib/itextpdf-5.5.6.jar”);
VARIABLES.stamper = createObject(“java”,“com.itextpdf.text.pdf.PdfStamper”,
“lib/itextpdf-5.5.6.jar”);
public any function init()
{
VARIABLES.reader = createObject(“java”,“com.itextpdf.text.pdf.PdfReader”,
“lib/itextpdf-5.5.6.jar”);
VARIABLES.stamper = createObject(“java”,“com.itextpdf.text.pdf.PdfStamper”,
“lib/itextpdf-5.5.6.jar”);
return THIS;
}
public Struct function getFormFields
(
required string source
)
{
var stFormFields = structNew(“linked”);
var local = {};
local.pdf = VARIABLES.reader.init(ARGUMENTS.source);
local.pdfForm = local.pdf.getAcroFields();
local.stFields = pdfForm.getFields().keySet().iterator();
while (local.stFields.hasNext()) {
var fieldName = stFields.next();
stFormFields[fieldName] = pdfForm.getField(fieldName);
}
local.pdf.close();
return stFormFields
}
public boolean function setFormFields
(
required string source,
required string destination,
required struct stFormFields,
boolean overwrite = true
)
{
var local = {};
local.ok = true;
local.pdf = VARIABLES.reader.init(ARGUMENTS.source);
//local.writePDF = expandpath(“#getTempDirectory()##createUUID()#.pdf”);
local.fileIO =
createObject(“java”,“java.io.FileOutputStream”).init(ARGUMENTS.destination);
local.newPDF = VARIABLES.stamper.init(local.pdf, local.fileIO);
local.pdfFormNew = local.newPDF.getAcroFields();
local.pdfForm = local.pdf.getAcroFields();
local.stFields = pdfForm.getFields().keySet().iterator();
// set field values
// TODO: loop through ARGUMENTS[‘stFormFields’] (for now this ensures all
fields are passed in)
while (local.stFields.hasNext()) {
var fieldName = stFields.next();
local.pdfFormNew.setField(fieldName, ARGUMENTS[‘stFormFields’][fieldName]);
}
local.newPDF.setFormFlattening(true);
local.newPDF.close();
local.pdf.close();
local.fileIO.close();
//local.binaryFile = fileReadBinary(local.writePDF);
//fileDelete(local.writePDF);
return local.ok
}
}
using
pdfFile = “#ExpandPath(‘.’)#\your.pdf”;
pdfForm = new com.itext.pdfform();
stFormFields = pdfForm.getFormFields(pdfFile);
dump(var=stFormFields, label= ‘stFormFields’);
On 25 April 2015 at 00:42, Ryan Hinton <@Ryan_Hinton1> wrote:
I have been attempting to pitch to my new company the idea of switching
from ACF to LCF.
The drawback to what my company needs heavily is cfpdfform.
I did some research in the Railo Google history (
Redirecting to Google Groups) and found a
couple of strings back in 2011/2012 that cfpdfform is in the plan for Railo
4. However, I don’t see it in Railo or Lucee and of course the
documentation shows that it is unsupported. Therefore, will this be able
to be a part of the collection of tag and script functions available to us
in Lucee in the near future or is it no longer in the scope of functions to
add to Lucee?
This will help us determine which direction we will take in choosing
either ACF or LCF.
Thank you for your time,
Ryan Hinton
–
You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/9d5ed586-acd1-4cb9-974d-865a90d968fa%40googlegroups.com
https://groups.google.com/d/msgid/lucee/9d5ed586-acd1-4cb9-974d-865a90d968fa%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.
–
AJ Mercer
<webonix:net strength=“Industrial” /> http://webonix.net | <webonix:org
community=“Open” /> http://webonix.org
http://twitter.com/webonix