Problem opening a PDF after flattening within Coldfusion page

Posted on 2011-10-13
Last Modified: 2013-12-24
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">

<!---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.
Question by:wdtech
    LVL 51

    Accepted Solution

       > <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.
    LVL 51

    Expert Comment

       > 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
    LVL 1

    Author Closing Comment

    As simple as that! Fantastic, thanks!
    LVL 51

    Expert Comment

    Welcome :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe INTRODUCTION This article presents a solution to a question (…
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
    In this second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now