File: pdfutils.h

package info (click to toggle)
cups-filters 1.28.17-3%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,096 kB
  • sloc: ansic: 54,489; cpp: 7,023; sh: 1,911; makefile: 963; xml: 127; perl: 73; php: 28; python: 8
file content (80 lines) | stat: -rw-r--r-- 1,902 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 *   PDF file output routines.
 *
 *   Copyright 2008 by Tobias Hoffmann.
 *
 *   This file is licensed as noted in "COPYING" 
 *   which should have been included with this file.
 *
 */
#include <time.h>

struct keyval_t {
  char *key,*value;
};

typedef struct {
  long filepos;

  int pagessize,pagesalloc;
  int *pages;

  int xrefsize,xrefalloc;
  long *xref;

  int kvsize,kvalloc;
  struct keyval_t *kv;
} pdfOut;

/* allocates a new pdfOut structure
 * returns NULL on error
 */
pdfOut *pdfOut_new();
void pdfOut_free(pdfOut *pdf);

/* start outputting a pdf
 * returns false on error
 */
int pdfOut_begin_pdf(pdfOut *pdf);
void pdfOut_finish_pdf(pdfOut *pdf);

/* General output routine for our pdf.
 * Keeps track of characters actually written out
 */
void pdfOut_printf(pdfOut *pdf,const char *fmt,...)
  __attribute__((format(printf, 2, 3)));

/* write out an escaped pdf string: e.g.  (Text \(Test\)\n)
 * >len==-1: use strlen(str) 
 */
void pdfOut_putString(pdfOut *pdf,const char *str,int len);
void pdfOut_putHexString(pdfOut *pdf,const char *str,int len);

/* Format the broken up timestamp according to
 * pdf requirements for /CreationDate
 * NOTE: uses statically allocated buffer 
 */
const char *pdfOut_to_pdfdate(struct tm *curtm);

/* begin a new object at current point of the 
 * output stream and add it to the xref table.
 * returns the obj number.
 */
int pdfOut_add_xref(pdfOut *pdf);

/* adds page dictionary >obj to the global Pages tree
 * returns false on error
 */
int pdfOut_add_page(pdfOut *pdf,int obj);

/* add a >key,>val pair to the document's Info dictionary
 * returns false on error
 */
int pdfOut_add_kv(pdfOut *pdf,const char *key,const char *val);

/* Writes the font >emb including descriptor to the pdf 
 * and returns the object number.
 * On error 0 is returned.
 */
struct _EMB_PARAMS;
int pdfOut_write_font(pdfOut *pdf,struct _EMB_PARAMS *emb);