• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Beginner at PDF

Community Beginner ,
Mar 26, 2020 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?

 

Views

1.4K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 27, 2020 Mar 27, 2020

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\ww

...

Votes

Translate

Translate
Community Expert ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

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


/Charlie (troubleshooter, carehart.org)

Votes

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
community guidelines
Community Beginner ,
Mar 26, 2020 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. 

 

Votes

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
community guidelines
Community Expert ,
Mar 27, 2020 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 (troubleshooter, carehart.org)

Votes

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
community guidelines
Community Beginner ,
Mar 27, 2020 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?

 

Votes

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
community guidelines
Community Beginner ,
Mar 27, 2020 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?

 

Votes

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
community guidelines
Community Expert ,
Mar 27, 2020 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 (troubleshooter, carehart.org)

Votes

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
community guidelines
Community Beginner ,
Mar 27, 2020 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!

 

Votes

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
community guidelines
Community Expert ,
Mar 27, 2020 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 (troubleshooter, carehart.org)

Votes

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
community guidelines
Community Beginner ,
Mar 27, 2020 Mar 27, 2020

Copy link to clipboard

Copied

I stand by my <cfsavecontent> comment. 

 

Votes

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
community guidelines
Community Beginner ,
Mar 27, 2020 Mar 27, 2020

Copy link to clipboard

Copied

LATEST

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. 

 

Votes

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
community guidelines
Resources
Documentation