From 1f6751d0e3d89ec6de9d8484ab8faef6037f849b Mon Sep 17 00:00:00 2001 From: Bj Tecu Date: Mon, 4 Jan 2021 22:17:56 -0500 Subject: [PATCH] Rotate in place when flattening --- src/api/form/PDFForm.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/api/form/PDFForm.ts b/src/api/form/PDFForm.ts index 1b6684ca7..f2151b157 100644 --- a/src/api/form/PDFForm.ts +++ b/src/api/form/PDFForm.ts @@ -15,14 +15,13 @@ import { } from 'src/api/errors'; import PDFFont from 'src/api/PDFFont'; import { StandardFonts } from 'src/api/StandardFonts'; +import { rotateInPlace } from 'src/api/operations'; import { drawObject, popGraphicsState, pushGraphicsState, - rotateRadians, translate, } from 'src/api/operators'; -import { degrees, toRadians } from 'src/api/rotations'; import { PDFAcroForm, PDFAcroField, @@ -583,14 +582,12 @@ export default class PDFForm { const xObjectKey = addRandomSuffix('FlatWidget', 10); page.node.setXObject(PDFName.of(xObjectKey), refOrDict); - const ap = widget.getAppearanceCharacteristics(); const rectangle = widget.getRectangle(); - const rotation = degrees(ap?.getRotation() ?? 0); const operators = [ pushGraphicsState(), translate(rectangle.x, rectangle.y), - rotateRadians(toRadians(rotation)), + ...rotateInPlace({ ...rectangle, rotation: 0 }), drawObject(xObjectKey), popGraphicsState(), ].filter(Boolean) as PDFOperator[];