This is an archived forum post. The information may be outdated. Contact us if you have any questions.

textarea element's value or text does not show in PDF generated from the PDF API

brettm247 wrote on 2016-01-03:

Is the textarea element supported? After text is entered i copy it to the the value or text attribute before i send it to the pdf generator. The pdf generator returns a pdf with no text in the field.

Here is my html elements in jade format

                span#basic-addon1.input-group-addon(style="font-weight:bold !important;") Comments:
                textarea.form-control(id='comments', type='text', placeholder='Comments', aria-describedby='basic-addon1', name='comments') 

and my javascript to copy the elements text:

var comments = document.getElementById("comments");
            comments.setAttribute("value", comments.value);

I then send it off to my server and then to PdfCrowds api. Which works well.

I have to change textarea to input for the value to be read.

Any ideas?

Thank you!
support wrote on 2016-01-04:

Could you please post a link to a web page with the form that demonstrates the issue?
brettm247 wrote on 2016-01-04:

Comment box is at the bottom

The function relevant is generatePDF()

As i understand it i just need to set the Value attribute for the form input fields for pdfCrowd to recognize values that a user filled in. I am assuming this is the same for the textarea type.

Here is my code for setting the Value Attribute to the value of the input fields:

var elems = document.getElementsByTagName("input");
for(var i = 0; i < elems.length; i++) {
    // set attribute to property value
    elems[i].setAttribute("value", elems[i].value);

I then send the form html to my node.js server with an ajax call:

var content = $("#ScaleForm")[0].outerHTML;
            var businessName = $("#CompanyName").val();
            var request = $.ajax({
                url: "/pdf",
                method: "POST",
                contentType: "application/x-www-form-urlencoded",
                success: function(msg) {
                     $("#downloadPDF").attr("href", msg.file)

                error: function(msg) {
                    $("#error-modal").dialog({ modal: true });

My server code for the pdf function is (email info taken out but working)'/pdf', function (req, res) {
    console.log('Connected to Pdf Route');
    var data = [];
    var date = new Date();
    var time = date.getUTCMilliseconds();
    client.convertHtml(req.body.src + "<link rel='stylesheet' type='text/css' href=''>"
                     + "<link rel='stylesheet' type='text/css' href=''>"
                     + "<link rel='stylesheet' type='text/css' href=''>"
                     + "<link rel='stylesheet' type='text/css' href=''>"
                     + "<link rel='stylesheet' type='text/css' href=''>"
                     + "<link rel='stylesheet' type='text/css' href=''>"
                     + "<link rel='stylesheet' type='text/css' href=''>",
        { pdf: function (rstream) {
            rstream.on('data', function (chunk) {

            rstream.on('end', function () {
                var buffer = new Buffer(data.reduce(function (prev, current) {
                    return prev.concat(;
                }, []));

                fs.writeFile("pdfs/" + + time + ".pdf", buffer, 'binary', function onComplete(err) {
                    if (err) {
                        throw err;
                    console.log("pushing download");
                    var mailOpts, smtpTrans;
                    smtpTrans = nodemailer.createTransport({
                        service: '',
                        auth: {
                            user: "<email>",
                            pass: <pass>
                    //Mail options
                    mailOpts = {
                        from: '', //grab form data from the request body object
                        to: '',
                        subject: 'PDF generated',
                        text: ""
                    console.log('Sending Mail');
                    smtpTrans.sendMail(mailOpts, function (error, response) {
                        //Email not sent
                        if (error) {
                        //Yay!! Email sent
                        else {
                            console.log("Email Successfully sent");
                    res.send(200, { msg: "completed", file: "/pdfs/" + + time + ".pdf" });
        }, {
            width: "8.5in",
            height: "-1",
            margin_top: ".2in",
            margin_left: ".4in",
            margin_right: ".4in",
            margin_bottom: ".2in",
            footer_html: '<div style=text-align:center;font-size:smaller;color:gray;">\
                              Page %p out of %n\
            use_print_media: '1'
    console.log("Done with PDF");

libraries i am using are:

JqueryValidation (
jquery.fileDownload (
Node.js with Express/PdfCrowd/cookie-parser

Thanks for your time!
support wrote on 2016-01-11:

I'm not sure where the problem is. The textarea element should work with Pdfcrowd - try to paste the following code to and click the "Convert to PDF" button.
<textarea rows="4" cols="50">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. 

I would recommend that you check the HTML code that your server sends to the API and ensure that the text area is not empty.
brettm247 wrote on 2016-01-13:
Setting the innerHTML instead of the value worked! I just assumed i needed to set the value like the other inputs.

var comments = document.getElementById("comments");
comments.innerHTML = comments.value;

Thanks for your help!