http://coldfusion.com logo
#cfml-general
Title
# cfml-general
g

glook

02/02/2022, 1:55 PM
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

aliaspooryorik

02/02/2022, 2:06 PM
Are you trying to create a form in your PDF?
g

glook

02/02/2022, 2:09 PM
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

aliaspooryorik

02/02/2022, 2:10 PM
So it's a read-only print out of their data?
g

glook

02/02/2022, 2:10 PM
Yes.
a

aliaspooryorik

02/02/2022, 2:12 PM
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

glook

02/02/2022, 2:14 PM
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

aliaspooryorik

02/02/2022, 2:19 PM
Oh no! 'used to work' stuff is very annoying 😕
g

glook

02/02/2022, 2:24 PM
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

aliaspooryorik

02/02/2022, 3:57 PM
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

Matt Jones

02/02/2022, 3:57 PM
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

glook

02/02/2022, 4:26 PM
Interesting, Matt. But I do see the same results in Acrobat DC. Worth looking at default stylesheet anyway, appreciate the response.
m

Matt Jones

02/02/2022, 4:53 PM
it wouldn't surprise me if something like dark mode somewhere in the mix was the culprit
👍 1
g

glook

02/02/2022, 4:54 PM
Yeah, that's valid. Especially in a used-to-work situation
d

David Buck

02/02/2022, 7:44 PM
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

glook

02/02/2022, 7:48 PM
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

David Buck

02/03/2022, 6:21 PM
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

glook

02/03/2022, 6:53 PM
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

David Buck

02/03/2022, 6:56 PM
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

glook

02/03/2022, 7:58 PM
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

David Buck

02/03/2022, 8:02 PM
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

glook

02/03/2022, 8:04 PM
I will
d

David Buck

02/03/2022, 8:05 PM
I'll upvote it if you post a link here
g

glook

02/03/2022, 9:33 PM
7 Views