summaryrefslogtreecommitdiff
path: root/bk_pdf.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-04-15 08:50:04 +0000
committerSimon Tatham <anakin@pobox.com>2004-04-15 08:50:04 +0000
commit8100588592f8c84f049870a17e6401646378dc5f (patch)
tree8710d36de61e21c3a4d4accf8fad70ebf00cd5dd /bk_pdf.c
parent8603d13eb7651e7721e421750202344f0ced55a7 (diff)
downloadhalibut-8100588592f8c84f049870a17e6401646378dc5f.zip
halibut-8100588592f8c84f049870a17e6401646378dc5f.tar.gz
halibut-8100588592f8c84f049870a17e6401646378dc5f.tar.bz2
halibut-8100588592f8c84f049870a17e6401646378dc5f.tar.xz
Put the document's version IDs into comments in the PS and PDF
output files. [originally from svn r4079]
Diffstat (limited to 'bk_pdf.c')
-rw-r--r--bk_pdf.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/bk_pdf.c b/bk_pdf.c
index b68598c..fe10894 100644
--- a/bk_pdf.c
+++ b/bk_pdf.c
@@ -62,6 +62,7 @@ static void make_pages_node(object *node, object *parent, page_data *first,
page_data *last, object *resources);
static int make_outline(object *parent, outline_element *start, int n,
int open);
+static int pdf_versionid(FILE *fp, word *words);
void pdf_backend(paragraph *sourceform, keywordlist *keywords,
indexdata *idx, void *vdoc) {
@@ -372,9 +373,13 @@ void pdf_backend(paragraph *sourceform, keywordlist *keywords,
}
/*
- * Header
+ * Header. I'm going to put the version IDs in the header as
+ * well, simply in PDF comments.
*/
fileoff = fprintf(fp, "%%PDF-1.3\n");
+ for (p = sourceform; p; p = p->next)
+ if (p->type == para_VersionID)
+ fileoff += pdf_versionid(fp, p->words);
/*
* Body
@@ -660,3 +665,47 @@ static int make_outline(object *parent, outline_element *items, int n,
return totalcount;
}
+
+static int pdf_versionid(FILE *fp, word *words)
+{
+ int ret;
+
+ ret = fprintf(fp, "%% ");
+
+ for (; words; words = words->next) {
+ char *text;
+ int type;
+
+ switch (words->type) {
+ case word_HyperLink:
+ case word_HyperEnd:
+ case word_UpperXref:
+ case word_LowerXref:
+ case word_XrefEnd:
+ case word_IndexRef:
+ continue;
+ }
+
+ type = removeattr(words->type);
+
+ switch (type) {
+ case word_Normal:
+ text = utoa_dup(words->text);
+ break;
+ case word_WhiteSpace:
+ text = dupstr(" ");
+ break;
+ case word_Quote:
+ text = dupstr("'");
+ break;
+ }
+
+ fputs(text, fp);
+ ret += strlen(text);
+ sfree(text);
+ }
+
+ ret += fprintf(fp, "\n");
+
+ return ret;
+}