CFDOCUMENT is not putting page number on first page - coldfusion

I have a page that is pulling data from a table, looping through it, and creating PDF pages with the content. I've declared a footer for displaying the page number, which works on every page but the very first. Any ideas what could be going on? I'm on CF2018, version: 2018,0,10,320417
In the code below, "plusVal" is either 0 or 1 depending on whether the generated report will have a cover page I create later and merge with the PDF.
<cfdocument format="pdf" filename="#tempFilepath#\#fileName#_temp.pdf" overwrite="true" bookmark="true" localurl="false"><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Report</title>
</head>
<body>
<cfoutput query="data">
<cfif len(template.header_logo) AND fileExists("#application.linkMediaRoot#\reports\logo\#template.header_logo#")>
<cfdocumentitem type="header"><img src="#application.mediaLink#/reports/logo/#template.header_logo#" /></cfdocumentitem>
</cfif>
<cfdocumentsection name="#data.page_title#">
<br><br>
<div style="font-family: Arial, Helvetica, sans-serif; !important;">
<h1 style="font-size:16pt;">#data.page_title#</h1>
<p>#page_content#</p>
<cfif len(data.additional_content)>
<p>#data.additional_content#</p>
</cfif>
</div>
</cfdocumentsection>
<cfdocumentitem type="footer" evalAtPrint="true">
<span style="font-family: Arial, Helvetica, sans-serif; font-size:10pt; !important">Page #cfdocument.currentpagenumber+plusVal# of #cfdocument.totalpagecount+plusVal#</span>
</cfdocumentitem>
</cfoutput>
</body>
</html>
</cfdocument>

Related

printing pdf files with <cfprint>

I am running ColdFusion 2018 on Windows 2016 (IIS) and having a problem printing a PDF file that I created using <cfdocument>. The printer is visible in CFAdmin and I can <cfdump> it. Here is what I've done:
<html>
<head>
<title>Printing PDF</title>
</head>
<body>
<cfdocument format="PDF" name="3099274.pdf">
<cfoutput>
.... HTML is here ...
</cfoutput>
</cfdocument>
<cfprint type="pdf" source="3099274.pdf" printer="HP LaserJet 4345 CS">
</body>
</html>
What am I doing wrong?

ColdFusion: Bad Request error

