2 * PaperJam -- Main program
4 * (c) 2018--2022 Martin Mares <mj@ucw.cz>
20 bool no_auto_transforms;
26 void debug(const char *msg, ...)
32 fprintf(stderr, "%*s", debug_indent, "");
33 vfprintf(stderr, msg, args);
38 void warn(const char *msg, ...)
42 fprintf(stderr, "Warning: ");
43 vfprintf(stderr, msg, args);
48 void die(const char *msg, ...)
52 vfprintf(stderr, msg, args);
58 void err(const char *msg, ...)
63 vsnprintf(buf, sizeof(buf), msg, args);
65 throw paperjam_error(buf);
76 static const struct option long_opts[] = {
77 { "debug", 0, 0, 'd' },
78 { "help", 0, 0, OPT_HELP },
79 { "version", 0, 0, OPT_VERSION },
80 { "bbox", 0, 0, 'b' },
84 static const char short_opts[] = "bd";
88 printf("Usage: paperjam [<options>] <commands> <in> <out>\n\
91 -b, --bbox Recalculate bounding boxes\n\
92 -d, --debug Show debugging messages\n\
93 --no-auto Disable automatic rotation of pages\n\
95 <command> = <name>(<args>, <named-arg>[=<value>], ...) [<pipeline>]\n\
96 <pipeline> = { <stage>, <stage>, ... }\n\
97 <stage> = <page> <page> ... [: <commands>]\n\
100 paperjam 'book nup(2, paper=a4)' input.pdf output.pdf\n\
107 static void show_version()
109 printf("PaperJam " VERSION " -- a PDF processor\n");
110 printf("(c) " YEAR " Martin Mares, distributed under GNU GPL 2+\n");
111 printf("Built on " BUILD_DATE " from Git commit " BUILD_COMMIT "\n");
114 int main(int argc, char **argv)
117 while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) >= 0)
133 no_auto_transforms = true;
139 if (optind + 3 != argc)
140 die("Exactly three positional parameters should be given");
143 parse(argv[optind], cmds);
144 in_name = argv[optind+1];
145 out_name = argv[optind+2];