mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2025-12-24 05:56:25 +01:00
Merge branch 'michaelrsweet:master' into feature/pdfa-subset-support
This commit is contained in:
@@ -26,6 +26,7 @@ v1.6.0 - YYYY-MM-DD
|
||||
v1.5.5 - YYYY-MM-DD
|
||||
-------------------
|
||||
|
||||
- Fixed unsupported filter error (Issue #130)
|
||||
- Fixed EOF comment written to the PDF (Issue #136)
|
||||
- Fixed TTF cmap underflow error.
|
||||
- Fixed some Clang warnings.
|
||||
|
||||
96
doc/pdfio.3
96
doc/pdfio.3
@@ -1,4 +1,4 @@
|
||||
.TH pdfio 3 "pdf read/write library" "2025-08-26" "pdf read/write library"
|
||||
.TH pdfio 3 "pdf read/write library" "2025-09-30" "pdf read/write library"
|
||||
.SH NAME
|
||||
pdfio \- pdf read/write library
|
||||
.SH Introduction
|
||||
@@ -1032,6 +1032,45 @@ pdfioContentTextShowf draws a formatted string in a text block
|
||||
pdfioContentTextShowJustified draws an array of literal strings with offsets between them
|
||||
|
||||
|
||||
.SS Tagged and Marked PDF Content
|
||||
.PP
|
||||
Content in a page stream can be tagged to help a PDF reader application know the kind and organization of that content. Content inserted using the PDFio Page Stream Functions can be tagged by surrounding it with the pdfioContentBeginMarked and pdfioContentEndMarked functions.
|
||||
.PP
|
||||
The pdfioContentBeginMarked function accepts a named tag and optional dictionary of attributes such as the marked content identifier ("MCID"). For example, the following code tags a paragraph of text:
|
||||
.nf
|
||||
|
||||
pdfio_file_t *pdf; // PDF file
|
||||
pdfio_stream_t *st; // Page stream
|
||||
|
||||
pdfioContentBeginMarked(st, "P", /*dict*/NULL);
|
||||
|
||||
pdfioContentTextShow(st, /*unicode*/false, "Mary had a little lamb\\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "whose fleece was white as snow.\\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "And everywhere that Mary went\\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "the lamb was sure to go,\\n");
|
||||
|
||||
pdfioContentEndMarked(st);
|
||||
.fi
|
||||
.PP
|
||||
To mark the same paragraph with a content identifier you would first create a dictionary containing the "MCID" key/value pair and then mark the paragraph with that dictionary:
|
||||
.nf
|
||||
|
||||
pdfio_file_t *pdf; // PDF file
|
||||
pdfio_stream_t *st; // Page stream
|
||||
pdfio_dict_t *dict; // Content dictionary
|
||||
|
||||
dict = pdfioDictCreate(pdf);
|
||||
pdfioDictSetNumber(dict, "MCID", 42);
|
||||
|
||||
pdfioContentBeginMarked(st, "P", dict);
|
||||
|
||||
pdfioContentTextShow(st, /*unicode*/false, "Mary had a little lamb\\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "whose fleece was white as snow.\\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "And everywhere that Mary went\\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "the lamb was sure to go,\\n");
|
||||
|
||||
pdfioContentEndMarked(st);
|
||||
.fi
|
||||
.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.
|
||||
@@ -1691,6 +1730,9 @@ The md2pdf program needs to maintain three sets of state \- one for the markdown
|
||||
// State for the current page
|
||||
pdfio_stream_t *st; // Current page stream
|
||||
double y; // Current position on page
|
||||
const char *tag; // Current block tag
|
||||
bool in_table, // Are we in a table?
|
||||
in_row; // Are we in a table row?
|
||||
docfont_t font; // Current font
|
||||
double fsize; // Current font size
|
||||
doccolor_t color; // Current color
|
||||
@@ -2167,6 +2209,9 @@ Code blocks consist of one or more lines of plain monospaced text. We draw a lig
|
||||
pdfioContentFillAndStroke(dd\->st, false);
|
||||
|
||||
// Start a code text block...
|
||||
dd\->tag = "P";
|
||||
pdfioContentBeginMarked(dd\->st, dd\->tag, /*dict*/NULL);
|
||||
|
||||
set_font(dd, DOCFONT_MONOSPACE, SIZE_CODEBLOCK);
|
||||
pdfioContentTextBegin(dd\->st);
|
||||
pdfioContentTextMoveTo(dd\->st, left, dd\->y);
|
||||
@@ -2203,6 +2248,9 @@ Code blocks consist of one or more lines of plain monospaced text. We draw a lig
|
||||
pdfioContentTextEnd(dd\->st);
|
||||
dd\->y += lineheight;
|
||||
|
||||
pdfioContentEndMarked(dd\->st);
|
||||
dd\->tag = NULL;
|
||||
|
||||
// Draw the bottom padding...
|
||||
set_color(dd, DOCCOLOR_LTGRAY);
|
||||
pdfioContentPathRect(dd\->st, left \- CODE_PADDING,
|
||||
@@ -2332,8 +2380,17 @@ Finally, we render each row in the table:
|
||||
.nf
|
||||
|
||||
// Render each table row...
|
||||
dd\->in_table = true;
|
||||
|
||||
if (dd\->st)
|
||||
pdfioContentBeginMarked(dd\->st, "Table", /*dict*/NULL);
|
||||
|
||||
for (row = 0, rowptr = rows; row < num_rows; row ++, rowptr ++)
|
||||
render_row(dd, num_cols, cols, rowptr);
|
||||
|
||||
pdfioContentEndMarked(dd\->st);
|
||||
|
||||
dd\->in_table = false;
|
||||
.fi
|
||||
.PP
|
||||
Rendering the Markdown Document
|
||||
@@ -2957,6 +3014,30 @@ bool pdfioArrayRemove (
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SS pdfioContentBeginMarked
|
||||
Start marked content with an optional dictionary.
|
||||
.PP
|
||||
.nf
|
||||
bool pdfioContentBeginMarked (
|
||||
pdfio_stream_t *st,
|
||||
const char *tag,
|
||||
pdfio_dict_t *dict
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function starts an area of marked content with an optional dictionary.
|
||||
It must be paired with a call to the \fIpdfioContentEndMarked\fR function.
|
||||
.PP
|
||||
The "tag" argument specifies the tag name string for the content such as "P"
|
||||
for a paragraph, "H1" for a top-level heading, and so forth. The "dict"
|
||||
argument specifies an optional dictionary of properties for the content such
|
||||
as the marked content identifier ("MCID") number.
|
||||
.PP
|
||||
Calling this function sets the "Marked" key in the "MarkInfo" dictionary of
|
||||
the document catalog. The caller is responsible for setting the
|
||||
"StructTreeRoot" dictionary when creating marked content.
|
||||
|
||||
|
||||
.SS pdfioContentClip
|
||||
Clip output to the current path.
|
||||
.PP
|
||||
@@ -2982,6 +3063,19 @@ bool pdfioContentDrawImage (
|
||||
.PP
|
||||
The object name must be part of the page dictionary resources, typically
|
||||
using the \fIpdfioPageDictAddImage\fR function.
|
||||
.SS pdfioContentEndMarked
|
||||
End marked content.
|
||||
.PP
|
||||
.nf
|
||||
bool pdfioContentEndMarked (
|
||||
pdfio_stream_t *st
|
||||
);
|
||||
.fi
|
||||
.PP
|
||||
This function ends an area of marked content that was started using the
|
||||
\fIpdfioContentBeginMarked\fR function.
|
||||
|
||||
|
||||
.SS pdfioContentFill
|
||||
Fill the current path.
|
||||
.PP
|
||||
|
||||
@@ -273,6 +273,7 @@ span.string {
|
||||
<li><a href="#pdf-objects">PDF Objects</a></li>
|
||||
<li><a href="#pdf-streams">PDF Streams</a></li>
|
||||
<li><a href="#pdf-content-helper-functions">PDF Content Helper Functions</a></li>
|
||||
<li><a href="#tagged-and-marked-pdf-content">Tagged and Marked PDF Content</a></li>
|
||||
</ul></li>
|
||||
<li><a href="#examples">Examples</a><ul class="subcontents">
|
||||
<li><a href="#read-pdf-metadata">Read PDF Metadata</a></li>
|
||||
@@ -310,8 +311,10 @@ span.string {
|
||||
<li><a href="#pdfioArrayGetString">pdfioArrayGetString</a></li>
|
||||
<li><a href="#pdfioArrayGetType">pdfioArrayGetType</a></li>
|
||||
<li><a href="#pdfioArrayRemove">pdfioArrayRemove</a></li>
|
||||
<li><a href="#pdfioContentBeginMarked">pdfioContentBeginMarked</a></li>
|
||||
<li><a href="#pdfioContentClip">pdfioContentClip</a></li>
|
||||
<li><a href="#pdfioContentDrawImage">pdfioContentDrawImage</a></li>
|
||||
<li><a href="#pdfioContentEndMarked">pdfioContentEndMarked</a></li>
|
||||
<li><a href="#pdfioContentFill">pdfioContentFill</a></li>
|
||||
<li><a href="#pdfioContentFillAndStroke">pdfioContentFillAndStroke</a></li>
|
||||
<li><a href="#pdfioContentMatrixConcat">pdfioContentMatrixConcat</a></li>
|
||||
@@ -1158,6 +1161,38 @@ pdfio_obj_t *img =
|
||||
<li><p><a href="#pdfioContentTextShowJustified"><code>pdfioContentTextShowJustified</code></a> draws an array of literal strings with offsets between them</p>
|
||||
</li>
|
||||
</ul>
|
||||
<h3 class="title" id="tagged-and-marked-pdf-content">Tagged and Marked PDF Content</h3>
|
||||
<p>Content in a page stream can be tagged to help a PDF reader application know the kind and organization of that content. Content inserted using the PDFio <a href="#page-stream-functions">Page Stream Functions</a> can be tagged by surrounding it with the <a href="#pdfioContentBeginMarked"><code>pdfioContentBeginMarked</code></a> and <a href="#pdfioContentEndMarked"><code>pdfioContentEndMarked</code></a> functions.</p>
|
||||
<p>The <code>pdfioContentBeginMarked</code> function accepts a named tag and optional dictionary of attributes such as the marked content identifier ("MCID"). For example, the following code tags a paragraph of text:</p>
|
||||
<pre><code class="language-c">pdfio_file_t *pdf; <span class="comment">// PDF file</span>
|
||||
pdfio_stream_t *st; <span class="comment">// Page stream</span>
|
||||
|
||||
pdfioContentBeginMarked(st, <span class="string">"P"</span>, <span class="comment">/*dict*/</span>NULL);
|
||||
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"Mary had a little lamb\n"</span>);
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"whose fleece was white as snow.\n"</span>);
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"And everywhere that Mary went\n"</span>);
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"the lamb was sure to go,\n"</span>);
|
||||
|
||||
pdfioContentEndMarked(st);
|
||||
</code></pre>
|
||||
<p>To mark the same paragraph with a content identifier you would first create a dictionary containing the "MCID" key/value pair and then mark the paragraph with that dictionary:</p>
|
||||
<pre><code class="language-c">pdfio_file_t *pdf; <span class="comment">// PDF file</span>
|
||||
pdfio_stream_t *st; <span class="comment">// Page stream</span>
|
||||
pdfio_dict_t *dict; <span class="comment">// Content dictionary</span>
|
||||
|
||||
dict = pdfioDictCreate(pdf);
|
||||
pdfioDictSetNumber(dict, <span class="string">"MCID"</span>, <span class="number">42</span>);
|
||||
|
||||
pdfioContentBeginMarked(st, <span class="string">"P"</span>, dict);
|
||||
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"Mary had a little lamb\n"</span>);
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"whose fleece was white as snow.\n"</span>);
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"And everywhere that Mary went\n"</span>);
|
||||
pdfioContentTextShow(st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, <span class="string">"the lamb was sure to go,\n"</span>);
|
||||
|
||||
pdfioContentEndMarked(st);
|
||||
</code></pre>
|
||||
<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>
|
||||
@@ -1753,6 +1788,9 @@ pdfioStreamClose(page_st);
|
||||
<span class="comment">// State for the current page</span>
|
||||
pdfio_stream_t *st; <span class="comment">// Current page stream</span>
|
||||
<span class="reserved">double</span> y; <span class="comment">// Current position on page</span>
|
||||
<span class="reserved">const</span> <span class="reserved">char</span> *tag; <span class="comment">// Current block tag</span>
|
||||
<span class="reserved">bool</span> in_table, <span class="comment">// Are we in a table?</span>
|
||||
in_row; <span class="comment">// Are we in a table row?</span>
|
||||
docfont_t font; <span class="comment">// Current font</span>
|
||||
<span class="reserved">double</span> fsize; <span class="comment">// Current font size</span>
|
||||
doccolor_t color; <span class="comment">// Current color</span>
|
||||
@@ -2130,6 +2168,9 @@ pdfioContentPathRect(dd->st, left - CODE_PADDING, dd->y + SIZE_CODEBLOCK,
|
||||
pdfioContentFillAndStroke(dd->st, <span class="reserved">false</span>);
|
||||
|
||||
<span class="comment">// Start a code text block...</span>
|
||||
dd->tag = <span class="string">"P"</span>;
|
||||
pdfioContentBeginMarked(dd->st, dd->tag, <span class="comment">/*dict*/</span>NULL);
|
||||
|
||||
set_font(dd, DOCFONT_MONOSPACE, SIZE_CODEBLOCK);
|
||||
pdfioContentTextBegin(dd->st);
|
||||
pdfioContentTextMoveTo(dd->st, left, dd->y);
|
||||
@@ -2166,6 +2207,9 @@ pdfioContentTextMoveTo(dd->st, left, dd->y);
|
||||
pdfioContentTextEnd(dd->st);
|
||||
dd->y += lineheight;
|
||||
|
||||
pdfioContentEndMarked(dd->st);
|
||||
dd->tag = NULL;
|
||||
|
||||
<span class="comment">// Draw the bottom padding...</span>
|
||||
set_color(dd, DOCCOLOR_LTGRAY);
|
||||
pdfioContentPathRect(dd->st, left - CODE_PADDING,
|
||||
@@ -2276,8 +2320,17 @@ pdfioContentFillAndStroke(dd->st, <span class="reserved">false</span>);
|
||||
</code></pre>
|
||||
<p>Finally, we render each row in the table:</p>
|
||||
<pre><code class="language-c"><span class="comment">// Render each table row...</span>
|
||||
dd->in_table = <span class="reserved">true</span>;
|
||||
|
||||
<span class="reserved">if</span> (dd->st)
|
||||
pdfioContentBeginMarked(dd->st, <span class="string">"Table"</span>, <span class="comment">/*dict*/</span>NULL);
|
||||
|
||||
<span class="reserved">for</span> (row = <span class="number">0</span>, rowptr = rows; row < num_rows; row ++, rowptr ++)
|
||||
render_row(dd, num_cols, cols, rowptr);
|
||||
|
||||
pdfioContentEndMarked(dd->st);
|
||||
|
||||
dd->in_table = <span class="reserved">false</span>;
|
||||
</code></pre>
|
||||
<h4 id="rendering-the-markdown-document">Rendering the Markdown Document</h4>
|
||||
<p>The formatted content in arrays of <code>linefrag_t</code> and <code>tablerow_t</code> structures are passed to the <code>render_line</code> and <code>render_row</code> functions respectively to produce content in the PDF document.</p>
|
||||
@@ -2767,6 +2820,35 @@ size_t pdfioArrayGetSize(<a href="#pdfio_array_t">pdfio_array_t</a> *a);</p>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description"><code>true</code> on success, <code>false</code> otherwise</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.6 </span><a id="pdfioContentBeginMarked">pdfioContentBeginMarked</a></h3>
|
||||
<p class="description">Start marked content with an optional dictionary.</p>
|
||||
<p class="code">
|
||||
<span class="reserved">bool</span> pdfioContentBeginMarked(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">char</span> *tag, <a href="#pdfio_dict_t">pdfio_dict_t</a> *dict);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>st</th>
|
||||
<td class="description">Stream</td></tr>
|
||||
<tr><th>tag</th>
|
||||
<td class="description">Tag name of marked content</td></tr>
|
||||
<tr><th>dict</th>
|
||||
<td class="description">Dictionary of parameters or <code>NULL</code> if none</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function starts an area of marked content with an optional dictionary.
|
||||
It must be paired with a call to the <a href="#pdfioContentEndMarked"><code>pdfioContentEndMarked</code></a> function.<br>
|
||||
<br>
|
||||
The "tag" argument specifies the tag name string for the content such as "P"
|
||||
for a paragraph, "H1" for a top-level heading, and so forth. The "dict"
|
||||
argument specifies an optional dictionary of properties for the content such
|
||||
as the marked content identifier ("MCID") number.<br>
|
||||
<br>
|
||||
Calling this function sets the "Marked" key in the "MarkInfo" dictionary of
|
||||
the document catalog. The caller is responsible for setting the
|
||||
"StructTreeRoot" dictionary when creating marked content.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><a id="pdfioContentClip">pdfioContentClip</a></h3>
|
||||
<p class="description">Clip output to the current path.</p>
|
||||
<p class="code">
|
||||
@@ -2804,6 +2886,22 @@ size_t pdfioArrayGetSize(<a href="#pdfio_array_t">pdfio_array_t</a> *a);</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The object name must be part of the page dictionary resources, typically
|
||||
using the <a href="#pdfioPageDictAddImage"><code>pdfioPageDictAddImage</code></a> function.</p>
|
||||
<h3 class="function"><span class="info"> PDFio 1.6 </span><a id="pdfioContentEndMarked">pdfioContentEndMarked</a></h3>
|
||||
<p class="description">End marked content.</p>
|
||||
<p class="code">
|
||||
<span class="reserved">bool</span> pdfioContentEndMarked(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);</p>
|
||||
<h4 class="parameters">Parameters</h4>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>st</th>
|
||||
<td class="description">Stream</td></tr>
|
||||
</tbody></table>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">This function ends an area of marked content that was started using the
|
||||
<a href="#pdfioContentBeginMarked"><code>pdfioContentBeginMarked</code></a> function.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><a id="pdfioContentFill">pdfioContentFill</a></h3>
|
||||
<p class="description">Fill the current path.</p>
|
||||
<p class="code">
|
||||
|
||||
67
doc/pdfio.md
67
doc/pdfio.md
@@ -868,6 +868,55 @@ escaping, as needed:
|
||||
offsets between them
|
||||
|
||||
|
||||
Tagged and Marked PDF Content
|
||||
-----------------------------
|
||||
|
||||
Content in a page stream can be tagged to help a PDF reader application know the
|
||||
kind and organization of that content. Content inserted using the PDFio
|
||||
[Page Stream Functions](@) can be tagged by surrounding it with the
|
||||
[`pdfioContentBeginMarked`](@@) and [`pdfioContentEndMarked`](@@) functions.
|
||||
|
||||
The `pdfioContentBeginMarked` function accepts a named tag and optional
|
||||
dictionary of attributes such as the marked content identifier ("MCID"). For
|
||||
example, the following code tags a paragraph of text:
|
||||
|
||||
```c
|
||||
pdfio_file_t *pdf; // PDF file
|
||||
pdfio_stream_t *st; // Page stream
|
||||
|
||||
pdfioContentBeginMarked(st, "P", /*dict*/NULL);
|
||||
|
||||
pdfioContentTextShow(st, /*unicode*/false, "Mary had a little lamb\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "whose fleece was white as snow.\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "And everywhere that Mary went\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "the lamb was sure to go,\n");
|
||||
|
||||
pdfioContentEndMarked(st);
|
||||
```
|
||||
|
||||
To mark the same paragraph with a content identifier you would first create a
|
||||
dictionary containing the "MCID" key/value pair and then mark the paragraph with
|
||||
that dictionary:
|
||||
|
||||
```c
|
||||
pdfio_file_t *pdf; // PDF file
|
||||
pdfio_stream_t *st; // Page stream
|
||||
pdfio_dict_t *dict; // Content dictionary
|
||||
|
||||
dict = pdfioDictCreate(pdf);
|
||||
pdfioDictSetNumber(dict, "MCID", 42);
|
||||
|
||||
pdfioContentBeginMarked(st, "P", dict);
|
||||
|
||||
pdfioContentTextShow(st, /*unicode*/false, "Mary had a little lamb\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "whose fleece was white as snow.\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "And everywhere that Mary went\n");
|
||||
pdfioContentTextShow(st, /*unicode*/false, "the lamb was sure to go,\n");
|
||||
|
||||
pdfioContentEndMarked(st);
|
||||
```
|
||||
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
@@ -1597,6 +1646,9 @@ typedef struct docdata_s // Document formatting data
|
||||
// State for the current page
|
||||
pdfio_stream_t *st; // Current page stream
|
||||
double y; // Current position on page
|
||||
const char *tag; // Current block tag
|
||||
bool in_table, // Are we in a table?
|
||||
in_row; // Are we in a table row?
|
||||
docfont_t font; // Current font
|
||||
double fsize; // Current font size
|
||||
doccolor_t color; // Current color
|
||||
@@ -2100,6 +2152,9 @@ pdfioContentPathRect(dd->st, left - CODE_PADDING, dd->y + SIZE_CODEBLOCK,
|
||||
pdfioContentFillAndStroke(dd->st, false);
|
||||
|
||||
// Start a code text block...
|
||||
dd->tag = "P";
|
||||
pdfioContentBeginMarked(dd->st, dd->tag, /*dict*/NULL);
|
||||
|
||||
set_font(dd, DOCFONT_MONOSPACE, SIZE_CODEBLOCK);
|
||||
pdfioContentTextBegin(dd->st);
|
||||
pdfioContentTextMoveTo(dd->st, left, dd->y);
|
||||
@@ -2136,6 +2191,9 @@ for (code = mmdGetFirstChild(block); code; code = mmdGetNextSibling(code))
|
||||
pdfioContentTextEnd(dd->st);
|
||||
dd->y += lineheight;
|
||||
|
||||
pdfioContentEndMarked(dd->st);
|
||||
dd->tag = NULL;
|
||||
|
||||
// Draw the bottom padding...
|
||||
set_color(dd, DOCCOLOR_LTGRAY);
|
||||
pdfioContentPathRect(dd->st, left - CODE_PADDING,
|
||||
@@ -2276,8 +2334,17 @@ Finally, we render each row in the table:
|
||||
|
||||
```c
|
||||
// Render each table row...
|
||||
dd->in_table = true;
|
||||
|
||||
if (dd->st)
|
||||
pdfioContentBeginMarked(dd->st, "Table", /*dict*/NULL);
|
||||
|
||||
for (row = 0, rowptr = rows; row < num_rows; row ++, rowptr ++)
|
||||
render_row(dd, num_cols, cols, rowptr);
|
||||
|
||||
pdfioContentEndMarked(dd->st);
|
||||
|
||||
dd->in_table = false;
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -467,20 +467,29 @@ pdfioArrayCreateColorFromStandard(
|
||||
// This function starts an area of marked content with an optional dictionary.
|
||||
// It must be paired with a call to the @link pdfioContentEndMarked@ function.
|
||||
//
|
||||
// The "tag" argument specifies the tag name string for the content such as "P"
|
||||
// for a paragraph, "H1" for a top-level heading, and so forth. The "dict"
|
||||
// argument specifies an optional dictionary of properties for the content such
|
||||
// as the marked content identifier ("MCID") number.
|
||||
//
|
||||
// Calling this function sets the "Marked" key in the "MarkInfo" dictionary of
|
||||
// the document catalog. The caller is responsible for setting the
|
||||
// "StructTreeRoot" dictionary when creating marked content.
|
||||
//
|
||||
// @since PDFio 1.6@
|
||||
//
|
||||
|
||||
bool // O - `true` on success, `false` on failure
|
||||
pdfioContentBeginMarked(
|
||||
pdfio_stream_t *st, // I - Stream
|
||||
const char *name, // I - Name of marked content
|
||||
const char *tag, // I - Tag name of marked content
|
||||
pdfio_dict_t *dict) // I - Dictionary of parameters or `NULL` if none
|
||||
{
|
||||
if (!st || !name)
|
||||
if (!st || !tag)
|
||||
return (false);
|
||||
|
||||
// Send the BDC/BMC command...
|
||||
if (!pdfioStreamPrintf(st, "%N", name))
|
||||
if (!pdfioStreamPrintf(st, "%N", tag))
|
||||
return (false);
|
||||
|
||||
if (dict)
|
||||
|
||||
@@ -69,7 +69,7 @@ extern pdfio_array_t *pdfioArrayCreateColorFromPrimaries(pdfio_file_t *pdf, size
|
||||
extern pdfio_array_t *pdfioArrayCreateColorFromStandard(pdfio_file_t *pdf, size_t num_colors, pdfio_cs_t cs);
|
||||
|
||||
// PDF content drawing functions...
|
||||
extern bool pdfioContentBeginMarked(pdfio_stream_t *st, const char *name, pdfio_dict_t *dict) _PDFIO_PUBLIC;
|
||||
extern bool pdfioContentBeginMarked(pdfio_stream_t *st, const char *tag, pdfio_dict_t *dict) _PDFIO_PUBLIC;
|
||||
extern bool pdfioContentClip(pdfio_stream_t *st, bool even_odd) _PDFIO_PUBLIC;
|
||||
extern bool pdfioContentDrawImage(pdfio_stream_t *st, const char *name, double x, double y, double w, double h) _PDFIO_PUBLIC;
|
||||
extern bool pdfioContentEndMarked(pdfio_stream_t *st) _PDFIO_PUBLIC;
|
||||
|
||||
@@ -623,7 +623,7 @@ _pdfioStreamOpen(pdfio_obj_t *obj, // I - Object
|
||||
else
|
||||
{
|
||||
// Something else we don't support
|
||||
_pdfioFileError(st->pdf, "Unsupported stream filter '%N'.", filter);
|
||||
_pdfioFileError(st->pdf, "Unsupported stream filter '/%s'.", filter);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
20
pdfio1.def
20
pdfio1.def
@@ -1,6 +1,10 @@
|
||||
LIBRARY pdfio1
|
||||
VERSION 1.6
|
||||
EXPORTS
|
||||
_pdfio_strlcpy
|
||||
_pdfio_strtod
|
||||
_pdfio_utf16cpy
|
||||
_pdfio_vsnprintf
|
||||
_pdfioArrayDebug
|
||||
_pdfioArrayDecrypt
|
||||
_pdfioArrayDelete
|
||||
@@ -11,12 +15,12 @@ _pdfioCryptoAESDecrypt
|
||||
_pdfioCryptoAESEncrypt
|
||||
_pdfioCryptoAESInit
|
||||
_pdfioCryptoLock
|
||||
_pdfioCryptoMD5Append
|
||||
_pdfioCryptoMD5Finish
|
||||
_pdfioCryptoMD5Init
|
||||
_pdfioCryptoMakeRandom
|
||||
_pdfioCryptoMakeReader
|
||||
_pdfioCryptoMakeWriter
|
||||
_pdfioCryptoMD5Append
|
||||
_pdfioCryptoMD5Finish
|
||||
_pdfioCryptoMD5Init
|
||||
_pdfioCryptoRC4Crypt
|
||||
_pdfioCryptoRC4Init
|
||||
_pdfioCryptoSHA256Append
|
||||
@@ -69,10 +73,6 @@ _pdfioValueDecrypt
|
||||
_pdfioValueDelete
|
||||
_pdfioValueRead
|
||||
_pdfioValueWrite
|
||||
_pdfio_strlcpy
|
||||
_pdfio_strtod
|
||||
_pdfio_utf16cpy
|
||||
_pdfio_vsnprintf
|
||||
pdfioArrayAppendArray
|
||||
pdfioArrayAppendBinary
|
||||
pdfioArrayAppendBoolean
|
||||
@@ -101,8 +101,10 @@ pdfioArrayGetSize
|
||||
pdfioArrayGetString
|
||||
pdfioArrayGetType
|
||||
pdfioArrayRemove
|
||||
pdfioContentBeginMarked
|
||||
pdfioContentClip
|
||||
pdfioContentDrawImage
|
||||
pdfioContentEndMarked
|
||||
pdfioContentFill
|
||||
pdfioContentFillAndStroke
|
||||
pdfioContentMatrixConcat
|
||||
@@ -156,8 +158,8 @@ pdfioContentTextNewLineShow
|
||||
pdfioContentTextNewLineShowf
|
||||
pdfioContentTextNextLine
|
||||
pdfioContentTextShow
|
||||
pdfioContentTextShowJustified
|
||||
pdfioContentTextShowf
|
||||
pdfioContentTextShowJustified
|
||||
pdfioDictClear
|
||||
pdfioDictCopy
|
||||
pdfioDictCreate
|
||||
@@ -168,8 +170,8 @@ pdfioDictGetDate
|
||||
pdfioDictGetDict
|
||||
pdfioDictGetKey
|
||||
pdfioDictGetName
|
||||
pdfioDictGetNumPairs
|
||||
pdfioDictGetNumber
|
||||
pdfioDictGetNumPairs
|
||||
pdfioDictGetObj
|
||||
pdfioDictGetRect
|
||||
pdfioDictGetString
|
||||
|
||||
Reference in New Issue
Block a user