I almost never work with ColdFusion anymore. That said, I have one site that was just moved to another server and CF was updated to whatever its most stable version is. I think it was 8 when I programmed this. At any rate, when my form is submitted the following code is generating a "bad request" error (that's all it says in the browser window). I don't have access to the CF Administrator - basically, just FTP. Any ideas why the following code would generate a bad request error?
<cfparam name="form.AutoArtID" default="1">
<cfparam name="form.FWPriorityID" default="1">
<cfparam name="form.totalFields" default="0">
<CFLOOP FROM="1" TO="#form.totalFields#" INDEX="Counter">
<cfset variables.FWPriorityID=F ORM[ "FWPriorityID_"& counter]>
<cfset variables.AutoArtID=F ORM[ "AutoArtID_"& counter]>
<CFQUERY NAME="Updateexbuildernew" DATASOURCE="Ikonltd">
UPDATE artworknew SET FWPriorityID =
<cfqueryparam value="#variables.FWPriorityID#" cfsqltype="cf_sql_integer" null="#not IsNumeric(variables.FWPriorityID)#">
WHERE AutoArtID=
<cfqueryparam value="#variables.AutoArtID#" cfsqltype="cf_sql_integer">
</CFQUERY>
</CFLOOP>
<html>
<head>
<title>IKONLTD DATABASE ADMIN TOOL </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/admin.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript" src="http://ikonltd.com/admin/js/drop_down_menu.js"></script>
<script language="JavaScript" src="mm_menu.js"></script>
<script language="JavaScript" type="text/javascript" src="http://ikonltd.com/admin/js/drop_down_menu.js"></script>
<script language="JavaScript" src="mm_menu.js"></script>
</head>
<body>
<script language="JavaScript1.2">
mmLoadMenus();
</script>
<cfinclude template="../includes/topnav.cfm">
<p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" valign="top">
<h3 align="center">update artist artwork priority</h3>
</td>
</tr>
<tr>
<td width="32%" valign="top"> </td>
<td width="68%" valign="top"> </td>
</tr>
<tr>
<td colspan="2" valign="top">
<p>PriorityIDs for <strong>Featured Works</strong> have been updated. <br>
<br>
Click here to further edit Featured Works Priority IDs.</p>
<hr>
</td>
</tr>
</table>
</body>
</html>
Solution came from server admin who has access to cf admin:
Had to increase the POST parameters in ColdFusion admin. 
I was getting issue because I was uploading a 30MB csv file and then was able to fix the issue by adjusting the 'Maximum size of post data'.
In the Coldfusion Admin page on your webserver, under "Server Settings -> Settings", increase the "Maximum number of POST request parameters" setting. I know this because I had this same issue and this post pointed me in the right direction.

Railo PDF generation issues

I am relatively new on Railo. Trying to set up an application on “Railo” I had encountered a problem with PDF generation. Notice I run the app on Adobe CFML Server with no problem.
The problem: Somewhere in my app I have a button that fetches data from a database and serves a downloadable PDF file. On Railo server the PDF content is returned with “funny characters”. The output language is Greek. Greek language has many accented characters. And that’s where the problem occurs (accented characters returned in a “funny” format e.g. Ÿ for ή or Š for O or OΕ’ for Ά). I think the problem is related to Railo’s fonts collection. The same manifests on openBD server!
I have already tried adding cfprocessingdirective pageEncoding="utf-8" in the cfm file with no results. I have tried to add fonts in the fonts.jar (this is under \WEB-INF\lib folder) with no results also (and the call the fonts in the PDF css).
I don’t want to use Adobe CFML Server anymore.
Is there any solution on this issue?
Many thanks in advance,
Tom
Greece
The cfc just serves data from the database
The code I am using:
<cfprocessingdirective pageEncoding="utf-8">
<cfif not IsDefined("URL.id")>
<cfelseif not IsDefined("URL.model")>
<cfelseif not IsDefined("URL.title")>
<cfelseif not IsDefined("URL.id_tree")>
</cfif>
<cfheader name="Content-Disposition" value="attachment; filename=#URL.id_tree#.pdf">
<cfcontent type="application/unknown; charset=utf-8">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!---<link rel="stylesheet" type="text/css" href="resources/fonts/MinionProRegular/MinionProRegular.css" charset="utf-8" />--->
<title>Print</title>
</head>
<body>
<!---<cfif not IsDefined("URL.id")>
<cfelseif not IsDefined("URL.model")>
</cfif>--->
<!--- Get print details --->
<cfinvoke
component="Print"
method="myPrint"
returnvariable="getContent"
id="#URL.id#"
model="#URL.model#">
<!---<cfdump var="#getMember#">--->
<!--- Output the PDF --->
<cfdocument
format="pdf"
pagetype="a4"
<!---pageheight="5"
pagewidth="6.5"--->
margintop="0.6"
marginbottom="0.8"
marginright="1.3"
marginleft="1"
scale="90"
unit="in"
fontembed="true"
backgroundvisible="true">
<cfoutput query="getContent" >
<style type="text/css">
.logo {
background-image:url(../../images/app-specific/ithemis_logo_NEW.png);
background-repeat: no-repeat;
display: inline-block;
float: left;
clear: right;
}
.name {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 12px;
color: ##5a5a5a;
<!---float: left;
clear: right;--->
<!---margin-top: 5px;--->
}
.body {
font-family: "Times New Roman", Times, serif;
<!---font-family: Bodoni;--->
<!---font-family: Didot;--->
<!---font-family: Greek;--->
<!---font-family: Geosanslight;--->
<!---font-family: Minionpro_regular;--->
<!---font-family: Philosopher;--->
<!---font-family: Russian;--->
font-size: 11px;
color: ##323232;
line-height: 17px;
<!---float: left;
clear: right;--->
}
.line {
font-size:1px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: ##202020;
padding-bottom: 5px;
}
.point {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 11px;
padding: 5px 5px 5px 5px;
color: ##373737;
background-color: ##eeeeee;
/*width: 100% !important;*/
display: block !important;
text-align: justify;
}
</style>
<!---<cfprocessingdirective pageencoding="utf-8">--->
<cfdocumentitem type="header">
<img src="../../images/app-specific/ithemis_logo_print_pdf.png" alt="iThemis logo" width="80" height="30" style="float:left;" border="0"/>
</cfdocumentitem>
<!---Use a footer with current page of totalpages format. --->
<cfdocumentitem type="footer">
<cfoutput><span style="font-family:Georgia, 'Times New Roman', Times, serif;font-size:10px;color: ##5a5a5a;float:right;">Σελίδα #cfdocument.currentpagenumber# από #cfdocument.totalpagecount#</span></cfoutput>
</cfdocumentitem>
<table border="0">
<tr>
<td><span class="name">#Title#</span></td>
</tr>
<tr>
<td><span class="body">#Body#</span></td>
</tr>
</table>
</cfoutput>
</cfdocument>
</body>
</html>
Railo is different in some ways.
It is very important that the CFC / CFM file that is generating the PDF is ALSO saved in unicode format.
I recommend going to File > New in your editor and ensure that the editor allows you to define the BOM and encoding prior to creation of the file.
Then copy / paste the code into the new file and overwrite the file with it.
If you do this, it should work.
It sounds weird... but give it a shot.
It's fixed my UTF-8 apps on Railo many of times.
Dreamweaver, although I no longer use it - allowed for these settings to be defined upon file creation. You can also set them in preferences for all future documents.
On SublimeText 2, you can save a file with encoding and BOM.
In ColdFusion Builder, not sure exactly where BOM settings are located but here is a preferences pain for ensuring Default encoding is set to UTF-8.
I hope this helps you and anyone else having similar issues.
REMEMBER: If you're working with UTF-8 / Railo, you have to ensure EVERY ASPECT of the interactions are also saved with UTF-8 in mind. Including the cfc/cfm files themselves.
Good luck!
Make sure you ALSO add the <cfprocessingdirective pageencoding="utf-8"> immediately after the <cfcomponent> in your CFC.

Richfaces template header

I'm using RichFaces 4.1 and I found out for my template as shown below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title><ui:define name="title">Application Title</ui:define></title>
<meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />
</h:head>
<h:body>
<ui:insert name="body">Default content</ui:insert>
</h:body>
</html>
It always add extra head info for me:
<link type="text/css" rel="stylesheet" href="/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.Final/PackedCompressed/DEFAULT/skinning.css" /><script type="text/javascript" src="/javax.faces.resource/jsf.js.jsf?ln=javax.faces"></script><script type="text/javascript" src="/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.Final/PackedCompressed/packed/packed.js"></script>
If I take out this portion from template, those extra info will be disappear:
<h:head>
<title><ui:define name="title">Application Title</ui:define></title>
<meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />
</h:head>
With that extra info, the page renders better however if this page navigate to next page base on value return from form action (as defined in faces-config.xml), the component (e.g. a4j:commandButton ) will not work, need click twice to function.
Is that a bug? If you go to richfaces showcase and open the source, the meta info for head are diff. Any ideal why I get those extra meta info that seem buggy...
---- Some extra info ---
Hi Brendan
Thanks for the suggestion but not help...
[Template]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j">
<f:view contentType="text/html">
<h:head>
<ui:insert name="head"></ui:insert>
<!-- Mimic Internet Explorer 8 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />
<title><ui:insert name="title">CEA</ui:insert></title>
</h:head>
<h:body>
<div id="page">
<div id="header">
<div class="right-controls">
<ul class="top-links layout">
<li>Project Site
</li>
</ul>
</div>
</div>
<div id="page-content">
<ui:include src="/templates/includes/navigation.xhtml" />
<ui:insert name="body">
Body content missed
</ui:insert>
<div class="clear"></div>
</div>
<div id="footer">
<ui:insert name="footer"></ui:insert>
</div>
</div>
</h:body>
</f:view>
</html>
[p.xhtml]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="/templates/template.xhtml">
<h:outputStylesheet>
.red {
color: red;
}
.green {
color: green;
}
</h:outputStylesheet>
<ui:define name="body">
<h:form>
<a4j:commandButton value="Store changes"
action="#{profileCreation.goNext}" />
</h:form>
</ui:define>
</ui:composition>
profileCreation.goNext only do one thing, return the success value:
public String goNext() {
return IdmConst.IDM_CREATE_PROFILES_SUCCESS;
}
[faces-config.xml]
<navigation-rule>
<display-name>p.jsf</display-name>
<from-view-id>/public/idm/p.xhtml</from-view-id>
<navigation-case>
<from-outcome>IDM_CREATE_PROFILES_SUCCESS</from-outcome>
<to-view-id>/jsf/idm/resetpwd.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
[resetpwd.xhtm]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<ui:composition template="/templates/template.xhtml">
<ui:define name="head">
<style type="text/css">
.leftColumn {
width: 40%;
vertical-align: top;
text-align: left;
padding: 15px;
background: #00FFFF;
}
.rightColumn {
width: 60%;
vertical-align: top;
text-align: left;
padding: 15px;
}
.red {
color: red;
}
.green {
color: green;
}
</style>
</ui:define>
<ui:define name="title">Change / Rest Password</ui:define>
<ui:define name="body">
<h:form id="resetPwdForm">
<rich:graphValidator value="#{passwordValidationBean}" id="gv">
<rich:panel header="Change password" style="width:500px">
<rich:messages for="gv"/>
<rich:messages globalOnly="true"/>
<h:panelGrid columns="3">
<h:outputText value="Enter new password:" />
<h:inputSecret value="#{passwordValidationBean.password}" id="pass" />
<rich:message for="pass" />
<h:outputText value="Confirm the new password:" />
<h:inputSecret value="#{passwordValidationBean.confirm}" id="conf" />
<rich:message for="conf" />
</h:panelGrid>
<a4j:commandButton value="Store changes"
action="#{passwordValidationBean.storeNewPassword}" />
</rich:panel>
</rich:graphValidator>
</h:form>
</ui:define>
</ui:composition>
</html>
[passwordValidationBean]
I use the sample from richfaces showcase (http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=graphValidator&skin=blueSky)
As you can see as defined in faces-config, after user click the button on p.xhtml it will go to resetpwd.xhtml, if I have .. defined in template, then the button on resetpwd.xhtml will not work properly, I need click twice then will process the request. Well, if I directly go to resetpwd.xhtml wthout go throgh p.xhtml, everything is working fine.
So I suspect the problem cause by the .. defined in template., with this xml element, page source willd isplay extra header info:
Must be some bug in richfaces state management or the extra meta info included in head. As mention if I directly go to resetpwd.xhtml, everything work fine (i.e. button on that page no need click twice to respond). If navigate from p.xhtml to resetpwd.xhtml will work fine if take out the ... from tempalte file, but if I do so then the page will not render with skin.

How to wrap <noscript> tag to hide content when javascript disable

Let's say, I have HTML code like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
This is content.
</body>
</html>
And I want to add a <noscript> tag there. Which means, if the JavaScript disabled, it will show as a blank page.
And only when JavaScript is disabled, it will show "This is content text".
Please give me some examples to achieve. Thanks.
An alternative to a JS approach as suggested by rahul is to display a div in the <noscript> element, covering the entire page:
<noscript>
<div style="position: fixed; top: 0px; left: 0px; z-index: 30000000;
height: 100%; width: 100%; background-color: #FFFFFF">
<p style="margin-left: 10px">JavaScript is not enabled.</p>
</div>
</noscript>
Wrap all you contents inside a main div with display none and in the onload function change the display to block.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div id="divMain" style="display: none">
This is content.
</div>
<noscript>
JS not enabled
</noscript>
<script>
document.getElementById("divMain").style.display = "block";
</script>
</body>
</html>
The noscript tag works the other way around. To make the content visible when script is enabled, put it in an element that is hidden, and show it using script:
<div id="hasScript" style="display:none">
This is content
</div>
<script>document.getElementById('hasScript').style.display='';</script>
It's a little odd.
You don't even need a 'noscript' for this. You can just have a blank first page, who's only content is a javascript of the form:
document.location = '/realpage.htm';
And then call that OnLoad, with jQuery, or whatever. This will mean if the client doesn't have scripting, they don't go anywhere, hence the page remains blank.
Edit:
Example, as requested:
<html>
<body onload="document.location = 'realpage.html';">
</body>
</html>
This SHOULD really work!
hide a content when javascript is not enabled
Note: you can replace <noscript> with <noembed> or <noframes>, too.
<!-- Normal page content should be here: -->
Content
<!-- Normal page content should be here: -->
<noscript>
<div style="position: absolute; right: 0; bottom: 0;
display: none; visibility: hidden">
</noscript>
<-- Content that should hide begin -->
**Don't Show! Content**
<-- Content that should hide begin -->
<noscript>
</div>
</noscript>
<!-- Normal page content should be here: -->
Content
<!-- Normal page content should be here: -->
Both the style tag and the meta refresh DO work inside noscript:
<noscript>
<style>body { display:none; }</style>
<meta http-equiv="refresh" content="0; url=blankpage.html">
</noscript>
The first line will display the current page but empty.
The Second line will redirect to blankpage.html
I had a very problem:
I wanted to show the full site when javascript was enabled. However, if javascript were disabled, not only did I want to show a "this site requires javascript..." message, but I still wanted to display the header & footer (which reside in header.inc and footer.inc, called by each content page) of my site (to look nice). In other words, I only wanted to replace the main content area of my site. Here's my html/css solution:
Header.inc file (location not important):
<noscript>
<style>
.hideNoJavascript {
display: none;
}
#noJavascriptWarning {
display: block !important;
}
</style>
</noscript>
Header file (bottom):
<div id="noJavascriptWarning">The Ignite site requires Javascript to be enabled!</div>
<div class="container-fluid hideNoJavascript">
<!-- regular .php content here -->
CSS file:
#noJavascriptWarning {
color: #ed1c24;
font-size: 3em;
display: none; /* this attribute will be overridden as necessary in header.inc */
text-align: center;
max-width: 70%;
margin: 100px auto;
}
In summary, my "javascript required" message is hidden per my default CSS rule. However, when the browser parses the tag, it overrides the default rule, resulting in main content being hidden and (everything except header/footer) and the javascript message being displayed. Works perfectly...for my needs! Hopefully someone else finds this useful :-)
Here are two screenshots with javascript enabled/disabled:
You could do something like
<body id="thebody">
this is content.
<script>
document.getElementById('thebody').innerHTML = "<p>content when JS is enabled!</p>";
</script>
</body>
I know this is an old inquire, but somehow none of this things worked in one of the PHP page I created. Below is what worked, the important thing was the comment tag between the noscript tag:
<noscript>
<center><div style="font-size:300%;position: absolute;top: 40%;left: 50%;margin-right: -50%;transform: translate(-50%, -50%)">
Scripts are Required...
<meta http-equiv='refresh' content="1;url=http://flstate.us/NoScript"/>
</div> </center>
<!--
</noscript>
<html>
<body>
Page HERE...
</body>
</html>
<noscript> --> </noscript>