Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions examples/js/font-faces.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
var doc = new jsPDF();
const doc = new jsPDF();

doc.text("This is the default font.", 20, 20);

doc.setFont("courier");
doc.setFontStyle("normal");
doc.setFont("courier", "normal");
doc.text("This is courier normal.", 20, 30);

doc.setFont("times");
doc.setFontStyle("italic");
doc.setFont("times", "italic");
doc.text("This is times italic.", 20, 40);

doc.setFont("helvetica");
doc.setFontStyle("bold");
doc.setFont("helvetica", "bold");
doc.text("This is helvetica bold.", 20, 50);

doc.setFont("courier");
doc.setFontStyle("bolditalic");
doc.setFont("courier", "bolditalic");
doc.text("This is courier bolditalic.", 20, 60);

doc.setFont("times");
doc.setFontStyle("normal");
doc.setFont("times", "normal");
doc.text("This is centred text.", 105, 80, null, null, "center");
doc.text("And a little bit more underneath it.", 105, 90, null, null, "center");
doc.text("This is right aligned text", 200, 100, null, null, "right");
Expand Down
6 changes: 3 additions & 3 deletions examples/js/string-splitting.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ var pageWidth = 8.5,
// splitTextToSize takes your string and turns it in to an array of strings,
// each of which can be displayed within the specified maxLineWidth.
var textLines = doc
.setFont("helvetica", "neue")
.setFont("helvetica")
.setFontSize(fontSize)
.splitTextToSize(text, maxLineWidth);

// doc.text can now add those lines easily; otherwise, it would have run text off the screen!
doc.text(textLines, margin, margin + 2 * oneLineHeight);

// You can also calculate the height of the text very simply:
var textHeight = (textLines.length * fontSize * lineHeight) / ptsPerInch;
doc
.setFontStyle("bold")
.setFont("Helvetica", "bold")
.text(
"Text Height: " + textHeight + " inches",
margin,
Expand Down