Pdf-lib: Page rotation?

Created on 4 Jun 2019  路  2Comments  路  Source: Hopding/pdf-lib

I went through the documentation and source code. It seems we can't do page rotation right now. Is my understanding correct?

Most helpful comment

Hello @qingxiang-jia!

Page rotation is not currently documented, but it is certainly possible to do. It's quite straightforward:

import { PDFNumber } from 'pdf-lib';

const pdfDoc = ...
const firstPage = pdfDoc.getPages()[0];

// Rotate the first page by 180 degrees
firstPage.set('Rotate', PDFNumber.fromNumber(180));

Please let me know if you have any further questions!

All 2 comments

Hello @qingxiang-jia!

Page rotation is not currently documented, but it is certainly possible to do. It's quite straightforward:

import { PDFNumber } from 'pdf-lib';

const pdfDoc = ...
const firstPage = pdfDoc.getPages()[0];

// Rotate the first page by 180 degrees
firstPage.set('Rotate', PDFNumber.fromNumber(180));

Please let me know if you have any further questions!

Thank you for the help. That's great to know!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msvargas picture msvargas  路  6Comments

DanielJackson-Oslo picture DanielJackson-Oslo  路  3Comments

fatso83 picture fatso83  路  3Comments

MarcGodard picture MarcGodard  路  3Comments

sdfereday picture sdfereday  路  4Comments