1 #include "pdfutils.h"
2 #include <assert.h>
3 #include <string.h>
4
main()5 int main()
6 {
7 pdfOut *pdf;
8
9 pdf=pdfOut_new();
10 assert(pdf);
11
12 pdfOut_begin_pdf(pdf);
13
14 // bad font
15 int font_obj=pdfOut_add_xref(pdf);
16 pdfOut_printf(pdf,"%d 0 obj\n"
17 "<</Type/Font\n"
18 " /Subtype /Type1\n" // /TrueType,/Type3
19 " /BaseFont /%s\n"
20 ">>\n"
21 "endobj\n"
22 ,font_obj,"Courier");
23 // test
24 const int PageWidth=595,PageLength=842;
25 int cobj=pdfOut_add_xref(pdf);
26 const char buf[]="BT /a 10 Tf (abc) Tj ET";
27 pdfOut_printf(pdf,"%d 0 obj\n"
28 "<</Length %d\n"
29 ">>\n"
30 "stream\n"
31 "%s\n"
32 "endstream\n"
33 "endobj\n"
34 ,cobj,strlen(buf),buf);
35
36 int obj=pdfOut_add_xref(pdf);
37 pdfOut_printf(pdf,"%d 0 obj\n"
38 "<</Type/Page\n"
39 " /Parent 1 0 R\n"
40 " /MediaBox [0 0 %d %d]\n"
41 " /Contents %d 0 R\n"
42 " /Resources << /Font << /a %d 0 R >> >>\n"
43 ">>\n"
44 "endobj\n"
45 ,obj,PageWidth,PageLength,cobj,font_obj); // TODO: into pdf->
46 pdfOut_add_page(pdf,obj);
47 pdfOut_finish_pdf(pdf);
48
49 pdfOut_free(pdf);
50
51 return 0;
52 }
53