pdf_matrix xform;
public:
void render(out_context *out, pdf_matrix xform) override;
+ void debug_dump() override
+ {
+ debug("Transform [%s]", xform.to_string().c_str());
+ orig_page->debug_dump();
+ }
xform_page(page *p, pdf_matrix xf);
};
out->contents += page_cm->pdf_stream(out, page_bbox, xform);
out->contents += image_cm->pdf_stream(out, image_box, xform);
}
+ void debug_dump() override
+ {
+ debug("Draw debugging boxes");
+ orig_page->debug_dump();
+ }
};
class debug_cmd : public cmd_exec_simple {
for (auto p: orig_pages)
p->render(out, xform);
}
+ void debug_dump() override
+ {
+ debug("Merge pages");
+ debug_indent += 4;
+ for (auto p: orig_pages)
+ p->debug_dump();
+ debug_indent -= 4;
+ }
};
vector<page *> merge_cmd::process(vector<page *> &pages)
cropmark_spec *cmarks;
void render(out_context *out, pdf_matrix xform) override;
nup_page(nup_state &st) : page(st.paper_w, st.paper_h) { }
+ void debug_dump() override
+ {
+ debug("N-up printing");
+ debug_indent += 4;
+ for (auto p: orig_pages)
+ p->debug_dump();
+ debug_indent -= 4;
+ }
};
void nup_page::render(out_context *out, pdf_matrix parent_xform)
orig_page->render(out, xform);
out->contents += cm->pdf_stream(out, image_box, xform);
}
+ void debug_dump() override
+ {
+ debug("Add cropmarks");
+ orig_page->debug_dump();
+ }
cropmarks_page(page *p, cropmark_spec *cms) : page(p), orig_page(p), cm(cms) { }
};
orig_page->render(out, xform);
out->contents += "Q ";
}
+ void debug_dump() override
+ {
+ debug("Clip [%.3f %.3f %.3f %.3f]", clip_to.x_min, clip_to.y_min, clip_to.x_max, clip_to.y_max);
+ orig_page->debug_dump();
+ }
clip_page(page *p, BBox &to) : page(p), orig_page(p), clip_to(to) { }
};
return is_zero(x-y);
}
+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;
+
+// This one is called during execution of commands and propagated as an exception
+void err(const char *msg, ...) FORMAT_CHECK(printf, 1, 2) NONRET;
+
#include "pdf-tools.h"
/*** Representation of commands ***/
double height;
BBox image_box; // Bounds useful contents
virtual void render(out_context *out UNUSED, pdf_matrix xform UNUSED) { abort(); }
+ virtual void debug_dump() = 0;
page(double _w=0, double _h=0) : index(0), width(_w), height(_h), image_box() { }
page(page *p)
{
struct empty_page : public page {
void render(out_context *out UNUSED, pdf_matrix xform UNUSED) { }
+ void debug_dump() { debug("Empty page"); }
empty_page(double _w=0, double _h=0) : page(_w, _h) { };
};
extern int debug_level;
extern int debug_indent;
-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;
-
-// This one is called during execution of commands and propagated as an exception
-void err(const char *msg, ...) FORMAT_CHECK(printf, 1, 2) NONRET;
-
class paperjam_error : public exception {
string message;
public:
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);
};
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)
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();