/*** Basic macros and constants ***/
-#define UNUSED __attribute__((unused))
-#define FORMAT_CHECK(x,y,z) __attribute__((format(x,y,z)))
-#define NONRET __attribute__((noreturn))
-
#define A4_WIDTH 595
#define A4_HEIGHT 842
static const double mm = 72/25.4;
-/*** Messages ***/
-
-void debug(const char *msg, ...) FORMAT_CHECK(printf, 1, 2);
-void warn(const char *msg, ...) FORMAT_CHECK(printf, 1, 2);
-void die(const char *msg, ...) FORMAT_CHECK(printf, 1, 2) NONRET;
-void bad(const char *msg, ...) FORMAT_CHECK(printf, 1, 2) NONRET;
-
-extern int debug_mode;
-extern int debug_indent;
-
/*** Transformation matrices ***/
struct pdf_matrix {
m[5] = f;
}
+ void apply(double *px, double *py)
+ {
+ double x=*px, y=*py;
+ *px = m[0]*x + m[2]*y + m[4];
+ *py = m[1]*x + m[3]*y + m[5];
+ }
+
// A*B is a matrix which transforms first by A and then by B
pdf_matrix operator *(pdf_matrix y)
{
x_min = 0, x_max = x;
y_min = 0, y_max = y;
}
- BBox(QPDFObjectHandle box) {
- if (!parse(box)) {
- warn("Invalid bounding box, falling back to A4");
- x_min = 0, x_max = A4_WIDTH;
- y_min = 0, y_max = A4_HEIGHT;
- }
- }
+ BBox(QPDFObjectHandle box);
QPDFObjectHandle to_array();
+ string to_rect();
double width() { return x_max - x_min; }
double height() { return y_max - y_min; }
+ void transform(pdf_matrix &m);
+ void join(BBox &with);
private:
bool parse(QPDFObjectHandle h);
};
QPDFObjectHandle page_to_xobject(QPDF *out, QPDFObjectHandle page);
#endif
-