Highlighted

Beginner at PDF

Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Ok, I am trying to make a PDF file ... 

At the end of a <cfsavecontent> within a function within a ajax .cfc template ... 

I added <cffile
action = "write"
file = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
output = "#invoice#"
>

That worked fine. 

Then I added ... 

<cfhtmltopdf>
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf"

</cfhtmltopdf>

The moment I run it I get a parse JSON error.  It's hosing on the cfhtmltopdf tag. 

I know I do not yet have a other parameters ... but what am I doing wrong to cause the JSON error?

 

Adobe Community Professional
Correct answer by Charlie Arehart | Adobe Community Professional

The doc is mistaken. You've been a cfml coder for years (I've just noticed your account name). Do you not recognize the mistake, even from what I said?

 

Let me be explicit for you. Please first change this:

<cfhtmltopdf>
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf"

</cfhtmltopdf>

 

To this:

 

<cfhtmltopdf
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf">

</cfhtmltopdf>

 

You may even be able to leave off the closing tag. I'm short of time to run a test for you. 

 

You could also leave off the source attribute and put your #invoice# var between the pair of cfhtmltopdf tags. 

 

Finally, you have not addressed my suggestion that you look at the intermediate html file, to see how it looks. First look in a editor, then in a browser. Anything amiss about it?

 

The cf tag will of course be trying to create a pdf from that html, so if the browse has any errors, so will cf. But even if it renders well, look at the source in that html. There may be something your human eyes recognize as an error that the browser may not, but it seems cf has a problem with.

 

 

Views

1.1K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Beginner at PDF

Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Ok, I am trying to make a PDF file ... 

At the end of a <cfsavecontent> within a function within a ajax .cfc template ... 

I added <cffile
action = "write"
file = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
output = "#invoice#"
>

That worked fine. 

Then I added ... 

<cfhtmltopdf>
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf"

</cfhtmltopdf>

The moment I run it I get a parse JSON error.  It's hosing on the cfhtmltopdf tag. 

I know I do not yet have a other parameters ... but what am I doing wrong to cause the JSON error?

 

Adobe Community Professional
Correct answer by Charlie Arehart | Adobe Community Professional

The doc is mistaken. You've been a cfml coder for years (I've just noticed your account name). Do you not recognize the mistake, even from what I said?

 

Let me be explicit for you. Please first change this:

<cfhtmltopdf>
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf"

</cfhtmltopdf>

 

To this:

 

<cfhtmltopdf
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf">

</cfhtmltopdf>

 

You may even be able to leave off the closing tag. I'm short of time to run a test for you. 

 

You could also leave off the source attribute and put your #invoice# var between the pair of cfhtmltopdf tags. 

 

Finally, you have not addressed my suggestion that you look at the intermediate html file, to see how it looks. First look in a editor, then in a browser. Anything amiss about it?

 

The cf tag will of course be trying to create a pdf from that html, so if the browse has any errors, so will cf. But even if it renders well, look at the source in that html. There may be something your human eyes recognize as an error that the browser may not, but it seems cf has a problem with.

 

 

Views

1.2K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 26, 2020 0
Adobe Community Professional ,
Mar 26, 2020

Copy link to clipboard

Copied

Can you confirm it's not about the closing bracket right after cfhtmltopdf? 

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 26, 2020 0
Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Sorry, not understanding your question. 

There is a closing bracket.  >

Just as if one were to use, say. <cfmail> lgskgs </cfmail>

Obviously I cannot put this stuff inside the <cfsavecontent> as the variable #invoice# would not be avilable to be used. 

I also understand what throws a parseJSON error.  

Either a valid showstopper error OR random junk characters in your function but outside the <cfsavecontent>

Which is WHERE my PDF stuff (<cfhtmltopdf>) is.  But where else can you put it?

Could it have anything to do with not having set something up in the CFADMIN panel?

And I spent a good few minutes reading the quite unhelpful docs at 

https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-g-h/cfhtmltopdf.html

and looked for a youtube video.  Nada. 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 26, 2020 0
Adobe Community Professional ,
Mar 27, 2020

Copy link to clipboard

Copied

You wrote <cfhtmltopdf>, with the closing bracket after the f, rather than after the value of the destination attribute. Was that just a copy/paste mistake here?

 

Assuming so, have you opened the intermediate html page? In an editor? Is it all and only html?

 

The error refers to json. I don't see how there's be any json involved in a cfhtmltoldf. Are you doing anything with json in this?

 

Finally, do you really NEED to write out the intermediate html file?  Cf doesn't require it, but you may have reason to prefer it. 

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0
Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

At

https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-g-h/cfhtmltopdf.html

it clearly shows the destination as being within 

<cfhtmltopdf>

encryption = "AES_128|RC4_40|RC4_128|RC4_128M|None"
source = "URL|pathname absolute or relative to web root"
destination = "filename"
language="language name"
marginBottom = "number"
marginLeft = "number"
marginRight = "number"
marginTop = "number"
name = "output variable name"
orientation = "portrait|landscape"
overwrite = "yes|no"
ownerPassword = "password"
pageHeight = "page height in inches(default)"
pageType = "page type"
pageWidth = "page width in inches(default)"
permissions = "permission list"
saveAsName = "PDF filename"
unit = "in|cm"
userPassword = "password"

HTML and CFML code

</cfhtmltopdf>

 

I tried without writing the file but got a JSON error too. 

How else would you do it?

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0
Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

This forum software is silly. 

Why send me an email to tell me when I have replied to my own thread? DOH?

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0
Adobe Community Professional ,
Mar 27, 2020

Copy link to clipboard

Copied

The doc is mistaken. You've been a cfml coder for years (I've just noticed your account name). Do you not recognize the mistake, even from what I said?

 

Let me be explicit for you. Please first change this:

<cfhtmltopdf>
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf"

</cfhtmltopdf>

 

To this:

 

<cfhtmltopdf
source = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.html"
destination = "c:\inetpub\wwwroot\webstuff\coldfusion\images\pdffile.pdf">

</cfhtmltopdf>

 

You may even be able to leave off the closing tag. I'm short of time to run a test for you. 

 

You could also leave off the source attribute and put your #invoice# var between the pair of cfhtmltopdf tags. 

 

Finally, you have not addressed my suggestion that you look at the intermediate html file, to see how it looks. First look in a editor, then in a browser. Anything amiss about it?

 

The cf tag will of course be trying to create a pdf from that html, so if the browse has any errors, so will cf. But even if it renders well, look at the source in that html. There may be something your human eyes recognize as an error that the browser may not, but it seems cf has a problem with.

 

 

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0
Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

Recognize the mistake???  I was doing what teacher (docs) said. 

Besides the syntax is valid for all sorts of tags like<cfsavecontent>

Moving the #invoice# to between the tags also works. 

Thank you ... 

Yes that did it.  BAD BOY TEACHER!

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0
Adobe Community Professional ,
Mar 27, 2020

Copy link to clipboard

Copied

Thanks for marking one of the answers correct.

 

But no, the syntax you were attempting was not valid. It does NOT make sense to close the opening tag name and THEN list its attributes. You would not write this, would you?

<cfquery>
datasource="yourdsn" name="xx"

I was getting at this from the first reply, in increasing detail. Hope it makes sense now. 

 

But yes, the doc you were using is wrong, and it misled you from the outset. That's unfortunate. You can report that at tracker.adobe.com. If you do, please share the link here so others can add votes.

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0
Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

I stand by my <cfsavecontent> comment. 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0
Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

https://tracker.adobe.com/ is a waste of time .. too much time just to figure out HOW to add a bug. 

Too many required choices. 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 27, 2020 0