Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial PDF 1.4 support (embedded in core) #920

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 63 additions & 0 deletions examples/pdf_1_4/blend_modes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">
<script src="../../jspdf.js"></script>
<script src="../../libs/css_colors.js"></script>
<script src="../../plugins/canvas.js"></script>
<script src="../../plugins/context2d.js"></script>
<head>
<meta charset="UTF-8">
<title>jsPDF Blend Modes</title>
</head>
<body>
<h1>jsPDF Blend Modes</h1>
<iframe id='result' style='width: 100%; height:8in'></iframe>
<div id='source' style='width: 100%'></div>
<script>
var makePdf = function () {
var pdf = new jsPDF({
pdfVersion: '1.4',
orientation: 'p',
unit: 'pt',
format: 'a4'
});

var c = pdf.canvas.getContext('2d');

var lineHeight = 60;
var lineWidth = 200;
var cols = 2;
var index = 0;

pdf.internal.v_1_4.pdfBlendModes.forEach(function (mode) {
c.save();
var x = 50 + (index % cols) * lineWidth;
var y = 30 + (Math.floor(index / cols)) * lineHeight;

c.fillText(mode, x + 35, y);

c.beginPath();
c.arc(x, y, 20, 0, 2 * Math.PI, false);
c.fillStyle = 'blue';
c.fill();

c.globalCompositeOperation = mode.toLowerCase();

c.beginPath();
c.arc(x + 10, y + 10, 20, 0, 2 * Math.PI, false);
c.fillStyle = 'yellow';
c.fill();

c.restore();
index++;
});

return pdf;

console.log(pdf.newObject2List);
};

document.getElementById('result').setAttribute('src', makePdf().output('dataurlstring'));
document.getElementById('source').innerText = makePdf().output();
</script>
</body>
</html>