ClibPDF Example PDF Files and
Programs
The example source code files are included in the library source
distiribution. It is not necessary to download them individually.
Press "Reload" or "Refresh"
button if your web browser shows a blank page.
(Updated source code for version 2.0x)
-
HTML Form to Dynamic PDF [no source] --- Tax
Form 1040 example.
This demo generates a new PDF file dynamically based on the browser
data posted from a HTML form and server-side real-time data (web-cam images)
and calculations. The demo now includes bar-coded
social security number. There are alternatives to Acrobat Forms and
FDF.
-
Shipping Label with Tracking Number (Dynamic PDF) [shiplabel.c]
--- Try it.
This demo illustrates a very simple but quite realistic Dynamic PDF
CGI in just ~100 lines of C code. Address data here come from a HTML
form, but they can easily come from a fully automated order processing
system. A free CGI library, cgihtml,
is used for input parsing.
-
PDF Clock - Dynamic PDF [pdfclock.c]
--- Current time in California?
This demo generates a PDF file showing current time in California in
analog as well as digital (text) formats. If you don't know how to
produce a CGI using ClibPDF, this is a good start.
-
Japanese Font Support [jpntest.c]
--- PDF output -- requires Japanese
Font Pack unless you are running a Japanese OS.
The above demo, and the Chinese/Korean font demos below illustrate the use of Asian fonts in PDF documents.
To view files that use Japanese, Korean and Chinese fonts, you must have appropriate font packs installed for Acrobat Reader 4.0 and 5.0 (free from this
Adobe page).
As you can see, as a programmer, using Asian fonts
is as easy as using any built-in Roman fonts. Also note that, although
Acrobat Reader requires the Asian fonts, systems that run ClibPDF applications
do NOT. Any system anywhere can host a dynamic PDF CGI that generates
Asian language PDF documents.
-
Chinese Font Support [cn-test.c]
--- PDF output -- requires Both Traditional and Simplified Chinese Font Packs.
-
Korean Font Support [kr-test.c]
--- PDF output -- requires Korean Font Pack unless you are running a Korean OS.
-
Bar Code [barcode.c]
--- PDF output
This demo illustrates the use of bar code fonts using the ClibPDF's
ability to embed Type-1 fonts. The 1040 tax form demo above also
shows an example of the use of bar code in form applications.
-
Text Box with Fitting [textboxfit.c]
--- PDF output
This text box will fit any amount of text (within reason) into a text
box of a given size by reducing font size. All text boxes can now
be rotated to any angle with ease.
-
Text Box / TEXT2PDF [textbox.c
-- raw text ] -- PDF
output.
This program is a simple but capable (yet anothter) TEXT2PDF.
It illustrates the use of a new API function cpdf_textBox() and cpdf_rawTextBox().
In addition to simple ascii-text-to-PDF capability, these functions offer
columnar text formatting with left-aligned, right-aligned, centered and
justfied text. It also allows a straight-forward way to chain
text boxes for multi-columnar formatting and continuting text to subsequent
pages. Look at the source code/data/result above, and see how simple
this can be.
-
Font List [fontlist.c]
--- PDF output of this program.
Creates a list of all 41 fonts available to any ClibPDF program.
(This is not font embedding, although PS Type1 font embedding is also
supported now. See bar code example above and the library
test program at the end of this page below for font embedding examples.)
Only the font metrics data are embedded for the 41 fonts (not font itself).
The metrics data are linked in as static data for speed (not on-the-fly
loading of AFM/PFM files). Most PostScript printers (with Reader
4.0) will print these fonts accurately because these are the standard built-in
fonts. On non-PostScript printers and on the screen, Acrobat Reader
will approximate the specified fonts. CPDF-Monospace and CPDF-SmallCap
are two fonts we made up by just tweaking font metrics/descriptor data.
Note that these two fonts will not be rendered correctly with most non-Adobe
PDF viewers.
-
Arc and Circles [Arcs.c]
--- PDF output of this program.
Draws arcs of various angles, and color-filled pie shapes.
-
Outline (Book Marks) [outline.c]
--- PDF output of this program.
Multi-level Outlines (book marks) are generated (3 levels) in this
example for a 200-page file programatically. The 3-rd level is hidden
(closed) from the initial view. Full controls of destination specifications
(e.g., fit a rectangular region to view, fit page to view) are available.
The use of a new function cpdf_setDocumentLimits() is also demonstrated.
Some examples of new action outlines (v1.10 or later)
are included at the top of book mark list.
This program generates the cover of the ClibPDF Referance Manual.
It draws 100+ pie and pacman shapes of random parameters (size, color,
position, angles). It is a good example of the use of a clip path.
It also demonstrates the use of cpdf_textAligned(), Web- and e-mail
hyper text links, and an in-line image. Page 2 of the PDF file
is produced by reading in an ascii text file and showing the content as
is, using automatic new-line functions of PDF/ClibPDF.
Source code for Fig. 2 of the API manual.
Demonstrates the notion of plot domains and how they ease plotting
of numerical data. A Gaussian curve stored in arrays are plotted
on both linear-linear, and log-log domains. It also demonstrates
how to use clipping to restrict plots within a specified plot domain.
Source code for Fig. 4 of the API manual.
Tests arcs and their drawing directions, "fill" and "eofill" operators.
-
Dash Pattern [dashtest.c]
--- PDF output of this program
Source code for Fig. 5 of the API manual.
Demonstrates how one specifies dash patterns for stroking paths.
-
Aligned Text [textalign.c]
--- PDF output of this program
Source code for Fig. 6 of the API manual.
Shows the definition of text alignment modes (left, right, top, and
bottom alignment, and centering modes for cpdf_textAligned() function.
-
Time Axis [timeaxis.c]
--- PDF output of this program
Source code for Fig. 7 of the API manual.
Demonstrates the use of time/date axes. Time axes will try to
use appropriate tick marks and numbering automatically for axis spanning
any duration.
-
Data Markers [MarkerTest.c]
--- PDF output of this program
Source code for Fig. 8 of the API manual.
Draws all marker symbols available for marking data points. It
also shows pointers (arrow heads). By setting fill and stroke colors
appropriately, most of these markers may become either filled or open symbols.
Plots weather data (hourly temperature in degrees C or F, and relative
humidity) from an ascii data file. This program demonstrates a realistic
use of time plot domain and axis, and parsing of a simple text data file.
The data file included is for the Oakland Airport, California, down-loaded
hourly from the National Weather Service (NOAA) web site (http://iwin.nws.noaa.gov/iwin/ca/hourly.html)
via a script and a cron job. The data file also includes dew point,
wind direction and speed, and atmospheric pressure.
This program performs relatively extensive test of key functions included
in
ClibPDF library. It now creates two PDF files at the same time.
It is not a great example, as test items have been added without much thought
as the library was being developed. However, it is a good test of
the library when porting to a new environment. Under a Unix environment,
"make test" will produce the test program executable without the use of
the library file (i.e., links in individual object files). Page 2
of this file includes the same JPEG file as on page 1, and a gradient image
placed as an in-line image.
(Copyright (C) 1998 FastIO Systems, All Rights Reserved,
Last updated: Oct. 1, 1999)