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

OnLoad To call PDF convert (not worknig)

basemMO wrote on 2011-10-04:
<a id="callPDF" href="">&nbsp;</a>

<script type="text/javascript">
window.onload = function () { triggerPDF(); }

function triggerPDF() {

basemMO wrote on 2011-10-04:

I think I was able to trigger an <a> tag, however, what the HTML I want to to convert into PDF is in below tag, and I'm usining innerHTML to pouplate the text, However the PDF is not showing the dynamically rendered HTML code, Kindly advise, what other code should I use

<td id="projectsDisplayList" height="163" align="left" valign="top" bgcolor="#FFFFFF">
basemMO wrote on 2011-10-04:
<form method='post' target='_blank' action='' id='createPdfForm'>

<input type='hidden' name='username' value='basemMO' />
<input type='hidden' name='key' value='basemMO' />

<input type='hidden' name='src' id='pdfsrc' />

<input type='hidden' name='width' value='210mm' />
<input type='hidden' name='height' value='297mm' />
<input type='hidden' name='pdf_name' value='dashboard.pdf' />


<script type="text/javascript">


window.onload = function () { triggerForm(); }

function triggerForm() {

alert ('before setting');
// set the inner html page to the pdf converter tool
document.getElementById("pdfsrc").value = projectDisplay;
alert ('after setting');

alert ('submitting the form');
alert (document.getElementById("pdfsrc").value);



NOT WORKING............................. PLEASE WANT HELP HERE
support wrote on 2011-10-04:
Submitting the form automatically (i.e. without user intervention) in onload seems not to work reliably in all browsers. For example Google Chrome displays "This site is attempting to download multiple files" on the second reload.

An option is to submit the form manually. You can set the value of the src field dynamically like this
    <script src=""></script>
      $(function() {
        $("#createPdf").click(function() {
          $("#pdfsrc").val("<b>your html code</b>")

    <form method="post" action="" id="createPdfForm" > 
      <input type="hidden" name="username" value="***" /> 
      <input type="hidden" name="key" value="***" /> 
      <input type="hidden" name="src" id="pdfsrc" value="test"/> 
      <input type="hidden" name="width" value="210mm" /> 
      <input type="hidden" name="height" value="297mm" /> 
      <input type="hidden" name="pdf_name" value="dashboard.pdf" /> 
      <input type="button" id="createPdf" value="create PDF" /> 

basemMO wrote on 2011-10-05:
Perfectoo... working fine now :) much apprecaited, I'm pretty sure that after showing it to management, we will buy it