- ps_printf(p, "endstream\n");
- ps_printf(p, "endobj\n");
- ps_printf(p, "%zu 0 obj\n",
- p->engine.ps.pdfbody +
- (p->engine.ps.pages + 1) * 4 + 1);
- ps_printf(p, "%zu\n", len);
- ps_printf(p, "endobj\n");
- ps_printf(p, "%zu 0 obj\n",
- p->engine.ps.pdfbody +
- (p->engine.ps.pages + 1) * 4 + 2);
- ps_printf(p, "<<\n");
- ps_printf(p, "/ProcSet [/PDF /Text]\n");
+ base = p->engine.ps.pages * 4 + p->engine.ps.pdfbody;
+
+ ps_printf(p, "endstream\nendobj\n");
+
+ /* Length of content. */
+ pdf_obj(p, base + 1);
+ ps_printf(p, "%zu\nendobj\n", len);
+
+ /* Resource for content. */
+ pdf_obj(p, base + 2);
+ ps_printf(p, "<<\n/ProcSet [/PDF /Text]\n");