Update documentation and prep for 1.0.1 release.

This commit is contained in:
Michael R Sweet 2022-03-02 09:30:01 -05:00
parent f7f2969e3a
commit 54578144a0
No known key found for this signature in database
GPG Key ID: 999559A027815955
8 changed files with 141 additions and 43 deletions

View File

@ -84,6 +84,9 @@ all-shared:
debug: debug:
$(MAKE) -$(MAKEFLAGS) COMMONFLAGS="-g -fsanitize=address -DDEBUG=1" clean all $(MAKE) -$(MAKEFLAGS) COMMONFLAGS="-g -fsanitize=address -DDEBUG=1" clean all
macos:
$(MAKE) -$(MAKEFLAGS) COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64" clean all
# Clean everything # Clean everything
clean: clean:
@ -156,7 +159,7 @@ pdfio1.def: $(LIBOBJS) Makefile
grep -v '^_ttf' | sed -e '1,$$s/^_//' | sort >>$@ grep -v '^_ttf' | sed -e '1,$$s/^_//' | sort >>$@
# pdfio text extraction demo # pdfio text extraction (demo, doesn't handle a lot of things yet)
pdfiototext: pdfiototext.o libpdfio.a pdfiototext: pdfiototext.o libpdfio.a
$(CC) $(LDFLAGS) $(COMMONFLAGS) -o $@ pdfiototext.o libpdfio.a $(LIBS) $(CC) $(LDFLAGS) $(COMMONFLAGS) -o $@ pdfiototext.o libpdfio.a $(LIBS)

View File

