cantoo-scribe / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
124 stars 24 forks source link

fix drawRectangle to handle rotation correctly #62

Closed MatheusrdSantos closed 1 month ago

MatheusrdSantos commented 1 month ago

What?

Fix drawRectangle to handle rotation correctly

Why?

to fix the issue reported here: https://github.com/cantoo-scribe/pdf-lib/issues/61

How?

Testing?

const fs = require('fs');
const pdf = require('@cantoo/pdf-lib');
run();
async function run() {
    const doc = await pdf.PDFDocument.create();
    const page = doc.addPage();
    page.drawRectangle({x: 20, y: 200, width: 100, height: 50, rotate: pdf.degrees(45)});
    fs.writeFileSync('bugreport.pdf', await doc.save());
}

New Dependencies?

Screenshots

before(left) and after(right) image