Using Adobe CF 2018, this code produces a PDF with...
# cfml-general
g
Using Adobe CF 2018, this code produces a PDF with a blank textarea where the text only displays if clicked:
Copy code
<cfhtmltopdf name="myerecord">
<textarea name="test" id="test">TEXT</textarea>
</cfhtmltopdf>
<cfheader name="Content-Disposition" value="attachment;filename=testdocument.pdf">
<cfcontent type="application/pdf" variable="#myerecord#">
a
Are you trying to create a form in your PDF?
g
Yes-ish. These are e records with form fields for sure. The forms have already been completed, and we are now displaying the option to download as a PDF.
a
So it's a read-only print out of their data?
g
Yes.
a
I think you'd probably be better off doing a
<div class="textarea">My content</div>
and then a style of
.textarea {border:1px solid black width: 50px; height: 50px;}
or something like that. Forms in PDFs are a different rabbit hole 🙂
g
I could see that for sure. Of course, this is one of those 'stopped working' things where hundreds of forms with textareas are now requiring a click for reading their content.
a
Oh no! 'used to work' stuff is very annoying 😕
g
It sure is. You've helped me in the past and I appreciate your attention. I'm looking now into whether it's the viewer that is the problem by installing standard adobe reader and see if it has the same behavior.
It's not just textareas. I've added <input type="text" value="Input" /> and it does the same thing, hidden til clicked.
a
I figured it may be forms related (as PDFs can be forms) but why it did work and now doesn't is a mystery. Did any CSS change before it broke?
m
default stylesheet maybe updated for the viewer? i know in the past, if we hadn't declared some things explicitly it would occasionally change on us.
g
Interesting, Matt. But I do see the same results in Acrobat DC. Worth looking at default stylesheet anyway, appreciate the response.
m
it wouldn't surprise me if something like dark mode somewhere in the mix was the culprit
👍 1
g
Yeah, that's valid. Especially in a used-to-work situation
d
This is pretty kludgy, but for some reason, passing your pdf variable to
<cfpdfform>
and doing a "populate" action (with no data) seems to fix the problem:
Copy code
<cfhtmltopdf name="myerecord">
<textarea name="test" id="test">TEXT</textarea>
</cfhtmltopdf>
<cfpdfform source="#myerecord#" action="populate" name="myerecord" />
<cfheader name="Content-Disposition" value="attachment;filename=testdocument.pdf">
<cfcontent type="application/pdf" variable="#toBinary(myerecord)#">
It might be possible to use
<cfpdf>
in a similar fashion, though I haven't tested it.
g
It may be kludgy, but it's the best I've seen so far!
I've almost closed this case, and yes, the action-populate is at the heart of it. The last hurdle is that the pdf may be password protected. If I do the password at cfhtmltopdf, the action-populate of cfpdfform does not allow for a password. Ive tried to do cfpdf action-protect but this seems to expect the source to be a file and not a variable. I have to determine how to password protect after the populate. Still hacking away, thanks for what I've got so far.
d
cfpdf should work with a variable as the source. Try leaving off the pound signs.
If you don't need the form fields to retain their interactivity, you could also use cfpdf's "flatten" option to fix the problem instead of cfpdfform, e.g.:
Copy code
<cfpdf source="myerecord" name="myerecord" action="write" flatten="true">
g
The flatten is very nice and I'm running it right after the cfpdfform action-populate. It takes a blue background out of the text boxes. Thank you for that.
Because I've seen success with action="write" flatten="true", I'm trying action="protect" source="variablename" password="admin" to throw a password on.
d
Yw. Yeah, might as well do it all in one tag. You actually don't need to use the cfpdfform tag at all if you're doing cfpdf flatten=true.
g
You're dead on
👍 1
This is where it landed: <cfhtmltopdf name="myerecord">              <textarea name="test" id="test">TEXT</textarea> </cfhtmltopdf> <cfpdf action="write" source="myerecord" name="theerecord" flatten="true"></cfpdf> <cfpdf action="protect" source="theerecord" encrypt="AES_128" newUserPassword="fred"></cfpdf>
d
Yeah, that's pretty much the best I could come up with, too.
If you ever have a few minutes, you should report this issue to the Adobe bug tracker: https://tracker.adobe.com
g
I will
d
I'll upvote it if you post a link here
g