@ -1,4 +1,4 @@
.TH pdfio 3 "pdf read/write library" "2021-12-14" "pdf read/write library" .TH pdfio 3 "pdf read/write library" "2022-03-02" "pdf read/write library"
.SH NAME .SH NAME
pdfio \- pdf read/write library pdfio \- pdf read/write library
.SH Introduction .SH Introduction
@ -34,7 +34,7 @@ PDFio is
.I not .I not
concerned with rendering or viewing a PDF file, although a PDF RIP or viewer could be written using it. concerned with rendering or viewing a PDF file, although a PDF RIP or viewer could be written using it.
.PP .PP
PDFio is Copyright \[co] 2021 by Michael R Sweet and is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software. See the files "LICENSE" and "NOTICE" for more information. PDFio is Copyright \[co] 2021\-2022 by Michael R Sweet and is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software. See the files "LICENSE" and "NOTICE" for more information.
.SS Requirements .SS Requirements
.PP .PP
PDFio requires the following to build the software: PDFio requires the following to build the software:
@ -156,7 +156,7 @@ There is also an Xcode project ("pdfio.xcodeproj") you can use on macOS which ge
You can reproduce this with the makefile using: You can reproduce this with the makefile using:
.nf .nf
sudo make COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64" install sudo make macos install
.fi .fi
.SS Detecting PDFio .SS Detecting PDFio
.PP .PP
@ -228,9 +228,9 @@ where the three arguments to the function are the filename ("myinputfile.pdf"),
error_cb(pdfio_file_t *pdf, const char *message, void *data) error_cb(pdfio_file_t *pdf, const char *message, void *data)
{ {
(void)data; // This callback does not use the data pointer (void)data; // This callback does not use the data pointer
fprintf(stderr, "%s: %s\\n", pdfioFileGetName(pdf), message); fprintf(stderr, "%s: %s\\n", pdfioFileGetName(pdf), message);
// Return false to treat warnings as errors // Return false to treat warnings as errors
return (false); return (false);
} }
@ -245,7 +245,7 @@ Each PDF file contains one or more pages. The pdfioFileGetNumPages function retu
size_t i; // Looping var size_t i; // Looping var
size_t count; // Number of pages size_t count; // Number of pages
pdfio_obj_t *page; // Current page pdfio_obj_t *page; // Current page
// Iterate the pages in the PDF file // Iterate the pages in the PDF file
for (i = 0, count = pdfioFileGetNumPages(pdf); i < count; i ++) for (i = 0, count = pdfioFileGetNumPages(pdf); i < count; i ++)
{ {
@ -254,7 +254,7 @@ Each PDF file contains one or more pages. The pdfioFileGetNumPages function retu
} }
.fi .fi
.PP .PP
Each page is represented by a "page tree" object (what pdfioFileGetPage returns) that specifies information about the page and one or more "content" objects that contain the images, fonts, text, and graphics that appear on the page. Each page is represented by a "page tree" object (what pdfioFileGetPage returns) that specifies information about the page and one or more "content" objects that contain the images, fonts, text, and graphics that appear on the page. Use the pdfioPageGetNumStreams and pdfioPageOpenStream functions to access the content streams for each page.
.PP .PP
The pdfioFileClose function closes a PDF file and frees all memory that was used for it: The pdfioFileClose function closes a PDF file and frees all memory that was used for it:
.nf .nf
@ -268,7 +268,7 @@ You create a new PDF file using the pdfioFileCreate function:
pdfio_rect_t media_box = { 0.0, 0.0, 612.0, 792.0 }; // US Letter pdfio_rect_t media_box = { 0.0, 0.0, 612.0, 792.0 }; // US Letter
pdfio_rect_t crop_box = { 36.0, 36.0, 576.0, 756.0 }; // w/0.5" margins pdfio_rect_t crop_box = { 36.0, 36.0, 576.0, 756.0 }; // w/0.5" margins
pdfio_file_t *pdf = pdfioFileCreate("myoutputfile.pdf", "2.0", &media_box, &crop_box, error_cb, error_data); pdfio_file_t *pdf = pdfioFileCreate("myoutputfile.pdf", "2.0", &media_box, &crop_box, error_cb, error_data);
.fi .fi
.PP .PP
@ -279,7 +279,7 @@ Alternately you can stream a PDF file using the pdfioFileCreateOutput function:
pdfio_rect_t media_box = { 0.0, 0.0, 612.0, 792.0 }; // US Letter pdfio_rect_t media_box = { 0.0, 0.0, 612.0, 792.0 }; // US Letter
pdfio_rect_t crop_box = { 36.0, 36.0, 576.0, 756.0 }; // w/0.5" margins pdfio_rect_t crop_box = { 36.0, 36.0, 576.0, 756.0 }; // w/0.5" margins
pdfio_file_t *pdf = pdfioFileCreateOutput(output_cb, output_ctx, "2.0", &media_box, &crop_box, error_cb, error_data); pdfio_file_t *pdf = pdfioFileCreateOutput(output_cb, output_ctx, "2.0", &media_box, &crop_box, error_cb, error_data);
.fi .fi
.PP .PP
@ -324,6 +324,14 @@ Some PDF objects have an associated data stream, such as for pages, images, ICC
.PP .PP
The first argument is the object pointer. The second argument is a boolean value that specifies whether you want to decode (typically decompress) the stream data or return it as\-is. The first argument is the object pointer. The second argument is a boolean value that specifies whether you want to decode (typically decompress) the stream data or return it as\-is.
.PP .PP
When reading a page stream you'll use the pdfioPageOpenStream function instead:
.nf
pdfio_file_t *pdf = pdfioFileOpen(...);
pdfio_obj_t *obj = pdfioFileGetPage(pdf, number);
pdfio_stream_t *st = pdfioPageOpenStream(obj, 0, true);
.fi
.PP
Once you have the stream open, you can use one of several functions to read from it: Once you have the stream open, you can use one of several functions to read from it:
.IP \(bu 5 .IP \(bu 5
.PP .PP
@ -353,12 +361,21 @@ To create a stream for a new object, call the pdfioObjCreateStream function:
.nf .nf
pdfio_file_t *pdf = pdfioFileCreate(...); pdfio_file_t *pdf = pdfioFileCreate(...);
pdfio_obj_t *pdfioFileCreateObj(pdf, ...); pdfio_obj_t *obj = pdfioFileCreateObj(pdf, ...);
pdfio_stream_t *pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE); pdfio_stream_t *st = pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE);
.fi .fi
.PP .PP
The first argument is the newly created object. The second argument is either PDFIO_FILTER_NONE to specify that any encoding is done by your program or PDFIO_FILTER_FLATE to specify that PDFio should Flate compress the stream. The first argument is the newly created object. The second argument is either PDFIO_FILTER_NONE to specify that any encoding is done by your program or PDFIO_FILTER_FLATE to specify that PDFio should Flate compress the stream.
.PP .PP
To create a page content stream call the pdfioFileCreatePage function:
.nf
pdfio_file_t *pdf = pdfioFileCreate(...);
pdfio_dict_t *dict = pdfioDictCreate(pdf);
\... set page dictionary keys and values ...
pdfio_stream_t *st = pdfioFileCreatePage(pdf, dict);
.fi
.PP
Once you have created the stream, use any of the following functions to write to the stream: Once you have created the stream, use any of the following functions to write to the stream:
.IP \(bu 5 .IP \(bu 5
.PP .PP
@ -444,13 +461,13 @@ PDFio also includes predefined constants for creating a few standard color space
.nf .nf
pdfio_file_t *pdf = pdfioFileCreate(...); pdfio_file_t *pdf = pdfioFileCreate(...);
// Create an AdobeRGB color array // Create an AdobeRGB color array
pdfio_array_t *adobe_rgb = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_ADOBE); pdfio_array_t *adobe_rgb = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_ADOBE);
// Create an Display P3 color array // Create an Display P3 color array
pdfio_array_t *display_p3 = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_P3_D65); pdfio_array_t *display_p3 = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_P3_D65);
// Create an sRGB color array // Create an sRGB color array
pdfio_array_t *srgb = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_SRGB); pdfio_array_t *srgb = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_SRGB);
.fi .fi
@ -550,10 +567,10 @@ will create an object for a 1024x1024 RGBA image in memory, using the default co
.nf .nf
pdfio_file_t *pdf = pdfioFileCreate(...); pdfio_file_t *pdf = pdfioFileCreate(...);
// Create an AdobeRGB color array // Create an AdobeRGB color array
pdfio_array_t *adobe_rgb = pdfioArrayCreateColorFromMatrix(pdf, 3, pdfioAdobeRGBGamma, pdfioAdobeRGBMatrix, pdfioAdobeRGBWhitePoint); pdfio_array_t *adobe_rgb = pdfioArrayCreateColorFromMatrix(pdf, 3, pdfioAdobeRGBGamma, pdfioAdobeRGBMatrix, pdfioAdobeRGBWhitePoint);
// Create a 1024x1024 RGBA image using AdobeRGB // Create a 1024x1024 RGBA image using AdobeRGB
unsigned char data[1024 * 1024 * 4]; // 1024x1024 RGBA image data unsigned char data[1024 * 1024 * 4]; // 1024x1024 RGBA image data
pdfio_obj_t *img = pdfioFileCreateImageObjFromData(pdf, data, /*width*/1024, /*height*/1024, /*num_colors*/3, /*color_data*/adobe_rgb, /*alpha*/true, /*interpolate*/false); pdfio_obj_t *img = pdfioFileCreateImageObjFromData(pdf, data, /*width*/1024, /*height*/1024, /*num_colors*/3, /*color_data*/adobe_rgb, /*alpha*/true, /*interpolate*/false);
@ -2693,6 +2710,24 @@ bool pdfioPageDictAddImage (
pdfio_obj_t *obj pdfio_obj_t *obj
); );
.fi .fi
.SS pdfioPageGetNumStreams
Get the number of content streams for a page object.
.PP
.nf
size_t pdfioPageGetNumStreams (
pdfio_obj_t *page
);
.fi
.SS pdfioPageOpenStream
Open a content stream for a page.
.PP
.nf
pdfio_stream_t * pdfioPageOpenStream (
pdfio_obj_t *page,
size_t n,
bool decode
);
.fi
.SS pdfioStreamClose .SS pdfioStreamClose
Close a (data) stream in a PDF file. Close a (data) stream in a PDF file.
.PP .PP
@ -2947,4 +2982,4 @@ typedef uint8_t state_t[4][4];
Michael R Sweet Michael R Sweet
.SH COPYRIGHT .SH COPYRIGHT
.PP .PP
Copyright (c) 2021 by Michael R Sweet Copyright (c) 2021-2022 by Michael R Sweet

View File

@ -1,13 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en-US"> <html lang="en-US">
<head> <head>
<title>PDFio Programming Manual v1.0rc1</title> <title>PDFio Programming Manual v1.0.1</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="generator" content="codedoc v3.7"> <meta name="generator" content="codedoc v3.7">
<meta name="author" content="Michael R Sweet"> <meta name="author" content="Michael R Sweet">
<meta name="language" content="en-US"> <meta name="language" content="en-US">
<meta name="copyright" content="Copyright © 2021 by Michael R Sweet"> <meta name="copyright" content="Copyright © 2021-2022 by Michael R Sweet">
<meta name="version" content="1.0rc1"> <meta name="version" content="1.0.1">
<style type="text/css"><!-- <style type="text/css"><!--
body { body {
background: white; background: white;
@ -245,9 +245,9 @@ span.string {
<body> <body>
<div class="header"> <div class="header">
<p><img class="title" src="pdfio-512.png"></p> <p><img class="title" src="pdfio-512.png"></p>
<h1 class="title">PDFio Programming Manual v1.0rc1</h1> <h1 class="title">PDFio Programming Manual v1.0.1</h1>
<p>Michael R Sweet</p> <p>Michael R Sweet</p>
<p>Copyright © 2021 by Michael R Sweet</p> <p>Copyright © 2021-2022 by Michael R Sweet</p>
</div> </div>
<div class="contents"> <div class="contents">
<h2 class="title">Contents</h2> <h2 class="title">Contents</h2>
@ -425,6 +425,8 @@ span.string {
<li><a href="#pdfioPageDictAddColorSpace">pdfioPageDictAddColorSpace</a></li> <li><a href="#pdfioPageDictAddColorSpace">pdfioPageDictAddColorSpace</a></li>
<li><a href="#pdfioPageDictAddFont">pdfioPageDictAddFont</a></li> <li><a href="#pdfioPageDictAddFont">pdfioPageDictAddFont</a></li>
<li><a href="#pdfioPageDictAddImage">pdfioPageDictAddImage</a></li> <li><a href="#pdfioPageDictAddImage">pdfioPageDictAddImage</a></li>
<li><a href="#pdfioPageGetNumStreams">pdfioPageGetNumStreams</a></li>
<li><a href="#pdfioPageOpenStream">pdfioPageOpenStream</a></li>
<li><a href="#pdfioStreamClose">pdfioStreamClose</a></li> <li><a href="#pdfioStreamClose">pdfioStreamClose</a></li>
<li><a href="#pdfioStreamConsume">pdfioStreamConsume</a></li> <li><a href="#pdfioStreamConsume">pdfioStreamConsume</a></li>
<li><a href="#pdfioStreamGetToken">pdfioStreamGetToken</a></li> <li><a href="#pdfioStreamGetToken">pdfioStreamGetToken</a></li>
@ -491,7 +493,7 @@ span.string {
</li> </li>
</ul> </ul>
<p>PDFio is <em>not</em> concerned with rendering or viewing a PDF file, although a PDF RIP or viewer could be written using it.</p> <p>PDFio is <em>not</em> concerned with rendering or viewing a PDF file, although a PDF RIP or viewer could be written using it.</p>
<p>PDFio is Copyright © 2021 by Michael R Sweet and is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software. See the files &quot;LICENSE&quot; and &quot;NOTICE&quot; for more information.</p> <p>PDFio is Copyright © 2021-2022 by Michael R Sweet and is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software. See the files &quot;LICENSE&quot; and &quot;NOTICE&quot; for more information.</p>
<h3 class="title" id="requirements">Requirements</h3> <h3 class="title" id="requirements">Requirements</h3>
<p>PDFio requires the following to build the software:</p> <p>PDFio requires the following to build the software:</p>
<ul> <ul>
@ -557,7 +559,7 @@ make install-shared
<pre><code>sudo xcodebuild install <pre><code>sudo xcodebuild install
</code></pre> </code></pre>
<p>You can reproduce this with the makefile using:</p> <p>You can reproduce this with the makefile using:</p>
<pre><code>sudo make COMMONFLAGS=&quot;-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64&quot; install <pre><code>sudo make macos install
</code></pre> </code></pre>
<h3 class="title" id="detecting-pdfio">Detecting PDFio</h3> <h3 class="title" id="detecting-pdfio">Detecting PDFio</h3>
<p>PDFio can be detected using the <code>pkg-config</code> command, for example:</p> <p>PDFio can be detected using the <code>pkg-config</code> command, for example:</p>
@ -621,7 +623,7 @@ pdfio_obj_t *page; <span class="comment">// Current page</span>
<span class="comment">// do something with page</span> <span class="comment">// do something with page</span>
} }
</code></pre> </code></pre>
<p>Each page is represented by a &quot;page tree&quot; object (what <a href="#pdfioFileGetPage"><code>pdfioFileGetPage</code></a> returns) that specifies information about the page and one or more &quot;content&quot; objects that contain the images, fonts, text, and graphics that appear on the page.</p> <p>Each page is represented by a &quot;page tree&quot; object (what <a href="#pdfioFileGetPage"><code>pdfioFileGetPage</code></a> returns) that specifies information about the page and one or more &quot;content&quot; objects that contain the images, fonts, text, and graphics that appear on the page. Use the <a href="#pdfioPageGetNumStreams"><code>pdfioPageGetNumStreams</code></a> and <a href="#pdfioPageOpenStream"><code>pdfioPageOpenStream</code></a> functions to access the content streams for each page.</p>
<p>The <a href="#pdfioFileClose"><code>pdfioFileClose</code></a> function closes a PDF file and frees all memory that was used for it:</p> <p>The <a href="#pdfioFileClose"><code>pdfioFileClose</code></a> function closes a PDF file and frees all memory that was used for it:</p>
<pre><code class="language-c">pdfioFileClose(pdf); <pre><code class="language-c">pdfioFileClose(pdf);
</code></pre> </code></pre>
@ -663,6 +665,11 @@ pdfio_obj_t *obj = pdfioFileFindObj(pdf, number);
pdfio_stream_t *st = pdfioObjOpenStream(obj, <span class="reserved">true</span>); pdfio_stream_t *st = pdfioObjOpenStream(obj, <span class="reserved">true</span>);
</code></pre> </code></pre>
<p>The first argument is the object pointer. The second argument is a boolean value that specifies whether you want to decode (typically decompress) the stream data or return it as-is.</p> <p>The first argument is the object pointer. The second argument is a boolean value that specifies whether you want to decode (typically decompress) the stream data or return it as-is.</p>
<p>When reading a page stream you'll use the <a href="#pdfioPageOpenStream"><code>pdfioPageOpenStream</code></a> function instead:</p>
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileOpen(...);
pdfio_obj_t *obj = pdfioFileGetPage(pdf, number);
pdfio_stream_t *st = pdfioPageOpenStream(obj, <span class="number">0</span>, <span class="reserved">true</span>);
</code></pre>
<p>Once you have the stream open, you can use one of several functions to read from it:</p> <p>Once you have the stream open, you can use one of several functions to read from it:</p>
<ul> <ul>
<li><p><a href="#pdfioStreamConsume"><code>pdfioStreamConsume</code></a> reads and discards a number of bytes in the stream</p> <li><p><a href="#pdfioStreamConsume"><code>pdfioStreamConsume</code></a> reads and discards a number of bytes in the stream</p>
@ -679,10 +686,16 @@ pdfio_stream_t *st = pdfioObjOpenStream(obj, <span class="reserved">true</span>)
</code></pre> </code></pre>
<p>To create a stream for a new object, call the <a href="#pdfioObjCreateStream"><code>pdfioObjCreateStream</code></a> function:</p> <p>To create a stream for a new object, call the <a href="#pdfioObjCreateStream"><code>pdfioObjCreateStream</code></a> function:</p>
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...); <pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
pdfio_obj_t *pdfioFileCreateObj(pdf, ...); pdfio_obj_t *obj = pdfioFileCreateObj(pdf, ...);
pdfio_stream_t *pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE); pdfio_stream_t *st = pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE);
</code></pre> </code></pre>
<p>The first argument is the newly created object. The second argument is either <code>PDFIO_FILTER_NONE</code> to specify that any encoding is done by your program or <code>PDFIO_FILTER_FLATE</code> to specify that PDFio should Flate compress the stream.</p> <p>The first argument is the newly created object. The second argument is either <code>PDFIO_FILTER_NONE</code> to specify that any encoding is done by your program or <code>PDFIO_FILTER_FLATE</code> to specify that PDFio should Flate compress the stream.</p>
<p>To create a page content stream call the <a href="#pdfioFileCreatePage"><code>pdfioFileCreatePage</code></a> function:</p>
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
pdfio_dict_t *dict = pdfioDictCreate(pdf);
... set page dictionary keys <span class="reserved">and</span> values ...
pdfio_stream_t *st = pdfioFileCreatePage(pdf, dict);
</code></pre>
<p>Once you have created the stream, use any of the following functions to write to the stream:</p> <p>Once you have created the stream, use any of the following functions to write to the stream:</p>
<ul> <ul>
<li><p><a href="#pdfioStreamPrintf"><code>pdfioStreamPrintf</code></a> writes a formatted string to the stream</p> <li><p><a href="#pdfioStreamPrintf"><code>pdfioStreamPrintf</code></a> writes a formatted string to the stream</p>
@ -3264,6 +3277,32 @@ bool pdfioPageDictAddImage(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const
</tbody></table> </tbody></table>
<h4 class="returnvalue">Return Value</h4> <h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p> <p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioPageGetNumStreams">pdfioPageGetNumStreams</a></h3>
<p class="description">Get the number of content streams for a page object.</p>
<p class="code">
size_t pdfioPageGetNumStreams(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>page</th>
<td class="description">Page object</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Number of streams</p>
<h3 class="function"><a id="pdfioPageOpenStream">pdfioPageOpenStream</a></h3>
<p class="description">Open a content stream for a page.</p>
<p class="code">
<a href="#pdfio_stream_t">pdfio_stream_t</a> *pdfioPageOpenStream(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, size_t n, bool decode);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>page</th>
<td class="description">Page object</td></tr>
<tr><th>n</th>
<td class="description">Stream index (0-based)</td></tr>
<tr><th>decode</th>
<td class="description"><code>true</code> to decode/decompress stream</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Stream</p>
<h3 class="function"><a id="pdfioStreamClose">pdfioStreamClose</a></h3> <h3 class="function"><a id="pdfioStreamClose">pdfioStreamClose</a></h3>
<p class="description">Close a (data) stream in a PDF file.</p> <p class="description">Close a (data) stream in a PDF file.</p>
<p class="code"> <p class="code">

View File

@ -15,8 +15,8 @@ goals of pdfio are:
PDFio is *not* concerned with rendering or viewing a PDF file, although a PDF PDFio is *not* concerned with rendering or viewing a PDF file, although a PDF
RIP or viewer could be written using it. RIP or viewer could be written using it.
PDFio is Copyright © 2021 by Michael R Sweet and is licensed under the Apache PDFio is Copyright © 2021-2022 by Michael R Sweet and is licensed under the
License Version 2.0 with an (optional) exception to allow linking against Apache License Version 2.0 with an (optional) exception to allow linking against
GPL2/LGPL2 software. See the files "LICENSE" and "NOTICE" for more information. GPL2/LGPL2 software. See the files "LICENSE" and "NOTICE" for more information.
@ -104,7 +104,7 @@ generates a static library that will be installed under "/usr/local" with:
You can reproduce this with the makefile using: You can reproduce this with the makefile using:
sudo make COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64" install sudo make macos install
Detecting PDFio Detecting PDFio
@ -209,7 +209,8 @@ for (i = 0, count = pdfioFileGetNumPages(pdf); i < count; i ++)
Each page is represented by a "page tree" object (what [`pdfioFileGetPage`](@@) Each page is represented by a "page tree" object (what [`pdfioFileGetPage`](@@)
returns) that specifies information about the page and one or more "content" returns) that specifies information about the page and one or more "content"
objects that contain the images, fonts, text, and graphics that appear on the objects that contain the images, fonts, text, and graphics that appear on the
page. page. Use the [`pdfioPageGetNumStreams`](@@) and [`pdfioPageOpenStream`](@@)
functions to access the content streams for each page.
The [`pdfioFileClose`](@@) function closes a PDF file and frees all memory that The [`pdfioFileClose`](@@) function closes a PDF file and frees all memory that
was used for it: was used for it:
@ -294,6 +295,15 @@ The first argument is the object pointer. The second argument is a boolean
value that specifies whether you want to decode (typically decompress) the value that specifies whether you want to decode (typically decompress) the
stream data or return it as-is. stream data or return it as-is.
When reading a page stream you'll use the [`pdfioPageOpenStream`](@@) function
instead:
```c
pdfio_file_t *pdf = pdfioFileOpen(...);
pdfio_obj_t *obj = pdfioFileGetPage(pdf, number);
pdfio_stream_t *st = pdfioPageOpenStream(obj, 0, true);
```
Once you have the stream open, you can use one of several functions to read Once you have the stream open, you can use one of several functions to read
from it: from it:
@ -315,14 +325,23 @@ function:
```c ```c
pdfio_file_t *pdf = pdfioFileCreate(...); pdfio_file_t *pdf = pdfioFileCreate(...);
pdfio_obj_t *pdfioFileCreateObj(pdf, ...); pdfio_obj_t *obj = pdfioFileCreateObj(pdf, ...);
pdfio_stream_t *pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE); pdfio_stream_t *st = pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE);
``` ```
The first argument is the newly created object. The second argument is either The first argument is the newly created object. The second argument is either
`PDFIO_FILTER_NONE` to specify that any encoding is done by your program or `PDFIO_FILTER_NONE` to specify that any encoding is done by your program or
`PDFIO_FILTER_FLATE` to specify that PDFio should Flate compress the stream. `PDFIO_FILTER_FLATE` to specify that PDFio should Flate compress the stream.
To create a page content stream call the [`pdfioFileCreatePage`](@@) function:
```c
pdfio_file_t *pdf = pdfioFileCreate(...);
pdfio_dict_t *dict = pdfioDictCreate(pdf);
... set page dictionary keys and values ...
pdfio_stream_t *st = pdfioFileCreatePage(pdf, dict);
```
Once you have created the stream, use any of the following functions to write Once you have created the stream, use any of the following functions to write
to the stream: to the stream:

View File

@ -372,7 +372,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.0.0; CURRENT_PROJECT_VERSION = 1.0.1;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -450,7 +450,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.0.0; CURRENT_PROJECT_VERSION = 1.0.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;

View File

@ -219,6 +219,8 @@ pdfioPageCopy
pdfioPageDictAddColorSpace pdfioPageDictAddColorSpace
pdfioPageDictAddFont pdfioPageDictAddFont
pdfioPageDictAddImage pdfioPageDictAddImage
pdfioPageGetNumStreams
pdfioPageOpenStream
pdfioStreamClose pdfioStreamClose
pdfioStreamConsume pdfioStreamConsume
pdfioStreamGetToken pdfioStreamGetToken

View File

@ -3,7 +3,7 @@
<metadata> <metadata>
<id>pdfio_native</id> <id>pdfio_native</id>
<title>PDFio Library for VS2019+</title> <title>PDFio Library for VS2019+</title>
<version>1.0.0</version> <version>1.0.1</version>
<authors>Michael R Sweet</authors> <authors>Michael R Sweet</authors>
<owners>michaelrsweet</owners> <owners>michaelrsweet</owners>
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl> <projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
@ -12,11 +12,11 @@
<readme>build/native/README.md</readme> <readme>build/native/README.md</readme>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PDFio Library for VS2019+</description> <description>PDFio Library for VS2019+</description>
<summary>PDFio is a simple C library for reading and writing PDF files. PDFio is licensed under the Apache License Version 2.0 with an exception to allow linking against GNU GPL2-only software.</summary> <summary>PDFio is a simple C library for reading and writing PDF files. PDFio is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GNU GPL2-only software.</summary>
<copyright>Copyright © 2019-2021 by Michael R Sweet</copyright> <copyright>Copyright © 2019-2022 by Michael R Sweet</copyright>
<tags>pdf file native</tags> <tags>pdf file native</tags>
<dependencies> <dependencies>
<dependency id="pdfio_native.redist" version="1.0.0" /> <dependency id="pdfio_native.redist" version="1.0.1" />
<dependency id="zlib_native.redist" version="1.2.11" /> <dependency id="zlib_native.redist" version="1.2.11" />
</dependencies> </dependencies>
</metadata> </metadata>

View File

@ -3,7 +3,7 @@
<metadata> <metadata>
<id>pdfio_native.redist</id> <id>pdfio_native.redist</id>
<title>PDFio Library for VS2019+</title> <title>PDFio Library for VS2019+</title>
<version>1.0.0</version> <version>1.0.1</version>
<authors>Michael R Sweet</authors> <authors>Michael R Sweet</authors>
<owners>michaelrsweet</owners> <owners>michaelrsweet</owners>
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl> <projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
@ -12,8 +12,8 @@
<readme>build/native/README.md</readme> <readme>build/native/README.md</readme>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PDFio Library for VS2019+</description> <description>PDFio Library for VS2019+</description>
<summary>PDFio is a simple C library for reading and writing PDF files. This package provides the redistributable content for the PDFio library. PDFio is licensed under the Apache License Version 2.0 with an exception to allow linking against GNU GPL2-only software.</summary> <summary>PDFio is a simple C library for reading and writing PDF files. This package provides the redistributable content for the PDFio library. PDFio is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GNU GPL2-only software.</summary>
<copyright>Copyright © 2019-2021 by Michael R Sweet</copyright> <copyright>Copyright © 2019-2022 by Michael R Sweet</copyright>
<tags>pdf file native</tags> <tags>pdf file native</tags>
</metadata> </metadata>
<files> <files>