diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-05-23 14:00:27 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-05-23 14:00:27 +0000 |
| commit | acc2deba308bb4746d5a48f5b19f5a40b63f0cdd (patch) | |
| tree | a4f86023a24ee22e6987549d6bc4858a8cdda7a7 | |
| parent | 64b8c4d982634f6f342b4a7cf8323960d2cbc1a2 (diff) | |
| download | halibut-acc2deba308bb4746d5a48f5b19f5a40b63f0cdd.zip halibut-acc2deba308bb4746d5a48f5b19f5a40b63f0cdd.tar.gz halibut-acc2deba308bb4746d5a48f5b19f5a40b63f0cdd.tar.bz2 halibut-acc2deba308bb4746d5a48f5b19f5a40b63f0cdd.tar.xz | |
Stop the PDF backend from crashing if no outline elements appear. It
still doesn't _work_ properly if there aren't any contents entries,
but it's a start.
[originally from svn r4250]
| -rw-r--r-- | bk_pdf.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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]; |