This topic contains 3 replies, has 0 voices, and was last updated by Jordan Manningham 7 years, 9 months ago.

  • Author
    Posts
  • #5594

    Jordan Manningham

    Hi All,

    I’ve been working on a project that requires generating a PDF which of course requires some knowledge of HTML and CSS. The part I’m stuck on requires some JavaScript though I’m not sure how to tie both languages together using [js]'


    xml += '

    '

    xml += '

    '
    xml += ' '
    xml += '

    '
    xml += '

    '
    xml += '

    '
    xml += '

    '
    xml += '

    '
    xml += '

    '
    xml += '

    '
    xml += '

    '
    xml += '

    Bill of Materials
    Item Description Quantity Units

    '
    xml += '

    '
    xml += ''
    xml += '';

    response.renderPDF(xml); //TESTING WITH ITEM 6700-55
    }
    else{
    dumpResponse(request,response);
    }

    }
    [/js]

    This is a cached copy. Click here to see the original post.

  • #5595

    david.smith

    I don’t think you want to try and put your script into the xml for the PDF. A PDF document is not able to modify itself like this. There are quite a few things here I would change but basically you will want your ‘xml’ to be the complete before rendering it. So use your ‘lines’ loop to create the table data as a string and then just insert that into the ‘xml’.

  • #5596

    Jordan Manningham

    david.smith You’re a genius. That makes so much sense and I’m jealous I didn’t think of it haha. Will make corrections to my code and report back. Thanks!


    david.smith replied on 02/02/2017, 02:54 PM: hahaha – shhhhhh, don’t tell anyone those kinda things.

    Let me know how it goes.

  • #5597

    Jordan Manningham

    david.smith It worked like a charm!

    Code:
    //Components – Bill of Materials
    var lines = o_r.getLineItemCount(‘member’);
    var bom_string;
    for (var mem = 1; mem <= lines; mem++){
    components[mem – 1][0] = o_r.getLineItemText('member', 'item', mem);
    components[mem – 1][1] = o_r.getLineItemValue('member', 'memberdescr', mem);
    components[mem – 1][2] = o_r.getLineItemValue('member', 'quantity', mem);
    components[mem – 1][3] = o_r.getLineItemValue('member', 'memberunit', mem);
    bom_string += '

    ‘ + components[mem – 1][0] + ‘ ‘ + components[mem – 1][1] +
    ‘ ‘ +components[mem – 1][2] + ‘ ‘ + components[mem – 1][3] + ‘

    ‘;
    }

    while (bom_string.indexOf(‘ & ‘) != -1){
    bom_string = bom_string.replace(‘ & ‘, ‘ & ‘);
    }

    while (bom_string.indexOf(‘null’) != -1){
    bom_string = bom_string.replace(‘null’, ‘ ‘);
    }


    david.smith replied on 02/17/2017, 09:37 AM: You could also try nlapiEscapeXML(bom_string).

You must be logged in to reply to this topic.