]> mj.ucw.cz Git - paperjam.git/blobdiff - pdf.cc
TODO
[paperjam.git] / pdf.cc
diff --git a/pdf.cc b/pdf.cc
index 8f46d1674c5ecf112583f9955026058c2a008015..ff7a8b03aa4578c9bf9a11ab658e48d136befccc 100644 (file)
--- a/pdf.cc
+++ b/pdf.cc
@@ -7,6 +7,7 @@
 #include <cassert>
 #include <cstdlib>
 #include <cstdio>
+#include <cstring>
 #include <unistd.h>
 #include <sys/wait.h>
 
@@ -30,6 +31,7 @@ class in_page : public page {
 public:
   BBox media_box;
   void render(out_context *out, pdf_matrix xform);
+  void debug_dump() { debug("Input page %d", index); }
   in_page(QPDFObjectHandle inpg, int idx);
 };
 
@@ -79,10 +81,19 @@ void debug_pages(vector<page *> &pages)
     return;
 
   for (auto pg: pages)
-    debug("Page #%d: media[%.3f %.3f] image[%.3f %.3f %.3f %.3f]",
-      pg->index,
-      pg->width, pg->height,
-      pg->image_box.x_min, pg->image_box.y_min, pg->image_box.x_max, pg->image_box.y_max);
+    {
+      debug("Page #%d: media[%.3f %.3f] image[%.3f %.3f %.3f %.3f][%.3f %.3f]",
+       pg->index,
+       pg->width, pg->height,
+       pg->image_box.x_min, pg->image_box.y_min, pg->image_box.x_max, pg->image_box.y_max,
+       pg->image_box.width(), pg->image_box.height());
+      if (debug_level > 2)
+       {
+         debug_indent += 4;
+         pg->debug_dump();
+         debug_indent -= 4;
+       }
+    }
 }
 
 vector<page *> run_command_list(list<cmd *> &cmds, vector<page *> &pages)
@@ -158,8 +169,18 @@ void process(list<cmd *> &cmds)
   pages = run_command_list(cmds, pages);
 
   debug("### Writing output");
+  int out_page = 0;
   for (auto pg: pages)
     {
+      ++out_page;
+      if (debug_level > 1)
+       {
+         debug("Page #%d", out_page);
+         debug_indent += 4;
+         pg->debug_dump();
+         debug_indent -= 4;
+       }
+
       out_context out;
       out.pdf = &out_pdf;
       out.resources = QPDFObjectHandle::newDictionary();