-
Notifications
You must be signed in to change notification settings - Fork 1
/
pdf_writer.txt
133 lines (100 loc) · 4.21 KB
/
pdf_writer.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Intro to PDF Writer
===================
The PDF Writer consists of a package, PDF_Out,
which produces PDF files - as "physical" files, or as
other types of data streams.
The creation of a PDF file is as simple as this
small procedure:
with PDF_Out;
procedure Hello is
pdf : PDF_Out.PDF_Out_File;
begin
pdf.Create ("tiny.pdf");
pdf.Put_Line ("Hello world !");
pdf.Close;
end;
Contents
========
PDF Writer
==========
- pdf_out.ads : package specification
- pdf_out.adb : package body
- pdf_out-* : private children packages (needed but not relevant for users)
- pdf_out_demo.adb : demo procedure
- pdf_out_gnat.gpr : project file for the GNAT compiler, using the local GID copy
- pdf_out_gnat_w_gid.gpr : project file for the GNAT compiler, with reference to GID as project (*)
- pdf_out_oa.prj : project file for the ObjectAda (10+) compiler
- pdf_writer.txt : this file
- gid/* : packages used by pdf_out.adb (local copy of GID, the Generic Image Decoder)
(*) The alternative project file for GNAT, pdf_out_gnat_w_gid.gpr, will reference
the project file for GID (the Generic Image Decoder), gid.gpr.
This is useful if:
- you are using GID elsewhere in your own project (to avoid duplication)
- gid.gpr is visible through GPR_PROJECT_PATH or ADA_PROJECT_PATH (again, to avoid duplication)
- you are using the Alire package manager ( https://alire.ada.dev ) - in this case, all is already
managed behind the scenes.
License / Warning / Legal stuff
===============================
There is NO WARRANTY in the PDF Writer software.
PDF Writer is licensed under the MIT License.
You find the full license and copyright notice in pdf_out.ads.
Portability
===========
PDF Writer can be compiled for any target machine, and with any compiler
for Ada 2005 or later language versions.
How to build PDF Writer and its demo
====================================
Here is how to build with GNAT/GCC:
- type "gprbuild -p -P pdf_out_gnat" in the command line
or
- open the pdf_out_gnat.gpr file (will launch the GNAT Programming Studio (GPS)),
press F4 (Build)
Here is how to build with ObjectAda (10+):
- open the pdf_out_oa.prj file, press F7 (Build)
As a result there is a pdf_out_demo[.exe] executable.
Type hierarchy
==============
In PDF_Out:
|- PDF_Out_Stream : root type, abstract
\
|- PDF_Out_File : type for writing to files (defined in PDF_Out)
|- PDF_Out_String : type for writing to strings (defined in PDF_Out)
|
In your own extension, if needed:
|
|- (your own stream!)
How to create properly PDF files or streams
===========================================
Most, if not all possibilities are in the Big_demo procedure
nested in PDF_Out_Demo. So it is a good place to pick code...
To summarize, you need to define the document contents in
a certain order:
1. Create
2. Optional settings, before any output or next page:
| Define page layout (see Header, Footer, Page_Setup, ...)
| Font, Font_Size, ...
3. | Put(pdf, data),
| New_Line(pdf), ... : other "Text_IO"-like (full list below)
| Image(pdf, ...) : raster images
| Move/Line/... : vector graphics
| New_Page(pdf)
4. Close
5. (PDF_Out_String only) function Contents returns the full .pdf
Thanks to...
============
Giuseppe Cannone ( http://www.ari-srl.it/ ), for testing with a
third-party online validator ( https://www.pdf-online.com/osa/validate.aspx )
and providing a patch to the PDF Writer for making it ISO-compliant.
Roland Coghetto ( https://github.com/CoghettoR ), for testing and
contributions in the Text Output area.
Where to find the latest version
================================
Home page: http://apdf.sf.net/
Project page 1: http://sf.net/projects/apdf/
Project page 2: https://github.com/zertovitch/ada-pdf-writer
Alire crate: https://alire.ada.dev/crates/apdf
See also the "web", "web2", "web3", "web4", constants in pdf_out.ads.
--
Enjoy!
Gautier de Montmollin
gautier.de.montmollin, at: gmail dot com.