mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2026-01-18 01:30:09 +01:00
Implement pdfioPageGetXxx functions (Issue #150)
This commit is contained in:
@@ -9,6 +9,8 @@ v1.7.0 - YYYY-MM-DD
|
||||
- Added support for basic compound stream filters for ASCII85Decode support
|
||||
(Issue #11)
|
||||
- Added support for LZWDecode filters (Issue #11)
|
||||
- Added `pdfioPageGetXxx` functions to get values from the page dictionaries
|
||||
(Issue #150)
|
||||
- Fixed a buffer overflow in the (still not enabled) AES-256 code.
|
||||
|
||||
|
||||
|
||||
148
doc/pdfio.3
148
doc/pdfio.3
@@ -1,4 +1,4 @@
|
||||
.TH pdfio 3 "pdf read/write library" "2025-10-05" "pdf read/write library"
|
||||
.TH pdfio 3 "pdf read/write library" "2026-01-16" "pdf read/write library"
|
||||
.SH NAME
|
||||
pdfio \- pdf read/write library
|
||||
.SH Introduction
|
||||
@@ -2555,7 +2555,7 @@ ASCIIHexDecode filter (reading only)
|
||||
.TP 5
|
||||
PDFIO_FILTER_CCITTFAX
|
||||
.br
|
||||
CCITTFaxDecode filter
|
||||
CCITTFaxDecode filter (reading only)
|
||||
.TP 5
|
||||
PDFIO_FILTER_CRYPT
|
||||
.br
|
||||
@@ -2571,7 +2571,7 @@ FlateDecode filter
|
||||
.TP 5
|
||||
PDFIO_FILTER_JBIG2
|
||||
.br
|
||||
JBIG2Decode filter
|
||||
JBIG2Decode filter (reading only)
|
||||
.TP 5
|
||||
PDFIO_FILTER_JPX
|
||||
.br
|
||||
@@ -4924,6 +4924,91 @@ bool pdfioPageDictAddImage (
|
||||
pdfio_obj_t *obj
|
||||
);
|
||||
.fi
|
||||
.SS pdfioPageGetArray
|
||||
Get an array value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
pdfio_array_t * pdfioPageGetArray (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up an array value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetBinary
|
||||
Get a binary value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
unsigned char * pdfioPageGetBinary (
|
||||
pdfio_obj_t *page,
|
||||
const char *key,
|
||||
size_t *length
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a binary value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetBoolean
|
||||
Get a boolean value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
bool pdfioPageGetBoolean (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a boolean value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetDate
|
||||
Get a date value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
time_t pdfioPageGetDate (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a date value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetDict
|
||||
Get a dictionary value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
pdfio_dict_t * pdfioPageGetDict (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a dictionary value in the page dictionary, either in
|
||||
the specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetName
|
||||
Get a name value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
const char * pdfioPageGetName (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a name value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetNumStreams
|
||||
Get the number of content streams for a page object.
|
||||
.PP
|
||||
@@ -4932,6 +5017,63 @@ size_t pdfioPageGetNumStreams (
|
||||
pdfio_obj_t *page
|
||||
);
|
||||
.fi
|
||||
.SS pdfioPageGetNumber
|
||||
Get a number value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
double pdfioPageGetNumber (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a number value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetObj
|
||||
Get an indirect object value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
pdfio_obj_t * pdfioPageGetObj (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up an indirect object value in the page dictionary,
|
||||
either in the specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetRect
|
||||
Get a rectangle value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
pdfio_rect_t * pdfioPageGetRect (
|
||||
pdfio_obj_t *page,
|
||||
const char *key,
|
||||
pdfio_rect_t *rect
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a rectangle value in the page dictionary, either in
|
||||
the specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageGetString
|
||||
Get a string value from the page dictionary.
|
||||
.PP
|
||||
.nf
|
||||
const char * pdfioPageGetString (
|
||||
pdfio_obj_t *page,
|
||||
const char *key
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function looks up a string value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
|
||||
.SS pdfioPageOpenStream
|
||||
Open a content stream for a page.
|
||||
.PP
|
||||
|
||||
226
doc/pdfio.html
226
doc/pdfio.html
@@ -1,13 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>PDFio Programming Manual v1.6.0</title>
|
||||
<title>PDFio Programming Manual v1.7.0</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<meta name="generator" content="codedoc v3.8">
|
||||
<meta name="author" content="Michael R Sweet">
|
||||
<meta name="language" content="en-US">
|
||||
<meta name="copyright" content="Copyright © 2021-2025 by Michael R Sweet">
|
||||
<meta name="version" content="1.6.0">
|
||||
<meta name="version" content="1.7.0">
|
||||
<style type="text/css"><!--
|
||||
body {
|
||||
background: white;
|
||||
@@ -92,13 +92,16 @@ blockquote :first-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
p code, li code, p.code, pre, ul.code li {
|
||||
background: rgba(127,127,127,0.25);
|
||||
border: thin dotted gray;
|
||||
font-family: monospace;
|
||||
hyphens: manual;
|
||||
-webkit-hyphens: manual;
|
||||
}
|
||||
p code, li code {
|
||||
padding: 0 5px;
|
||||
}
|
||||
p.code, pre, ul.code li {
|
||||
background: rgba(127,127,127,0.25);
|
||||
border: thin dotted gray;
|
||||
padding: 10px;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
@@ -217,6 +220,21 @@ span.string {
|
||||
a:link:hover, a:visited:hover, a:active {
|
||||
color: #f06;
|
||||
}
|
||||
span.comment {
|
||||
color: #7c7;
|
||||
}
|
||||
span.directive {
|
||||
color: red;
|
||||
}
|
||||
span.number {
|
||||
color: #c64;
|
||||
}
|
||||
span.reserved {
|
||||
color: #77f;
|
||||
}
|
||||
span.string {
|
||||
color: #f7f;
|
||||
}
|
||||
}
|
||||
/* Show contents on left side in web browser */
|
||||
@media screen and (min-width: 800px) {
|
||||
@@ -251,7 +269,7 @@ span.string {
|
||||
<body>
|
||||
<div class="header">
|
||||
<p><img class="title" src="pdfio-512.png"></p>
|
||||
<h1 class="title">PDFio Programming Manual v1.6.0</h1>
|
||||
<h1 class="title">PDFio Programming Manual v1.7.0</h1>
|
||||
<p>Michael R Sweet</p>
|
||||
<p>Copyright © 2021-2025 by Michael R Sweet</p>
|
||||
</div>
|
||||
@@ -464,7 +482,17 @@ span.string {
|
||||
<li><a href="#pdfioPageDictAddColorSpace">pdfioPageDictAddColorSpace</a></li>
|
||||
<li><a href="#pdfioPageDictAddFont">pdfioPageDictAddFont</a></li>
|
||||
<li><a href="#pdfioPageDictAddImage">pdfioPageDictAddImage</a></li>
|
||||
<li><a href="#pdfioPageGetArray">pdfioPageGetArray</a></li>
|
||||
<li><a href="#pdfioPageGetBinary">pdfioPageGetBinary</a></li>
|
||||
<li><a href="#pdfioPageGetBoolean">pdfioPageGetBoolean</a></li>
|
||||
<li><a href="#pdfioPageGetDate">pdfioPageGetDate</a></li>
|
||||
<li><a href="#pdfioPageGetDict">pdfioPageGetDict</a></li>
|
||||
<li><a href="#pdfioPageGetName">pdfioPageGetName</a></li>
|
||||
<li><a href="#pdfioPageGetNumStreams">pdfioPageGetNumStreams</a></li>
|
||||
<li><a href="#pdfioPageGetNumber">pdfioPageGetNumber</a></li>
|
||||
<li><a href="#pdfioPageGetObj">pdfioPageGetObj</a></li>
|
||||
<li><a href="#pdfioPageGetRect">pdfioPageGetRect</a></li>
|
||||
<li><a href="#pdfioPageGetString">pdfioPageGetString</a></li>
|
||||
<li><a href="#pdfioPageOpenStream">pdfioPageOpenStream</a></li>
|
||||
<li><a href="#pdfioStreamClose">pdfioStreamClose</a></li>
|
||||
<li><a href="#pdfioStreamConsume">pdfioStreamConsume</a></li>
|
||||
@@ -5409,6 +5437,116 @@ array that was created using the
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetArray">pdfioPageGetArray</a></h3>
|
||||
<p class="description">Get an array value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioPageGetArray(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Array or <code>NULL</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up an array value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetBinary">pdfioPageGetBinary</a></h3>
|
||||
<p class="description">Get a binary value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<span class="reserved">unsigned</span> <span class="reserved">char</span> *pdfioPageGetBinary(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key, size_t *length);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
<tr><th>length</th>
|
||||
<td class="description">Length of value</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Pointer to binary data or <code>NULL</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a binary value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetBoolean">pdfioPageGetBoolean</a></h3>
|
||||
<p class="description">Get a boolean value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<span class="reserved">bool</span> pdfioPageGetBoolean(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Boolean value or <code>false</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a boolean value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetDate">pdfioPageGetDate</a></h3>
|
||||
<p class="description">Get a date value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
time_t pdfioPageGetDate(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Date/time or <code>0</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a date value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetDict">pdfioPageGetDict</a></h3>
|
||||
<p class="description">Get a dictionary value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<a href="#pdfio_dict_t">pdfio_dict_t</a> *pdfioPageGetDict(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Dictionary or <code>NULL</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a dictionary value in the page dictionary, either in
|
||||
the specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetName">pdfioPageGetName</a></h3>
|
||||
<p class="description">Get a name value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioPageGetName(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Name string or <code>NULL</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a name value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
</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">
|
||||
@@ -5420,6 +5558,80 @@ size_t pdfioPageGetNumStreams(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page);</p>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Number of streams</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetNumber">pdfioPageGetNumber</a></h3>
|
||||
<p class="description">Get a number value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<span class="reserved">double</span> pdfioPageGetNumber(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Number value or <code>0.0</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a number value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetObj">pdfioPageGetObj</a></h3>
|
||||
<p class="description">Get an indirect object value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioPageGetObj(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Object or <code>NULL</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up an indirect object value in the page dictionary,
|
||||
either in the specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetRect">pdfioPageGetRect</a></h3>
|
||||
<p class="description">Get a rectangle value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<a href="#pdfio_rect_t">pdfio_rect_t</a> *pdfioPageGetRect(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key, <a href="#pdfio_rect_t">pdfio_rect_t</a> *rect);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
<tr><th>rect</th>
|
||||
<td class="description">Rectangle</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">Rectangle or <code>NULL</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a rectangle value in the page dictionary, either in
|
||||
the specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.7 </span><a id="pdfioPageGetString">pdfioPageGetString</a></h3>
|
||||
<p class="description">Get a string value from the page dictionary.</p>
|
||||
<p class="code">
|
||||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioPageGetString(<a href="#pdfio_obj_t">pdfio_obj_t</a> *page, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>page</th>
|
||||
<td class="description">Page object</td></tr>
|
||||
<tr><th>key</th>
|
||||
<td class="description">Dictionary key</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">String value or <code>NULL</code> if none</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function looks up a string value in the page dictionary, either in the
|
||||
specified object or one of its parents.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><a id="pdfioPageOpenStream">pdfioPageOpenStream</a></h3>
|
||||
<p class="description">Open a content stream for a page.</p>
|
||||
<p class="code">
|
||||
@@ -5759,11 +5971,11 @@ typedef enum <a href="#pdfio_valtype_e">pdfio_valtype_e</a> pdfio_valtype_t;
|
||||
<table class="list"><tbody>
|
||||
<tr><th>PDFIO_FILTER_ASCII85 </th><td class="description">ASCII85Decode filter (reading only)</td></tr>
|
||||
<tr><th>PDFIO_FILTER_ASCIIHEX </th><td class="description">ASCIIHexDecode filter (reading only)</td></tr>
|
||||
<tr><th>PDFIO_FILTER_CCITTFAX </th><td class="description">CCITTFaxDecode filter</td></tr>
|
||||
<tr><th>PDFIO_FILTER_CCITTFAX </th><td class="description">CCITTFaxDecode filter (reading only)</td></tr>
|
||||
<tr><th>PDFIO_FILTER_CRYPT </th><td class="description">Encryption filter</td></tr>
|
||||
<tr><th>PDFIO_FILTER_DCT </th><td class="description">DCTDecode (JPEG) filter</td></tr>
|
||||
<tr><th>PDFIO_FILTER_FLATE </th><td class="description">FlateDecode filter</td></tr>
|
||||
<tr><th>PDFIO_FILTER_JBIG2 </th><td class="description">JBIG2Decode filter</td></tr>
|
||||
<tr><th>PDFIO_FILTER_JBIG2 </th><td class="description">JBIG2Decode filter (reading only)</td></tr>
|
||||
<tr><th>PDFIO_FILTER_JPX </th><td class="description">JPXDecode filter (reading only)</td></tr>
|
||||
<tr><th>PDFIO_FILTER_LZW </th><td class="description">LZWDecode filter (reading only)</td></tr>
|
||||
<tr><th>PDFIO_FILTER_NONE </th><td class="description">No filter</td></tr>
|
||||
|
||||
291
pdfio-page.c
291
pdfio-page.c
@@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
static _pdfio_value_t *get_contents(pdfio_obj_t *page);
|
||||
static _pdfio_value_t *get_page_value(pdfio_obj_t *page, const char *key);
|
||||
|
||||
|
||||
//
|
||||
@@ -52,6 +53,158 @@ pdfioPageCopy(pdfio_file_t *pdf, // I - PDF file
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetArray()' - Get an array value from the page dictionary.
|
||||
//
|
||||
// This function looks up an array value in the page dictionary, either in the
|
||||
// specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
pdfio_array_t * // O - Array or `NULL` if none
|
||||
pdfioPageGetArray(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_ARRAY)
|
||||
return (v->value.array);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetBinary()' - Get a binary value from the page dictionary.
|
||||
//
|
||||
// This function looks up a binary value in the page dictionary, either in the
|
||||
// specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
unsigned char * // O - Pointer to binary data or `NULL` if none
|
||||
pdfioPageGetBinary(pdfio_obj_t *page, // I - Page object
|
||||
const char *key, // I - Dictionary key
|
||||
size_t *length) // O - Length of value
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_BINARY)
|
||||
{
|
||||
if (length)
|
||||
*length = v->value.binary.datalen;
|
||||
|
||||
return (v->value.binary.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetBoolean()' - Get a boolean value from the page dictionary.
|
||||
//
|
||||
// This function looks up a boolean value in the page dictionary, either in the
|
||||
// specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
bool // O - Boolean value or `false` if none
|
||||
pdfioPageGetBoolean(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_ARRAY)
|
||||
return (v->value.boolean);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetDate()' - Get a date value from the page dictionary.
|
||||
//
|
||||
// This function looks up a date value in the page dictionary, either in the
|
||||
// specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
time_t // O - Date/time or `0` if none
|
||||
pdfioPageGetDate(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_DATE)
|
||||
return (v->value.date);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetDict()' - Get a dictionary value from the page dictionary.
|
||||
//
|
||||
// This function looks up a dictionary value in the page dictionary, either in
|
||||
// the specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
pdfio_dict_t * // O - Dictionary or `NULL` if none
|
||||
pdfioPageGetDict(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_DICT)
|
||||
return (v->value.dict);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetName()' - Get a name value from the page dictionary.
|
||||
//
|
||||
// This function looks up a name value in the page dictionary, either in the
|
||||
// specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
const char * // O - Name string or `NULL` if none
|
||||
pdfioPageGetName(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_NAME)
|
||||
return (v->value.name);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetNumStreams()' - Get the number of content streams for a page object.
|
||||
//
|
||||
@@ -73,6 +226,112 @@ pdfioPageGetNumStreams(
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetNumber()' - Get a number value from the page dictionary.
|
||||
//
|
||||
// This function looks up a number value in the page dictionary, either in the
|
||||
// specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
double // O - Number value or `0.0` if none
|
||||
pdfioPageGetNumber(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_NUMBER)
|
||||
return (v->value.number);
|
||||
else
|
||||
return (0.0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetObj()' - Get an indirect object value from the page dictionary.
|
||||
//
|
||||
// This function looks up an indirect object value in the page dictionary,
|
||||
// either in the specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
pdfio_obj_t * // O - Object or `NULL` if none
|
||||
pdfioPageGetObj(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_INDIRECT)
|
||||
return (pdfioFileFindObj(page->pdf, v->value.indirect.number));
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetRect()' - Get a rectangle value from the page dictionary.
|
||||
//
|
||||
// This function looks up a rectangle value in the page dictionary, either in
|
||||
// the specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
pdfio_rect_t * // O - Rectangle or `NULL` if none
|
||||
pdfioPageGetRect(pdfio_obj_t *page, // I - Page object
|
||||
const char *key, // I - Dictionary key
|
||||
pdfio_rect_t *rect) // O - Rectangle
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_ARRAY && pdfioArrayGetSize(v->value.array) == 4)
|
||||
{
|
||||
rect->x1 = pdfioArrayGetNumber(v->value.array, 0);
|
||||
rect->y1 = pdfioArrayGetNumber(v->value.array, 1);
|
||||
rect->x2 = pdfioArrayGetNumber(v->value.array, 2);
|
||||
rect->y2 = pdfioArrayGetNumber(v->value.array, 3);
|
||||
|
||||
return (rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageGetString()' - Get a string value from the page dictionary.
|
||||
//
|
||||
// This function looks up a string value in the page dictionary, either in the
|
||||
// specified object or one of its parents.
|
||||
//
|
||||
// @since PDFio 1.7@
|
||||
//
|
||||
|
||||
const char * // O - String value or `NULL` if none
|
||||
pdfioPageGetString(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = get_page_value(page, key);
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_STRING)
|
||||
return (v->value.string);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'pdfioPageOpenStream()' - Open a content stream for a page.
|
||||
//
|
||||
@@ -158,3 +417,35 @@ get_contents(pdfio_obj_t *page) // I - Page object
|
||||
|
||||
return (contents);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'get_page_value()' - Get a page dictionary value, including parents.
|
||||
//
|
||||
|
||||
static _pdfio_value_t * // O - Dictionary value or `NULL` if none
|
||||
get_page_value(pdfio_obj_t *page, // I - Page object
|
||||
const char *key) // I - Dictionary key
|
||||
{
|
||||
_pdfio_value_t *v = NULL; // Dictionary value
|
||||
|
||||
|
||||
while (page != NULL)
|
||||
{
|
||||
// Load the page object as needed...
|
||||
if (page->value.type == PDFIO_VALTYPE_NONE && !_pdfioObjLoad(page))
|
||||
break;
|
||||
|
||||
// If there isn't a dictionary for the object, stop...
|
||||
if (page->value.type != PDFIO_VALTYPE_DICT)
|
||||
break;
|
||||
|
||||
// Lookup the key...
|
||||
if ((v = _pdfioDictGetValue(page->value.value.dict, key)) != NULL)
|
||||
break;
|
||||
|
||||
page = pdfioDictGetObj(page->value.value.dict, "Parent");
|
||||
}
|
||||
|
||||
return (v);
|
||||
}
|
||||
|
||||
10
pdfio.h
10
pdfio.h
@@ -238,7 +238,17 @@ extern const char *pdfioObjGetType(pdfio_obj_t *obj) _PDFIO_PUBLIC;
|
||||
extern pdfio_stream_t *pdfioObjOpenStream(pdfio_obj_t *obj, bool decode) _PDFIO_PUBLIC;
|
||||
|
||||
extern bool pdfioPageCopy(pdfio_file_t *pdf, pdfio_obj_t *srcpage) _PDFIO_PUBLIC;
|
||||
extern pdfio_array_t *pdfioPageGetArray(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern unsigned char *pdfioPageGetBinary(pdfio_obj_t *page, const char *key, size_t *length) _PDFIO_PUBLIC;
|
||||
extern bool pdfioPageGetBoolean(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern time_t pdfioDictPageDate(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern pdfio_dict_t *pdfioPageGetDict(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern const char *pdfioPageGetName(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern size_t pdfioPageGetNumStreams(pdfio_obj_t *page) _PDFIO_PUBLIC;
|
||||
extern double pdfioPageGetNumber(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern pdfio_obj_t *pdfioPageGetObj(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern pdfio_rect_t *pdfioPageGetRect(pdfio_obj_t *page, const char *key, pdfio_rect_t *rect) _PDFIO_PUBLIC;
|
||||
extern const char *pdfioPageGetString(pdfio_obj_t *page, const char *key) _PDFIO_PUBLIC;
|
||||
extern pdfio_stream_t *pdfioPageOpenStream(pdfio_obj_t *page, size_t n, bool decode) _PDFIO_PUBLIC;
|
||||
|
||||
extern bool pdfioStreamClose(pdfio_stream_t *st) _PDFIO_PUBLIC;
|
||||
|
||||
10
pdfio1.def
10
pdfio1.def
@@ -258,7 +258,17 @@ pdfioPageCopy
|
||||
pdfioPageDictAddColorSpace
|
||||
pdfioPageDictAddFont
|
||||
pdfioPageDictAddImage
|
||||
pdfioPageGetArray
|
||||
pdfioPageGetBinary
|
||||
pdfioPageGetBoolean
|
||||
pdfioPageGetDate
|
||||
pdfioPageGetDict
|
||||
pdfioPageGetName
|
||||
pdfioPageGetNumber
|
||||
pdfioPageGetNumStreams
|
||||
pdfioPageGetObj
|
||||
pdfioPageGetRect
|
||||
pdfioPageGetString
|
||||
pdfioPageOpenStream
|
||||
pdfioStreamClose
|
||||
pdfioStreamConsume
|
||||
|
||||
14
testpdfio.c
14
testpdfio.c
@@ -658,19 +658,7 @@ do_test_file(const char *filename, // I - PDF filename
|
||||
pdfio_stream_t *st; // Page content stream
|
||||
|
||||
memset(&media_box, 0, sizeof(media_box));
|
||||
dict = pdfioObjGetDict(obj);
|
||||
|
||||
if (!pdfioDictGetRect(dict, "MediaBox", &media_box))
|
||||
{
|
||||
pdfio_obj_t *parent; // Parent object
|
||||
|
||||
while ((parent = pdfioDictGetObj(dict, "Parent")) != NULL)
|
||||
{
|
||||
dict = pdfioObjGetDict(parent);
|
||||
if (pdfioDictGetRect(dict, "MediaBox", &media_box))
|
||||
break;
|
||||
}
|
||||
}
|
||||
pdfioPageGetRect(obj, "MediaBox", &media_box);
|
||||
|
||||
if ((st = pdfioPageOpenStream(obj, /*number*/0, /*decode*/true)) != NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user