X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/blobdiff_plain/ce1b04aa897271ca864aaeffe2225b6a211e526d..56a99eb648cb255aed42d929823a07913e0d743a:/bk_pdf.c diff --git a/bk_pdf.c b/bk_pdf.c index fa5262a..6aba554 100644 --- a/bk_pdf.c +++ b/bk_pdf.c @@ -76,7 +76,10 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords, olist.number = 1; cat = new_object(&olist); - outlines = new_object(&olist); + if (doc->n_outline_elements > 0) + outlines = new_object(&olist); + else + outlines = NULL; pages = new_object(&olist); resources = new_object(&olist); @@ -84,11 +87,16 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords, * The catalogue just contains references to the outlines and * pages objects. */ - objtext(cat, "<<\n/Type /Catalog\n/Outlines "); - objref(cat, outlines); + objtext(cat, "<<\n/Type /Catalog"); + if (outlines) { + objtext(cat, "\n/Outlines "); + objref(cat, outlines); + } objtext(cat, "\n/Pages "); objref(cat, pages); - objtext(cat, "\n/PageMode /UseOutlines\n>>\n"); + if (outlines) + objtext(cat, "\n/PageMode /UseOutlines"); + objtext(cat, "\n>>\n"); /* * Set up the resources dictionary, which mostly means @@ -349,7 +357,7 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords, /* * Set up the outlines dictionary. */ - { + if (outlines) { int topcount; char buf[80]; @@ -456,7 +464,7 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords, static object *new_object(objlist *list) { - object *obj = mknew(object); + object *obj = snew(object); obj->list = list;