Here simple code to make a small pdf file

The code below writes the file test.pdf and launches it by the
command shellexecute(...
The pdf file has in this case 4 lines of text...remark that each line extra
requires a '-10' step (see code in the 'middle'.
Good luck with the pdf file !

#include <stdio.h>

Regards,

Frederik Pot

(#include <stdio.h>)
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
 
FILE * fl;
fl=fopen ("test.pdf","w");
if (fl!=NULL)
{
fputs ("%PDF-1.1 %¥±ë\r",fl);
fputs ("1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj\r",fl);
fputs ("2 0 obj << /Type /Pages /Kids [3 0 R] /Count 1\r",fl);
fputs ("/MediaBox [0 0 300 620] >> endobj\r",fl);
fputs ("3 0 obj <<  /Type /Page /Parent 2 0 R /Resources << /Font << /F2\r",fl);
fputs ("<< /Type /Font /Subtype /Type1 /BaseFont /Arial >> >> >>\r",fl);
fputs ("/Contents 4 0 R >>endobj 4 0 obj << /Length 55 >> stream\r",fl);







fputs ("BT /F2 10 Tf 10 600 Td ( cplusplus.com  (Example line 1) ) Tj  ET\r",fl);
fputs ("BT /F2 10 Tf 10 590 Td (Example line 2) Tj  ET\r",fl);
fputs ("BT /F2 10 Tf 10 580 Td (    Example line 3) Tj  ET\r",fl);
fputs ("BT /F2 10 Tf 10 560 Td (Take a look at http://softbuild.nl) Tj  ET\r",fl);






fputs ("endstream\r",fl);
fputs ("endobj trailer <<  /Root 1 0 R >> startxref %%EOF\r",fl);


fclose (fl);
}
ShellExecute(NULL, "open","test.pdf", NULL, NULL, SW_SHOWNORMAL);
Topic archived. No new replies allowed.