shithub: pdffs

Download patch

ref: 838c584a7ad08d8650ea8204e3f069fd8adf96ce
parent: 46d81647ed29df0395eed990b8bfcbbc929c8d2b
author: Noam Preil <noam@pixelhero.dev>
date: Wed Apr 20 18:05:26 EDT 2022

ctm: CropBox defaults to MediaBox

--- a/op.c
+++ b/op.c
@@ -1361,6 +1361,15 @@
 	page->TS.y = 0;
 }
 
+Object*
+pagecropbox(Page *p)
+{
+	Object *o = dictget(p->obj, "CropBox");
+	if(o == &null)
+		o = dictget(p->obj, "MediaBox");
+	return o;
+}
+
 void
 ctminit(Page *p, double *ctm)
 {
@@ -1367,8 +1376,7 @@
 	Object *cropbox;
 	double mx, my;
 	matidentity(ctm);
-	if((cropbox = dictget(p->obj, "CropBox")) == nil)
-		return;
+	cropbox = pagecropbox(p);
 	mx = arrayget(cropbox, 2)->num.d;
 	my = arrayget(cropbox, 3)->num.d;
 	ctm[0] = 850 / mx;