]> mj.ucw.cz Git - paperjam.git/blobdiff - pdf-tools.h
Cropmarks mark=bg
[paperjam.git] / pdf-tools.h
index 9563ec024ceb132c7a1fb457b83f04c8b61bada6..0225e9c457f951806aa07129c9a692ab55856f9e 100644 (file)
 
 /*** Basic macros and constants ***/
 
 
 /*** 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;
 
 #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 {
 /*** Transformation matrices ***/
 
 struct pdf_matrix {
@@ -137,18 +123,14 @@ struct BBox {
                x_min = 0, x_max = x;
                y_min = 0, y_max = 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);
        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);
+       BBox transformed(pdf_matrix &m);
+       void join(BBox &with);
 private:
        bool parse(QPDFObjectHandle h);
 };
 private:
        bool parse(QPDFObjectHandle h);
 };
@@ -157,6 +139,6 @@ private:
 
 QPDFObjectHandle unicode_string(std::string s);
 QPDFObjectHandle page_to_xobject(QPDF *out, QPDFObjectHandle page);
 
 QPDFObjectHandle unicode_string(std::string s);
 QPDFObjectHandle page_to_xobject(QPDF *out, QPDFObjectHandle page);
+string pdf_coord(double x, uint digits=1);
 
 #endif
 
 #endif
-