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

              
                <h2>Batch QR Code generator</h2>

<div>
  <label for="codeSize" class="smallText">Code size (pixels)</label>
  <input id="codeSize" type="number" min="40" value="45" </input>
</div>

<div>
  <label for="codeMargin" class="smallText">Code margin (pixels)</label>
  <input id="codeMargin" type="number" min="0" value="0" </input>
</div>

<div>
  <label for="prefixTxt" class="smallText">Code prefix</label>
  <input id="prefixTxt" type="text" placeholder="will be prepended to every code" </input>
</div>
<div>
  <label for="inTxt" class="smallText"><b>Code values</b> (one line = one code)</label>
</div>
<div>
  <textarea id="inTxt" class="mono" type="text" placeholder="Paste Tag codes here. One line=one code, blank lines will be ignored." rows="10" cols="50"></textarea>
</div>

<button onclick="generateQRcodes()">Generate & Download QR codes</button>
              
            
!

CSS

              
                *{
  font-family: 'Noto Sans', sans-serif;
}

body{
  background-color: #ccc;
  padding: 10px;
}

body, div, span, button{

  margin: 6px;
}

.mono{
  font-family: 'Consolas', monospace;
}
.smallText{
  font-size: 0.8em;
}

.errLabel{
  color: red;
  font-size: 0.75em;
}

.transp{
  background-color: none;
}

.opaque{
  background-color: white;
}
              
            
!

JS

              
                var width = 45, height = 45;
var prefix = ""
var codeMargin = 0;

function getParameters(){
prefix = document.getElementById("prefixTxt").value;
width = height = document.getElementById("codeSize").value;
codeMargin = document.getElementById("codeMargin").value;
}

function generateQRcodes(){

  getParameters();

  var allText = document.getElementById("inTxt").value;
  var codes = allText.match(/[^\n\r]+/g); 
  if (codes.length == 0) return;
  
  const pdf = new jsPDF({
      unit: 'pt',
      orientation: 'p',
      format: [width, height],
      lineHeight: 1.2
    });
  
 pdf.deletePage(1);
  

var svgEl = document.createElement('svg');

for (var i=0; i<codes.length; i++){

qrcode = new QRCode({
  content: document.getElementById("prefixTxt").value + codes[i],
  padding: codeMargin,
  width: width,
  height: height,
  color: "black",
  background: "none",
  ecl: "L"
});

pdf.addPage();

svgEl.innerHTML = qrcode.svg();

// render the svg element
svg2pdf(svgEl, pdf, {
	xOffset: 0,
	yOffset: 0,
	scale: 1
});
 
}

// save pdf
  
 pdf.save('qrcodes');
  
// savePDFs(pdfArr, codes);
  
}
  
// get the data URI
//const uri = pdf.output('datauristring');
//console.log(uri);

// MAIN

document.getElementById("prefixTxt").value = prefix;
document.getElementById("codeSize").value = width;
document.getElementById("codeMargin").value = codeMargin;
              
            
!
999px

Console