Skip to content

Instantly share code, notes, and snippets.

@dmslabsbr
Created June 4, 2019 18:42
Show Gist options
  • Save dmslabsbr/a5b23c877970fd9caf4fa68eb3eca0e0 to your computer and use it in GitHub Desktop.
Save dmslabsbr/a5b23c877970fd9caf4fa68eb3eca0e0 to your computer and use it in GitHub Desktop.
Function to show numbers in a jsPDF pdf to help you put text in correct point.
/**
* Mostra números x : y para ajudar a colocar os dados nos locais certos.
* @param {*} doc
*/
function mostraRegua(doc) {
let pH = doc.internal.pageSize.height;
let pW = doc.internal.pageSize.width;
doc.setFontSize(5);
doc.setTextColor(255, 0, 0);
doc.setDrawColor(0,0,255);
for (var y = 0; y < pH; y += 50) {
for (var x = 0; x < pW; x += 50) {
doc.text(x+3, y+2, '' + x + " / " + y);
doc.circle(x, y, 1);
}
}
return doc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment