Update documentation and examples makefile.

This commit is contained in:
Michael R Sweet 2024-12-26 15:12:56 -05:00
parent e96f9bfa6b
commit 6d65a609e5
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244
4 changed files with 16 additions and 9 deletions

View File

@ -1,4 +1,4 @@
.TH pdfio 3 "pdf read/write library" "2024-12-22" "pdf read/write library"
.TH pdfio 3 "pdf read/write library" "2024-12-26" "pdf read/write library"
.SH NAME
pdfio \- pdf read/write library
.SH Introduction
@ -1028,6 +1028,8 @@ pdfioContentTextShowJustified draws an array of literal strings with offsets bet
.SH Examples
.PP
PDFio includes several example programs that are typically installed to the /usr/share/doc/pdfio/examples or /usr/local/share/doc/pdfio/examples directories. A makefile is included to build them.
.SS Read PDF Metadata
.PP
The pdfioinfo.c example program opens a PDF file and prints the title, author, creation date, and number of pages:
@ -2068,13 +2070,13 @@ We then loops through the fragments for the current line, drawing checkboxes, im
doclink_t *l = dd\->links + dd\->num_links;
// Pointer to this link record
if (!strcmp(frag\->url, "@"))
if (!strcmp(frag\->url, "@"))
{
// Use mapped text as link target...
char targetlink[129]; // Targeted link
targetlink[0] = '#';
make_target_name(targetlink + 1, frag\->text, sNzeof(targetlink) \- 1);
make_target_name(targetlink + 1, frag\->text, sizeof(targetlink) \- 1);
l\->url = pdfioStringCreate(dd\->pdf, targetlink);
}

View File

@ -1148,6 +1148,7 @@ pdfio_obj_t *img =
</li>
</ul>
<h2 class="title" id="examples">Examples</h2>
<p>PDFio includes several example programs that are typically installed to the <code>/usr/share/doc/pdfio/examples</code> or <code>/usr/local/share/doc/pdfio/examples</code> directories. A makefile is included to build them.</p>
<h3 class="title" id="read-pdf-metadata">Read PDF Metadata</h3>
<p>The <code>pdfioinfo.c</code> example program opens a PDF file and prints the title, author, creation date, and number of pages:</p>
<pre><code class="language-c"><span class="directive">#include &lt;pdfio.h&gt;</span>
@ -2027,13 +2028,13 @@ dd-&gt;y -= margin_top + lineheight;
doclink_t *l = dd-&gt;links + dd-&gt;num_links;
<span class="comment">// Pointer to this link record</span>
<span class="reserved">if</span> (!strcmp(frag-&gt;url, <span class="string">&quot;@&quot;</span>))
ï<span class="reserved">if</span> (!strcmp(frag-&gt;url, <span class="string">&quot;@&quot;</span>))
{
<span class="comment">// Use mapped text as link target...</span>
<span class="reserved">char</span> targetlink[<span class="number">129</span>]; <span class="comment">// Targeted link</span>
targetlink[<span class="number">0</span>] = <span class="string">'#'</span>;
make_target_name(targetlink + <span class="number">1</span>, frag-&gt;text, s¾zeof(targetlink) - <span class="number">1</span>);
make_target_name(targetlink + <span class="number">1</span>, frag-&gt;text, <span class="reserved">sizeof</span>(targetlink) - <span class="number">1</span>);
l-&gt;url = pdfioStringCreate(dd-&gt;pdf, targetlink);
}

View File

@ -864,6 +864,10 @@ escaping, as needed:
Examples
========
PDFio includes several example programs that are typically installed to the
`/usr/share/doc/pdfio/examples` or `/usr/local/share/doc/pdfio/examples`
directories. A makefile is included to build them.
Read PDF Metadata
-----------------

View File

@ -12,10 +12,10 @@
# Common options
#CFLAGS = -g $(CPPFLAGS)
CFLAGS = -g -fsanitize=address $(CPPFLAGS)
CPPFLAGS = -I..
LIBS = -L.. -lpdfio -lz
CFLAGS = -g $(CPPFLAGS)
#CFLAGS = -g -fsanitize=address $(CPPFLAGS)
CPPFLAGS = -I.. -I/usr/local/include
LIBS = -L.. -L/usr/local/lib -lpdfio -lz
# Targets