I'm using ColdFusion 8 to and the object to create an xml document and then write the data to fields in an existing PDF file on our intranet. The problem is that I need the PDF to open in a new browser window, not the same browser window, which is what is happening now.
Is there any additional info I can pass along with the 'destination=' tag to force the PDF form to open in a new browser window?
Thanks in advance for all replies
Providing code examples in the future would be greatly appreciated and should expedite resolution. However, if I am understanding you correctly, and depending on your preference, then one of the following solutions should suffice.
ColdFusion (Server-side)
If you are NOT writing the newly populated PDF to disk:
<cfpdf name="variableName" />
<cfheader name="Content-Disposition" value="attachment; filename=filename.pdf" />
<cfcontent type="application/pdf" variable="#toBinary(variableName)#" />
OR
If you ARE writing the newly populated PDF to disk:
<cfpdf action="write" destination="c:\full\path\to\filename.pdf" />
<cfheader name="Content-Disposition" value="attachment; filename=filename.pdf" />
<cfcontent type="application/pdf" file="c:\full\path\to\filename.pdf" />
OR
HTML (Client-side)
Anchor Text
OR
JavaScript (Client-side)
window.open("/relative/url/to/pdf/populate/template.cfm", "windowName");
I was looking for the answer and coworker steered me towards this easy solution. This will open a pdf in a new web browser window.
test.pdf
index.cfm (calling page)
<cfheader name="Content-disposition" value="inline;filename=test.pdf">
<CFCONTENT TYPE="application/pdf" FILE="#url.filePath#" DELETEFILE="No">
showPdf.cfm
Related
I have a web app that uses primefaces extensions.
If I use
<pe:documentViewer id="verPdf"
height="500"
name="/resources/pdf/#{utentesBean.nomeFile}" />
it does not render PDF in view.
if I use
<pe:documentViewer id="verPdf"
height="500"
name="/resources/pdf/441.pdf" />
it shows the PDF .
Can anyone give an idea ?
Thank you.
I am one of the developers of the document viewer component and I just tested it and it worked fine with both of the following:
<pe:documentViewer url="/sections/documentviewer/#{controller.bookFile}"/>
<pe:documentViewer library="books" name="#{controller.hoodFile}"/>
One thing I noticed above in your example is you were not using URL you were using "name" attribute and name is meant to be used with "library" as in my example above as a relative path to a resource folder called "books".
I think you want to change your code to...
<pe:documentViewer id="verPdf"
height="500"
library="pdf"
name="#{utentesBean.nomeFile}" />
I'm trying to print PDF from HTML using cfdocument. The code works fine when I access it through localhost, but when I use static IP to test it online on the same server it timeouts.
I tried cfhtmltopdf it didn't timeouts but it doesn't generate the chart and shows "image missing icon". nor charts get generated nor images. text gets printed fine. And it takes like 20 to 30 seconds to generated the PDF when an image or chart is used.
I tried this on CF11 32bit and 6bit both having same issue.
Even the simplest codes fails:
<cfhtmltopdf>
<!DOCTYPE html>
<html>
<body>
<div class="pdf_logo" style="margin-bottom: 20px;">
<img src="images/logo.png" width="180">
</div>
</body>
</html>
</cfhtmltopdf>
Your problem is probably with resolution of the path to the image. try an absolute path (http://) Or a file path (file:\) ... try resolving the image from the desktop of the server itself.
Remember that the server internally must resolve your images/logo.png into something like . If (for example) your pdf generating cfm is in a folder that is not the root, the server may resolve it to http://blah.com/some folder/images/logo.png - which naturally won't work because there's no "images" folder in there.
Other possibilities? Your server can't resolve an "internal" natted address, or is trying to use an external non-natted address through the firewall interface.
Fortunately almost all these problems can be easily tested or resolved. You will also save yourself headaches by simply using the file method to include any resources into your PDF file.
For more on resolution issues see my post on Network address resolution and Cfdocument.
Hope this helps! good luck.
I've encountered a similar issue with cfhtmltopdf. In my case, I was using a cfimage tag, and the images were being rendered in the PDF document very sporadically.
I suspect that the rendering of the cfhtmltopdf tag happens asynchronously, in a separate thread from any rendering that may happen inside that tag (for example, cfimage or cfchart). So the cfhtmltopdf tag will finish rendering, and it won't have the results from the rendering of cfimage or cfchart, so it displays the "broken image" icon because it can't find the source.
So this solution based on ColdFusion documentation†might help you:
<!--- 1. Generate the chart as a jpeg image. --->
<cfchart name="myChart" format="jpg">
<cfchartseries type="pie">
<cfchartdata item="New Vehicle Sales" value=500000>
<cfchartdata item="Used Vehicle Sales" value=250000>
<cfchartdata item="Leasing" value=300000>
<cfchartdata item="Service" value=400000>
</cfchartseries>
</cfchart>
<!--- 2. Write the jpeg image to a temporary directory. --->
<cffile
action="write"
file="#ExpandPath('/charts/vehicle.jpg')#"
output="#myChart#" />
<!--- 3. Generate the PDF file. --->
<cfhtmltopdf>
<!DOCTYPE html>
<cfoutput>
<html>
<body>
<div class="chart">
<!--- This image tag refers to the file created by cffile --->
<img src="/charts/vehicle.jpg" />
</div>
</body>
</html>
</cfoutput>
</cfhtmltopdf>
†Based on the example here: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7934.html
I'm using Primefaces 3.5 and I have ran into a pretty disturbing problem. The component looks like this in the xhtml:
<p:tab id="installApp" title="Install application">
<h:form enctype="multipart/form-data">
<p:panel header="Upload status" id="upld_status">
<p:dataTable id="errorTable" var="error"
value="#{applicationInstallerBean.uploadMsgs}">
<p:column headerText="Application">
<h:outputText value="#{error.filename}" />
</p:column>
<p:column headerText="Status">
<h:outputText value="#{error.errorMsg}" />
</p:column>
</p:dataTable>
</p:panel>
<p:remoteCommand name="clearPrevious" update="upld_status uploader" action="#{applicationInstallerBean.clearPrevious}" process="#this" />
<p:fileUpload id="uploader" multiple="true" dragDropSupport="true" onstart="clearPrevious()"
fileUploadListener="#{applicationInstallerBean.install}" uploadLabel="Install"
mode="advanced" update="#this upld_status" auto="false"
allowTypes="/(\.|\/)(zip)$/" styleClass="install_app_fileupload" />
</h:form>
<p:panel header="Help" toggleable="true">
<ui:include src="applicationInstallHelp.xhtml" />
</p:panel>
</p:tab>
Now the behaviour I'm experiencing is pretty strange:
For the first few times, uploading files with drag'n'drop method works fine. After a few uploads, the following errors appear totally undetermenistic:
FileUpload component disappears after pressing Upload button, only to reappear when I refresh the page
the onstart method gets called a lot of times during upload
the table containing the status of the upload does not refresh or only one of the files appear there, when multiple are uploaded
I also get a message from the browser that a script is running on this page and I can abort or continue
What I have tried:
Removing the h:form element, since this is an include in the index file, which already has a h:form element in it
Result: basicly the same, with the difference, that dropping a file for the first time onto the component automatically uploads it, but auto is set to false
I have also tried emptying the browser cache, redeploying the application from a scratch, turning off multiple...all with no luck.
The files I'm uploading are 80k to 9mb.
From this it looks to me, that uploading too much files makes the whole thing go crazy, but I cannot really think of a solution. Any help would be appreciated.
Update: During testing I found that the onstart method ALWAYS fires more than once after the first upload. For the first time it only fires once. On the second upload about 7-10 times, on the third time it seems it keeps firing until I end the session. This is pretty strange and I think it may be the root of the problems. Any ideas on this?
Thank you in advance!
The "multiple files" feature enables to select more files for uploading. The listener is called after each transmission. But I don't know how many files will be uploaded by the component at all.
I would like to navigate to the next page after all the selected files were processed. Any suggestion is highly appreciated.
fileUploadListener="#{uploadBean.handleFileUpload}"
maybe not a good solution but you can use the oncomplete from p:fileUpload to trigger a hidden button, which invokes a action to navigate.
<p:fileUpload ... oncomplete="$('#btn').click()" />
and
<p:commandButton id="btn" action="#{myBean.actionToNavigate}" style="display:none;" />
I need to embed Foxit Reader (PDF reading software) into a web page. Does anybody know the correct classid and parameters to use in the following code:
<object id="pdfReaderObj" classid="CLSID:XXXX" width="500" height="700">
<param name="Filename" value="/1234-56789-abc-123-3.pdf">
<param name="SRC" value="/1234-56789-abc-123-3.pdf">
You must install Foxit Reader to view this document.
</object>
Additionally if anyone has experience of enterprise deployment, silent installation, registry setting etc. These would also be welcomed.
Thanks
Foxit Reader itself doesn't include any embeddable components; they have Foxit Reader ActiveX for this purpose, which is a paid component distributed separately from the Reader. For example, the Standard ActiveX version can be embedded into a web page in the following way:
<script type="text/javascript"">
function openFile() {
document.getElementById("foxitReader").OpenFile("foo.pdf", "");
}
</script>
<body onload="openFile()">
<object id="foxitReader"
classid="clsid:DB2189DF-ABF4-445A-A4E5-BF32F2CEA4D9"
width="800" height="600">
<p>You must install Foxit Reader ActiveX to view this PDF file.</p>
</object>
</body>
(I'm not a web developer, so this code may be far from perfect, but it should help you get the idea.)
If using Foxit Reader ActiveX is not an option for you, take a look at this question which discusses other possible ways of displaying PDF content.