965
965
n = fread(buf, 1, sizeof(buf) - 1, file);
967
967
type = guess_file_type(buf, n, &startpos);
968
/* We do not use any JCL preceeded to the inputr data, as it is simply
969
the PJL commands from the PPD file, and these commands we can also
970
generate, end we even merge them with PJl from the driver */
971
/*if (startpos > 0) {
970
973
write_output(buf, startpos);
972
975
if (file != stdin)
983
986
char pdf2ps_cmd[PATH_MAX];
985
988
int renderer_pid;
989
char tmpfilename[PATH_MAX] = "";
987
991
_log("Driver does not understand PDF input, "
988
992
"converting to PostScript\n");
990
994
pdfconvertedtops = 1;
996
/* If reading from stdin, write everything into a temporary file */
1002
snprintf(tmpfilename, PATH_MAX, "%s/foomatic-XXXXXX", temp_dir());
1003
fd = mkstemp(tmpfilename);
1005
_log("Could not create temporary file: %s\n", strerror(errno));
1006
return EXIT_PRNERR_NORETRY_BAD_SETTINGS;
1008
tmpfile = fdopen(fd, "r+");
1009
copy_file(tmpfile, stdin, buf, n);
1012
filename = tmpfilename;
991
1015
snprintf(pdf2ps_cmd, PATH_MAX,
1016
"pdftops -level2 -origpagesizes %s - 2>/dev/null || "
992
1017
"gs -q -sstdout=%%stderr -sDEVICE=pswrite -sOutputFile=- "
993
"-dBATCH -dNOPAUSE -dPARANOIDSAFER %s",
994
file == stdin ? "-" : filename);
1018
"-dBATCH -dNOPAUSE -dPARANOIDSAFER %s 2>/dev/null",
1019
filename, filename);
996
1021
renderer_pid = start_system_process("pdf-to-ps", pdf2ps_cmd, &in, &out);
1000
fwrite(buf, 1, n, in);
1001
while ((n = fread(buf, 1, sizeof(buf), file)))
1002
fwrite(buf, 1, n, in);
1006
1023
if (dup2(fileno(out), fileno(stdin)) < 0)
1007
1024
rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS,
1008
1025
"Couldn't dup stdout of pdf-to-ps\n");
1192
1209
spooler = SPOOLER_LPRNG;
1193
1210
if ((str = strstr(getenv("PRINTCAP_ENTRY"), "ppd=")))
1195
else if ((str = strstr(getenv("PRINTCAP_ENTRY"), "ppdfile=")));
1212
else if ((str = strstr(getenv("PRINTCAP_ENTRY"), "ppdfile=")))
1198
1215
while (isspace(*str)) str++;
1199
1216
p = job->ppdfile;
1200
while (*str != '\0' && !isspace(*str) && *str != '\n') {
1217
while (*str != '\0' && !isspace(*str) && *str != '\n' &&
1201
1219
if (isprint(*str) && strchr(shellescapes, *str) == NULL)