Skip to content

Commit

Permalink
Update version to 0.15.2
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Dec 17, 2024
1 parent ec49332 commit 15d4083
Show file tree
Hide file tree
Showing 2 changed files with 65,893 additions and 73,312 deletions.
41 changes: 38 additions & 3 deletions demo/browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var PDFDocument = require('../');
var PDFDocument = require('../..');
var blobStream = require('blob-stream');
var ace = require('brace');
require('brace/mode/javascript');
Expand Down Expand Up @@ -33,9 +33,36 @@ function makePDF(PDFDocument, blobStream, lorem, iframe) {
.fill('red', 'even-odd')
.restore();

doc.save();
// a gradient fill
var gradient = doc
.linearGradient(100, 300, 200, 300)
.stop(0, 'green')
.stop(0.5, 'red')
.stop(1, 'green');
doc.rect(100, 300, 100, 100).fill(gradient);

// stroke & fill uncolored tiling pattern

var stripe45d = doc.pattern(
[1, 1, 4, 4],
3,
3,
'1 w 0 1 m 4 5 l s 2 0 m 5 3 l s'
);
doc.circle(280, 350, 50).fill([stripe45d, 'blue']);

doc
.rect(380, 300, 100, 100)
.fillColor('lime')
.strokeColor([stripe45d, 'orange'])
.lineWidth(5)
.fillAndStroke();
doc.restore();

// and some justified text wrapped into columns
doc
.text('And here is some wrapped text...', 100, 300)
.text('And here is some wrapped text...', 100, 450)
.font('Times-Roman', 13)
.moveDown()
.text(lorem, {
Expand Down Expand Up @@ -73,16 +100,24 @@ editor
var iframe = document.querySelector('iframe');
makePDF(PDFDocument, blobStream, lorem, iframe);

let debounceTimeout;

editor.getSession().on('change', function() {
try {
if (debounceTimeout) {
clearTimeout(debounceTimeout);
}
var fn = new Function(
'PDFDocument',
'blobStream',
'lorem',
'iframe',
editor.getValue()
);
fn(PDFDocument, blobStream, lorem, iframe);
debounceTimeout = setTimeout(() => {
fn(PDFDocument, blobStream, lorem, iframe);
debounceTimeout = undefined;
}, 100);
} catch (e) {
console.log(e);
}
Expand Down
Loading

0 comments on commit 15d4083

Please sign in to comment.