Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <!DOCTYPE html>
<html>
<img src="https://s3.amazonaws.com/awsmp-logos/PandaDoc.png"></img>
<body>
  <p>Access Token: <input type="text" id="access_token"></p>
  <input type="file" id="myFile">
  <br/>
  <p>
    <button onClick="createDocument()">Create Document from PDF upload</button>
  <p><a id='docURL' href="" target="_blank"></a></p>
    <p id="responseCreate"></p>
    <button onClick="checkStatus()">Check Document Status</button> --- check for status = document.draft before sending
    <p id="responseStatus"></p>
    
    <button onClick="sendDoc()">Send Document</button> --- after document is moved to draft status it can be sent
    <p id="responseSend"></p>
  </p>

</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                function createDocument() {
  var formData = new FormData();
  formData.append("file", document.getElementById("myFile").files[0]);

  formData.append(
    "data",
    JSON.stringify({
      name: "Sample Document from PDF with Field Tags",
      recipients: [
        {
          email: "jane@example.com",
          first_name: "Jane",
          last_name: "Roe"
        }
      ],
      parse_form_fields: false
    })
  );

  var xhr = new XMLHttpRequest();

  xhr.open("POST", "https://api.pandadoc.com/public/v1/documents");
  xhr.setRequestHeader(
    "Authorization",
    "Bearer " + document.getElementById("access_token").value
  );
  //This header is removed because we are letting the browser handle boundries and set content type appropriately.
  //xhr.setRequestHeader("Content-Type", "multipart/form-data");

  xhr.onload = function() {
    document.getElementById("responseCreate").innerHTML = xhr.responseText;
    document.getElementById("docURL").href = 'https://app.pandadoc.com/a/#/document/v1/editor/'+ JSON.parse(xhr.response).id
    document.getElementById("docURL").innerHTML = 'https://app.pandadoc.com/a/#/document/v1/editor/'+ JSON.parse(xhr.response).id
  };
  xhr.send(formData);
}

function checkStatus() {
  var doc_id = JSON.parse(document.getElementById("responseCreate").innerText)
    .id;
  var xhr = new XMLHttpRequest();

  xhr.open("GET", "https://api.pandadoc.com/public/v1/documents/" + doc_id);
  xhr.setRequestHeader(
    "Authorization",
    "Bearer " + document.getElementById("access_token").value
  );
  xhr.onload = function() {
    document.getElementById("responseStatus").innerHTML = xhr.responseText;
  };
  xhr.send();
}

function sendDoc() {
  var doc_id = JSON.parse(document.getElementById("responseCreate").innerText)
    .id;
  var xhr = new XMLHttpRequest();

  xhr.open(
    "POST",
    "https://api.pandadoc.com/public/v1/documents/" + doc_id + "/send"
  );
  xhr.setRequestHeader(
    "Authorization",
    "Bearer " + document.getElementById("access_token").value
  );
  xhr.setRequestHeader("Content-Type", "application/json");
  xhr.onload = function() {
    document.getElementById("responseSend").innerHTML = xhr.responseText;
  };
  let body = {
    message: "Hello! This document was sent from the PandaDoc API.",
    silent: false
  };
  xhr.send(JSON.stringify(body));
}

              
            
!
999px

Console