}
page *process_page(page *p) override
{
- pdf_matrix m;
- switch (deg)
- {
- case 0:
- break;
- case 90:
- m.rotate_deg(-90);
- m.shift(0, p->width);
- break;
- case 180:
- m.rotate_deg(180);
- m.shift(p->width, p->height);
- break;
- case 270:
- m.rotate_deg(90);
- m.shift(p->height, 0);
- break;
- default:
- abort();
- }
- return new xform_page(p, m);
+ return new xform_page(p, pdf_rotation_matrix(deg, p->width, p->height));
}
};
/*
* Auxiliary functions for processing PDF files
*
- * (c) 2018 Martin Mares <mj@ucw.cz>
+ * (c) 2018--2022 Martin Mares <mj@ucw.cz>
*/
#include <cstdio>
buf[--n] = 0;
return buf;
}
+
+/*** Rotation matrix construction ***/
+
+pdf_matrix pdf_rotation_matrix(int deg, double width, double height)
+{
+ pdf_matrix m;
+ switch (deg) {
+ case 0:
+ break;
+ case 90:
+ m.rotate_deg(-90);
+ m.shift(0, width);
+ break;
+ case 180:
+ m.rotate_deg(180);
+ m.shift(width, height);
+ break;
+ case 270:
+ m.rotate_deg(90);
+ m.shift(height, 0);
+ break;
+ default:
+ abort();
+ }
+ return m;
+}
QPDFObjectHandle unicode_string(std::string s);
QPDFObjectHandle page_to_xobject(QPDF *out, QPDFObjectHandle page);
string pdf_coord(double x, uint digits=1);
+pdf_matrix pdf_rotation_matrix(int deg, double width, double height);
#endif