Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.2.0/jspdf.umd.min.js"></script>
Entery your personal number here:
<input id="secret"></input>
<p>The certificate below will be downloaded to your computer. No information will be stored on the server.</p>
<hr>

<div id="content">
     <h1>YOUR CERTIFICATE OF AWESOME</h1>
  <h2>Jill Smith</h2>
  <div id="display-secret"></div>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam quid possumus facere melius? Non dolere, inquam, istud quam vim habeat postea videro; Idemne potest esse dies saepius, qui semel fuit? Hoc est non dividere, sed frangere. Quae cum ita sint, effectum est nihil esse malum, quod turpe non sit. Duo Reges: constructio interrete. Atqui haec patefactio quasi rerum opertarum, cum quid quidque sit aperitur, definitio est. Nec vero sum nescius esse utilitatem in historia, non modo voluptatem. Nam quid possumus facere melius?

</p>
  
</div>
<div id="editor"></div>

<button id="cmd">Download PDF</button>


              
            
!

CSS

              
                #content {
    border: 1px solid #000;
    padding: 20px;
  }

#display-secret {
    display:block;
    margin: 20px 0;
  }

@media print {
  body {
    text-align: center;
    width: 90%;
  }
  input {
    border: 0
  }
  #display-secret, p {
    display:block;
    height: 40px;
  }
  
}
              
            
!

JS

              
                //https://parall.ax/products/jspdf

function demoFromHTML() {
  
  var pdf = new jsPDF("p", "pt", "a4");
  pdf.setFontSize("10");
  pdf.setLineWidth("100");
  pdf.setTextColor("darkblue");

  // Printing text
  var vuejsinformation = `JQuery is a lightweight, "write less, do more", JavaScript library.`;
  pdf.text(vuejsinformation, 10, 10);
  //pdf.save("Sample.pdf");

  // Printing a complete div container who has class pdfrapper
  pdfmake.html(window.jQuery("#content").get(0), {
    callback: function (pdf) {
      pdf.save("Sample.pdf");
    },
    x: 10,
    y: 10,
  });

    }

$('#cmd').click(function () {    
  demoFromHTML();
});



//get the number and display
let secret = document.querySelector('#secret');
let secretDisplay = document.querySelector('#display-secret');
secret.addEventListener('input', function (evt) {
  console.log(this.value);
  secretDisplay.innerHTML = this.value
});

              
            
!
999px

Console