2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-23 03:18:59 +00:00
qpdf/examples/qpdfjob-c.c
Jay Berkenbilt cb769c62e5 WHITESPACE ONLY -- expand tabs in source code
This comment expands all tabs using an 8-character tab-width. You
should ignore this commit when using git blame or use git blame -w.

In the early days, I used to use tabs where possible for indentation,
since emacs did this automatically. In recent years, I have switched
to only using spaces, which means qpdf source code has been a mixture
of spaces and tabs. I have avoided cleaning this up because of not
wanting gratuitous whitespaces change to cloud the output of git
blame, but I changed my mind after discussing with users who view qpdf
source code in editors/IDEs that have other tab widths by default and
in light of the fact that I am planning to start applying automatic
code formatting soon.
2022-02-08 11:51:15 -05:00

63 lines
1.2 KiB
C

/*
* This is an example program to linearize a PDF file using the C
* QPDFJob API.
*/
#include <qpdf/qpdfjob-c.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char const* whoami = 0;
static void usage()
{
fprintf(stderr, "Usage: %s infile outfile\n", whoami);
exit(2);
}
int main(int argc, char* argv[])
{
char* infile = NULL;
char* outfile = NULL;
char const* new_argv[6];
int r = 0;
char* p = 0;
if ((p = strrchr(argv[0], '/')) != NULL)
{
whoami = p + 1;
}
else if ((p = strrchr(argv[0], '\\')) != NULL)
{
whoami = p + 1;
}
else
{
whoami = argv[0];
}
if (argc != 3)
{
usage();
}
infile = argv[1];
outfile = argv[2];
new_argv[0] = "qpdfjob";
new_argv[1] = infile;
new_argv[2] = outfile;
new_argv[3] = "--linearize";
new_argv[4] = "--static-id"; /* for testing only */
new_argv[5] = NULL;
/* See qpdf-job.cc for a C++ example of using the json interface.
* To use that from C just like the argv one, call
* qpdfjob_run_from_json instead and pass the json string as a
* single char const* argument.
*/
r = qpdfjob_run_from_argv(new_argv);
return r;
}