/*
- * "$Id: pstops.c 7006 2007-10-04 17:43:38Z mike $"
+ * "$Id: pstops.c 7689 2008-06-24 20:50:57Z mike $"
*
* PostScript filter for the Common UNIX Printing System (CUPS).
*
int level; /* Embedded document level */
pstops_page_t *pageinfo; /* Page information */
int first_page; /* First page on N-up output? */
+ int has_page_setup; /* Does the page have %%Begin/EndPageSetup? */
int bounding_box[4]; /* PageBoundingBox */
if (first_page)
doc_puts(doc, "%%BeginPageSetup\n");
- if (!strncmp(line, "%%BeginPageSetup", 16))
+ if ((has_page_setup = !strncmp(line, "%%BeginPageSetup", 16)) != 0)
{
int feature = 0; /* In a Begin/EndFeature block? */
else if (!strncmp(line, "%%Include", 9))
continue;
+ if (line[0] != '%' && !feature)
+ break;
+
if (!feature || (doc->number_up == 1 && !doc->fitplot))
doc_write(doc, line, linelen);
}
* Skip %%EndPageSetup...
*/
- if (linelen > 0)
- linelen = cupsFileGetLine(fp, line, linesize);
+ if (linelen > 0 && !strncmp(line, "%%EndPageSetup", 14))
+ {
+ linelen = cupsFileGetLine(fp, line, linesize);
+ has_page_setup = 0;
+ }
}
if (first_page)
* Finish the PageSetup section as needed...
*/
+ if (has_page_setup)
+ {
+ int feature = 0; /* In a Begin/EndFeature block? */
+
+ doc_write(doc, line, linelen);
+
+ while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
+ {
+ if (!strncmp(line, "%%EndPageSetup", 14))
+ break;
+ else if (!strncmp(line, "%%BeginFeature:", 15))
+ {
+ feature = 1;
+
+ if (doc->number_up > 1 || doc->fitplot)
+ continue;
+ }
+ else if (!strncmp(line, "%%EndFeature", 12))
+ {
+ feature = 0;
+
+ if (doc->number_up > 1 || doc->fitplot)
+ continue;
+ }
+ else if (!strncmp(line, "%%Include", 9))
+ continue;
+
+ if (!feature || (doc->number_up == 1 && !doc->fitplot))
+ doc_write(doc, line, linelen);
+ }
+
+ /*
+ * Skip %%EndPageSetup...
+ */
+
+ if (linelen > 0 && !strncmp(line, "%%EndPageSetup", 14))
+ linelen = cupsFileGetLine(fp, line, linesize);
+ }
+
if (first_page)
doc_puts(doc, "%%EndPageSetup\n");
/*
- * End of "$Id: pstops.c 7006 2007-10-04 17:43:38Z mike $".
+ * End of "$Id: pstops.c 7689 2008-06-24 20:50:57Z mike $".
*/