• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

Problem opening a PDF after flattening within Coldfusion page

Environment:
Coldfusion 8 server
PDF with form fields creaded in Acrobat X
End users on Intranet have Adobe Reader X, Win7

Here is what I am trying to achieve:
Page 1 - form to capture user data and submit to page 2
Page 2 - populates existing PDF's fields, saves to a new file and displays file.

The problem I am having is that when page 2 attempts to display the PDF file after creating it I am getting a file error: The file specified in contentTag does not exist.

Code snippet:
 
<!---write the form to a new file and flatten to prevent editing--->
<cfpdf action="write" source="ERF-temp.pdf" destination="#FileName#" flatten="yes"  overwrite = "true">
</cfpdf>

<!---show finished PDF for printing--->
<cfcontent file="http://vreports/admin/#FileName#">

Open in new window


I am assuming this is because it has not finished writing the file before I am trying to display it but I am not sure how to make it work. Please help.
0
wdtech
Asked:
wdtech
  • 3
1 Solution
 
_agx_Commented:
   > <cfcontent file="http://vreports/admin/#FileName#">

file should be a full physical path, for example:

    <cfcontent file="c:\coldfusion9\wwwroot\vreports\admin\someFile.pdf">

> <cfpdf action="write" source="ERF-temp.pdf" destination="#FileName#"

   It's also better to use absolute file paths instead of relative ones. You can use ExpandPath(".")
   to get the path of the current directory.
0
 
_agx_Commented:
   > You can use ExpandPath(".") to get the path of the current directory

... Or convert any relative url to get the a physical path.  

        <cfset path = ExpandPath(".")>                              <== current directory
        <cfset path = ExpandPath("../")>                            <== parent folder
        <cfset path = ExpandPath("/")>                              <== web root
        <cfset path = ExpandPath("/subfolder")>               <== some subfolder beneath root

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c67.html
0
 
wdtechAuthor Commented:
As simple as that! Fantastic, thanks!
0
 
_agx_Commented:
Welcome :)
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now