+ if (TERMTYPE_PS == p->type) {
+ ps_printf(p, "%%%%Trailer\n");
+ ps_printf(p, "%%%%Pages: %zu\n", p->engine.ps.pages);
+ ps_printf(p, "%%%%EOF\n");
+ return;
+ }
+
+ ps_printf(p, "2 0 obj\n");
+ ps_printf(p, "<<\n");
+ ps_printf(p, "/Type /Pages\n");
+ ps_printf(p, "/MediaBox [0 0 %zu %zu]\n",
+ (size_t)AFM2PNT(p, p->engine.ps.width),
+ (size_t)AFM2PNT(p, p->engine.ps.height));
+
+ ps_printf(p, "/Count %zu\n", p->engine.ps.pages);
+ ps_printf(p, "/Kids [");
+
+ for (i = 0; i < p->engine.ps.pages; i++)
+ ps_printf(p, " %zu 0 R",
+ p->engine.ps.pdfbody +
+ (i + 1) * 4 + 3);
+ ps_printf(p, "]\n");
+ ps_printf(p, ">>\n");
+ ps_printf(p, "endobj\n");
+ ps_printf(p, "%zu 0 obj\n",
+ p->engine.ps.pdfbody +
+ (p->engine.ps.pages * 4) + 4);
+ ps_printf(p, "<<\n");
+ ps_printf(p, "/Type /Catalog\n");
+ ps_printf(p, "/Pages 2 0 R\n");
+ ps_printf(p, ">>\n");
+ xref = p->engine.ps.pdfbytes;
+ ps_printf(p, "xref\n");
+ ps_printf(p, "0 %zu\n",
+ p->engine.ps.pdfbody +
+ (p->engine.ps.pages * 4) + 5);
+ ps_printf(p, "0000000000 65535 f\n");
+ ps_printf(p, "trailer\n");
+ ps_printf(p, "<<\n");
+ ps_printf(p, "/Size %zu\n",
+ p->engine.ps.pdfbody +
+ (p->engine.ps.pages * 4) + 5);
+ ps_printf(p, "/Root %zu 0 R\n",
+ p->engine.ps.pdfbody +
+ (p->engine.ps.pages * 4) + 4);
+ ps_printf(p, "/Info 1 0 R\n");
+ ps_printf(p, ">>\n");
+ ps_printf(p, "startxref\n");
+ ps_printf(p, "%zu\n", xref);
+ ps_printf(p, "%%%%EOF\n");