Everything I have found about CFPDF says that the way to add page numbers to a PDF is like this
<cfpdf action="addFooter" source="#finalFile#" name="mypdf"
text="Page _PAGENUMBER of _LASTPAGENUMBER" />
The problem is every reference I have found is for coldFusion 9 and before and I am wondering if maybe the Lucee guys didn't include this functionality because I get an error that says
Attribute text is not allowed for tag cfpdf
Is this a syntax issue or an oversight by Lucee/Railo not to put this in.
I am merging a group of PDFs using CFPDFs merge feature that this is working correctly but I now need to put page numbers on the PDF and that is were I am hitting a wall.
Here is the a more complete picture of what I am trying to do. The only part that isn't working is the addFooter line
<cfpdf action = "merge" destination="#finalFile#" overwrite="yes">
<cfloop array="#arrayOfPdfs#" index="k">
<cfpdfparam source="#k#">
</cfloop>
</cfpdf>
<cfpdf action="addFooter" source="#finalFile#" name="mypdf"
text="Page _PAGENUMBER of _LASTPAGENUMBER" />
<cfloop array="#arrayOfPdfs#" index="k">
<cffile action="delete" file="#k#">
</cfloop>
I did a little searching and here is what I found. Remember that Lucee was previously Railo. I found your exact issue reported as a bug in Railo back in August 2011 - cfpdf addfooter not supported It looks like that bug was never addressed.
The Lucee docs mention the ability to add a header/footer using cfpdf in the lead-in paragraph but not in the tags attributes - Lucee documentation for cfpdf
Create PDF portfolios - Add and remove header/footer from PDF documents - Optimize PDF documents
(my emphasis) But there is no mention of addheader or addfooter beyond that.
This just mirrors the original Railo documentation - Railo documentation for cfpdf
I am guessing that this bug was never resolved and now exists (still exists) in Lucee. I would create a new issue for the Lucee group to revisit this - https://luceeserver.atlassian.net/secure/Dashboard.jspa
It is interesting that it seems to accept the addfooter action just not the text attribute. That makes it seem like a bug.
UPDATE 11/18/2021
From Andy's comment below "It looks like a fix is coming from the PULL requests at github.com/lucee/extension-pdf/pulls specifically github.com/lucee/extension-pdf/pull/31" it appears that a fix may finally be coming for this issue. Thanks for the update Andy!
Related
Without warning and with no code change on my end the hosting company applied Update 19 to ColdFusion 11. They claim it's unrelated yet no PDF document can be populated from the DB.
Here's the beginning of the code that worked perfect for years.
<cfpdfform source="#ExpandPath( 'FORMS/PDF_FORM_TEMPATE.pdf' )#" action="populate" destination="#expandPath('TEMP/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#" overwrite=true >
<cfpdfsubform name="i9Main">
<cfpdfformparam name="LAST_NAME" value="#hog_data.LAST_NAME#">
Then I end the code by writing it to the final destinations and output it to the screen for viewing.
<cfpdf action="write" destination="#expandPath('FINAL/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#" source="#expandPath('TEMP/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#" flatten="yes" overwrite="yes">
<cffile action="delete" file="#expandPath('TEMP/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf')#">
<cflocation url="final/I9_#accountinfo.company_id#_#EMPLOYEE_ID#_#hog_data.LAST_NAME#.pdf">
This code has worked great until 6 Mar when the web hosting company applied ColdFusion Update 19. Has anyone has an issue with this or have suggestions?
First off, I want to thank all of you who provided suggestion. Turns out Adrian J. Moreno was correct. This issue was caused by an incompatible version of the Java Run Time Environment. Updating this fixed the issue and populating PDFs is now working again site-wide.
I am migrating a very old app (currently running in CF8) to Lucee. But I am running into a problem with what appears to be a custom tag of some sort.
I have tried to make sure that all the virtual directories are the same in IIS for both the old and the new installs. And made sure the mapping and custom tag paths in both the CFIDE and the Lucee Admin are the same.
But I am getting this error. And can't figure out how this cflink is being instantiated.
I have found the location of the erroring code on line 300 the utils.cfc file
I haven't used custom tags in a long time but thought they were generally called with an underscore and the code should like more like <cf_link pageid="#LinkPageID#" Init="start"> if this was being called as a custom tag.
If I go the the current CF server that is running this app I can find that a cfclass files HAS been created
From a file called cflink.cfm in a directory called "tags" even though there seems to be no mapping for the "tags" directory nor is is listed under "custom tags paths" in the administrator.
This App was start in 2003 and as you can imagine has grown into a mis-match of spaghetti code and no one from the beginning is around to ask how this tag is instantiated.
Does anyone with experience in legacy code has any other ideas where I should be looking to try to get this to work? The currently has only a production environment and if I can get it to work on Lucee it will not only be a dev environment that hasn't existed here in 10 years but will be a great way for me to be able to continue showcasing Lucee as a great CFML engine
Adding addition info
Leigh had asked if the init might be a jar reference but in the cflink.cfm file I see this code:
<cfif Attributes.Init IS "start">
<cfset Request.PageID = Attributes.PageID>
<cfset Request.Page_Width = Variables.qParentInfo.Page_Width>
<cfset Request.Page_Height = Variables.qParentInfo.Page_Height>
<cfset Request.Page_TypeID = Variables.qParentInfo.Page_TypeID>
<cfset Request.AddPath = "">
<cfif IsDefined("Attributes.Anchor")>
<cfset Request.Anchor = Attributes.Anchor>
<cfelse>
<cfset Request.Anchor = "">
</cfif>
<cfset Request.IsInternalLink = false>
<cfexit method="EXITTAG">
</cfif>
There are also references to cflink in the code inside tags\cflink.cfm
<cfif Len(Variables.qParentInfo.ParentID) GT 0>
<!--- Add the page title to the end of the path --->
<cfset Request.AddPath = ReplaceNoCase(Variables.qParentInfo.Nav_Title," ","_","ALL") & "/" & Request.AddPath>
<cflink init="working" pageid="#Variables.qParentInfo.ParentID#" popcode="#Attributes.popcode#">
<cfelse> ......</cfif>
Although this may be recursion given it was written in 2004 I kind of doubt it
Adding screen shots of searches
If anyone else runs into this. In CF8, and presuming earlier versions, you could put a cfm file into the ColdFusion8\wwwroot\WEB-INF\cftags Directory and that file in this case ColdFusion8\wwwroot\WEB-INF\cftags\link.cfm Then acts as any other cftag.
I was able to find the person who originally build this app in 2004 and he told me that they did it this way to avoid typing the underscore that they would have typed if they'd done it as a custom tag.
I kind of get it since this tag is used everywhere in the app, literally hundreds of times. Bit boy with a bitch to find.
Now all I have to do is figure out how to move it to the Lucee world in a similar fashion. So it instanciates the same way.
Thanks #Leigh for all your help, you are always amazing!
Adding more information
if there are files in the WEB-INF\lucee\library\tag the corresponding Lucee directory is WEB-INF\lucee\library\tag. These files are read on load and then able to be used as any other cf tag.
For example if you have file WEB-INF\lucee\library\tag\link.cfm it can be called by `cflink'.
Seems like a cool idea but a bit of a bitch for someone to find 10 years after the fact
It seems that when I use the <cfsavecontent> tag, the output of that is being served by the server (without the variable being outputted), which, to me, kind of defeats the purpose of <cfsavecontent>.
If this is important: my application uses ColdSpring, ModelGlue and Transfer ORM.
Here's my example code in a function:
<cfsavecontent variable="testvar">
<cfinclude template="test.cfm" />
</cfsavecontent>
<cfreturn testvar>
And the template:
<cfdocument format="PDF" pagetype="A4" orientation="portrait" unit="cm">
<cfoutput>
<!--- PDF content here --->
</cfoutput>
</cfdocument>
The PDF content is being parsed by my browser (Google Chrome), while the view hasn't even been loaded in. How can I best prevent this from happening?
Just to clarify: I am not outputting the #testvar# variable yet in this code, though it seems it loads the template in the browser anyways.
To achieve what you're trying to do, should you not simply be using the name attribute of <cfdocument> to put the PDF data into a variable, instead of trying to <cfsavecontent> it?
Disclosure: I've never used <cfdocument> for anything other than proof-of-concept code and testing, but that's what I'm inferring from the docs.
As I also needed to make multiple PDF documents merge, I ended up doing the following. Many thanks to Adam Cameron for providing the solution to my initial issue.
In the template file, I use the <cfdocument> tag with the name attribute to save the PDF in a variable (thanks to Adam Cameron for this)
Then, I store all the PDF documents in an array in their binary format
In my view, I merge the PDF documents together by using <cfpdf>'s merge action, and using a cfloop, to loop over the array, inside it.
Finally, I display the content by using <cfcontent> and using the variable attribute with toBinary(myPdf)
This got me to where I am.
cfinclude will process the test.cfm page, and the way you configured cfdocument will cause "opening" of pdf document in your browser.
You can prevent openning of this file by saving file on the disc:
<cfdocument format="PDF" pagetype="A4" orientation="portrait" unit="cm" filename ="test.pdf" overwrite ="yes">
But this will not prevent execution of cfinclude in the cfcontent tag, it will just prevent opening in the browser.
You can observe cfinclude as request to the server, it will always be executed.
The solution would be to invoke request on test.cfm file which contains cfdocument in the moment that you actually want to generate pdf.
Example: Use javascript on client to invoke report service which will generate and pop out the screen with pdf report.
Hope this helps.
I'm looking for a complete list of tags that are not available in ColdFusion 9 script syntax.
Example:
CFSetting: is one example that is available in Railo but not in CF9 for use in cfscript
CFDocument: I can't find this one so far.
Not an official list by any measure, but this is a list I presented to a private forum a while back, and it didn't receive too much correction (and those corrections have been integrated). It was in the context of what CF does and doesn't need to be implemented, to claim 100% coverage in CFScript.
Summary of omissions:
These ones are significant omissions:
<cfcollection>
<cfexchangecalendar>
<cfexchangeconnection>
<cfexchangecontact>
<cfexchangefilter>
<cfexchangemail>
<cfexchangetask>
<cfexecute>
<cfindex>
<cfinvoke> (support for dynamic method names)
<cflogin>
<cfloginuser>
<cflogout>
<cfmodule>
<cfoutput> (implementation of query looping with grouping)
<cfparam> (fix the bug in that enforced requiredness doesn’t work (ie: param name="foo";))
<cfsearch>
<cfsetting>
<cfwddx>
<cfzip>
<cfzipparam>
There’s a reasonable case for these ones to be implemented:
<cfassociate>
<cfcache>
<cfcontent>
<cfflush>
<cfhtmlhead>
<cfheader>
<cfntauthenticate>
<cfprint>
<cfschedule>
<cfsharepoint>
These ones... I’m ambivalent:
<cfgridupdate>
<cfinsert>
<cfobjectcache>
<cfregistry>
<cfreport>
<cfreportparam>
<cftimer>
<cfupdate>
We don’t need these ones at all, I think:
<cfajaximport>
<cfajaxproxy>
<cfapplet>
<cfcalendar>
<cfchart>
<cfchartdata>
<cfchartseries>
<cfcol>
<cfdiv>
<cfdocument>
<cfdocumentitem>
<cfdocumentsection>
<cffileupload>
<cfform>
<cfformgroup>
<cfformitem>
<cfgraph>
<cfgraphdata>
<cfgrid>
<cfgridcolumn>
<cfgridrow>
<cfinput>
<cflayout>
<cflayoutarea>
<cfmap>
<cfmapitem>
<cfmediaplayer>
<cfmenu>
<cfmenuitem>
<cfpod>
<cfpresentation>
<cfpresentationslide>
<cfpresenter>
<cfselect>
<cfsilent>
<cfslider>
<cfsprydataset>
<cftable>
<cftextarea>
<cftextinput>
<cftooltip>
<cftree>
<cftreeitem>
<cfwindow>
If there's anything here that you think ought to be included in CFScript, please raise an issue here - http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html - and cross reference the issue number here.
HTH.
I would argue that there are no commands that are not available as script as you can extend and write the missing bits using cfc's.
Thus wrap your favourite missing <cftag in a cfc and call it using new
However, here is a list of what is supported
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSe9cbe5cf462523a02805926a1237efcbfd5-7ffe.html
Does anyone else get this problem or know a solution / workaround I could try as I'm running out of ideas? :-(
I'm running this code on ColdFusion 9 - the idea is that it creates a PDF page (a front cover to a report) applies a watermark (a design I've been given with an orange background that I put my content on) and saves it for use later down the page.
The problem I've got is firstly I needed to turn backgroundvisible on in the cfdocument tag. Reason for this is I kept getting this white square showing on top of my produced page. When I do this though cfdocument then ignore any font colour changes I make it.
I've tried all kinds of combinations of trying to get this including styles, classes. internal / external CSS files but everytime ColdFusion defaults it to black.
Does anyone have any suggestions on what I can do to get this showing in white?
<cfdocument format="pdf" marginbottom="0" marginleft="0.77" marginright="0" margintop="5" pageType="A4" unit="in" name="cover" backgroundvisible="false">
<cfoutput>
<html>
<head>
</head>
<body style="color:##fff">
here
</body>
</html>
</cfoutput>
</cfdocument>
<cfpdf action="addWatermark" copyFrom="#coverFile#" source="cover" foreground="false" opacity="10" showonprint="true" />
<cfpdf action="write" destination='#PDFDir##frontCoverFile#' source="cover" overwrite="true" />
Thanks very much,
James
P.S. It maybe that a workaround has to be using CFIMAGE to produce this and then placing that in the page instead. I'd rather not though :-(
Try using straight HTML styles . Tried it and it seemed to do the job.
Ello world
Unfortunately in the case of this question I had to strip the PDF right back to basics.
I had more problems than just this but generally when it comes to PDF features in ColdFusion Adobe will certainly have to pull their fingers out as it's really buggy :-(
Don't know anything about CF mate, but you have two hashtags before the hex colour, so it probably won't be read!