mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-25 12:58:21 +01:00
5160 lines
272 KiB
HTML
5160 lines
272 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en-US">
|
||
<head>
|
||
<title>PDFio Programming Manual v1.4.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-2024 by Michael R Sweet">
|
||
<meta name="version" content="1.4.0">
|
||
<style type="text/css"><!--
|
||
body {
|
||
background: white;
|
||
color: black;
|
||
font-family: sans-serif;
|
||
font-size: 12pt;
|
||
}
|
||
a {
|
||
color: black;
|
||
}
|
||
a:link, a:visited {
|
||
color: #00f;
|
||
}
|
||
a:link:hover, a:visited:hover, a:active {
|
||
color: #c0c;
|
||
}
|
||
body, p, h1, h2, h3, h4, h5, h6 {
|
||
font-family: sans-serif;
|
||
line-height: 1.4;
|
||
}
|
||
h1, h2, h3, h4, h5, h6 {
|
||
font-weight: bold;
|
||
page-break-inside: avoid;
|
||
}
|
||
h1 {
|
||
font-size: 250%;
|
||
margin: 0;
|
||
}
|
||
h2 {
|
||
font-size: 250%;
|
||
margin-top: 1.5em;
|
||
}
|
||
h3 {
|
||
font-size: 200%;
|
||
margin-bottom: 0.5em;
|
||
margin-top: 1.5em;
|
||
}
|
||
h4 {
|
||
font-size: 150%;
|
||
margin-bottom: 0.5em;
|
||
margin-top: 1.5em;
|
||
}
|
||
h5 {
|
||
font-size: 125%;
|
||
margin-bottom: 0.5em;
|
||
margin-top: 1.5em;
|
||
}
|
||
h6 {
|
||
font-size: 110%;
|
||
margin-bottom: 0.5em;
|
||
margin-top: 1.5em;
|
||
}
|
||
img.title {
|
||
width: 256px;
|
||
}
|
||
div.header h1, div.header p {
|
||
text-align: center;
|
||
}
|
||
div.contents, div.body, div.footer {
|
||
page-break-before: always;
|
||
}
|
||
.class, .enumeration, .function, .struct, .typedef, .union {
|
||
border-bottom: solid 2px gray;
|
||
}
|
||
.description {
|
||
margin-top: 0.5em;
|
||
}
|
||
.function {
|
||
margin-bottom: 0;
|
||
}
|
||
blockquote {
|
||
border: solid thin gray;
|
||
box-shadow: 3px 3px 5px rgba(127,127,127,0.25);
|
||
margin: 1em 0;
|
||
padding: 10px;
|
||
page-break-inside: avoid;
|
||
}
|
||
blockquote :first-child {
|
||
margin-top: 0;
|
||
}
|
||
blockquote :first-child {
|
||
margin-bottom: 0;
|
||
}
|
||
p code, li code, p.code, pre, ul.code li {
|
||
font-family: monospace;
|
||
hyphens: manual;
|
||
-webkit-hyphens: manual;
|
||
}
|
||
p.code, pre, ul.code li {
|
||
background: rgba(127,127,127,0.25);
|
||
border: thin dotted gray;
|
||
padding: 10px;
|
||
page-break-inside: avoid;
|
||
}
|
||
pre {
|
||
white-space: pre-wrap;
|
||
}
|
||
a:link, a:visited {
|
||
text-decoration: none;
|
||
}
|
||
span.info {
|
||
background: black;
|
||
border: solid thin black;
|
||
color: white;
|
||
font-size: 80%;
|
||
font-style: italic;
|
||
font-weight: bold;
|
||
white-space: nowrap;
|
||
}
|
||
h1 span.info, h2 span.info, h3 span.info, h4 span.info {
|
||
border-top-left-radius: 10px;
|
||
border-top-right-radius: 10px;
|
||
float: right;
|
||
padding: 3px 6px;
|
||
}
|
||
ul.code, ul.contents, ul.subcontents {
|
||
list-style-type: none;
|
||
margin: 0;
|
||
padding-left: 0;
|
||
}
|
||
ul.code li {
|
||
margin: 0;
|
||
}
|
||
ul.contents > li {
|
||
margin-top: 1em;
|
||
}
|
||
ul.contents li ul.code, ul.contents li ul.subcontents {
|
||
padding-left: 2em;
|
||
}
|
||
table {
|
||
border-collapse: collapse;
|
||
border-spacing: 0;
|
||
}
|
||
td {
|
||
border: solid 1px gray;
|
||
padding: 5px 10px;
|
||
vertical-align: top;
|
||
}
|
||
td.left {
|
||
text-align: left;
|
||
}
|
||
td.center {
|
||
text-align: center;
|
||
}
|
||
td.right {
|
||
text-align: right;
|
||
}
|
||
th {
|
||
border-bottom: solid 2px gray;
|
||
padding: 1px 5px;
|
||
text-align: center;
|
||
vertical-align: bottom;
|
||
}
|
||
tr:nth-child(even) {
|
||
background: rgba(127,127,127,0.25);
|
||
}
|
||
table.list {
|
||
border-collapse: collapse;
|
||
width: 100%;
|
||
}
|
||
table.list th {
|
||
border-bottom: none;
|
||
border-right: 2px solid gray;
|
||
font-family: monospace;
|
||
font-weight: normal;
|
||
padding: 5px 10px 5px 2px;
|
||
text-align: right;
|
||
vertical-align: top;
|
||
}
|
||
table.list td {
|
||
border: none;
|
||
padding: 5px 2px 5px 10px;
|
||
text-align: left;
|
||
vertical-align: top;
|
||
}
|
||
h2.title, h3.title {
|
||
border-bottom: solid 2px gray;
|
||
}
|
||
/* Syntax highlighting */
|
||
span.comment {
|
||
color: darkgreen;
|
||
}
|
||
span.directive {
|
||
color: red;
|
||
}
|
||
span.number {
|
||
color: brown;
|
||
}
|
||
span.reserved {
|
||
color: blue;
|
||
}
|
||
span.string {
|
||
color: magenta;
|
||
}
|
||
/* Dark mode overrides */
|
||
@media (prefers-color-scheme: dark) {
|
||
body {
|
||
background: black;
|
||
color: #ccc;
|
||
}
|
||
a {
|
||
color: #ccc;
|
||
}
|
||
a:link, a:visited {
|
||
color: #66f;
|
||
}
|
||
a:link:hover, a:visited:hover, a:active {
|
||
color: #f06;
|
||
}
|
||
}
|
||
/* Show contents on left side in web browser */
|
||
@media screen and (min-width: 800px) {
|
||
div.contents {
|
||
border-right: solid thin gray;
|
||
bottom: 0px;
|
||
box-shadow: 3px 3px 5px rgba(127,127,127,0.5);
|
||
font-size: 10pt;
|
||
left: 0px;
|
||
overflow: scroll;
|
||
padding: 1%;
|
||
position: fixed;
|
||
top: 0px;
|
||
width: 18%;
|
||
}
|
||
div.contents h2.title {
|
||
margin-top: 0px;
|
||
}
|
||
div.header, div.body, div.footer {
|
||
margin-left: 20%;
|
||
padding: 1% 2%;
|
||
}
|
||
}
|
||
/* Center title page content vertically */
|
||
@media print {
|
||
div.header {
|
||
padding-top: 33%;
|
||
}
|
||
}
|
||
--></style>
|
||
</head>
|
||
<body>
|
||
<div class="header">
|
||
<p><img class="title" src="pdfio-512.png"></p>
|
||
<h1 class="title">PDFio Programming Manual v1.4.0</h1>
|
||
<p>Michael R Sweet</p>
|
||
<p>Copyright © 2021-2024 by Michael R Sweet</p>
|
||
</div>
|
||
<div class="contents">
|
||
<h2 class="title">Contents</h2>
|
||
<ul class="contents">
|
||
<li><a href="#introduction">Introduction</a><ul class="subcontents">
|
||
<li><a href="#requirements">Requirements</a></li>
|
||
<li><a href="#installing-pdfio">Installing PDFio</a></li>
|
||
<li><a href="#visual-studio-project">Visual Studio Project</a></li>
|
||
<li><a href="#xcode-project">Xcode Project</a></li>
|
||
<li><a href="#detecting-pdfio">Detecting PDFio</a></li>
|
||
<li><a href="#header-files">Header Files</a></li>
|
||
<li><a href="#understanding-pdf-files">Understanding PDF Files</a></li>
|
||
</ul></li>
|
||
<li><a href="#api-overview">API Overview</a><ul class="subcontents">
|
||
<li><a href="#reading-pdf-files">Reading PDF Files</a></li>
|
||
<li><a href="#writing-pdf-files">Writing PDF Files</a></li>
|
||
<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>
|
||
</ul></li>
|
||
<li><a href="#examples">Examples</a><ul class="subcontents">
|
||
<li><a href="#read-pdf-metadata">Read PDF Metadata</a></li>
|
||
<li><a href="#extract-text-from-pdf-file">Extract Text from PDF File</a></li>
|
||
<li><a href="#create-a-pdf-file-with-text-and-an-image">Create a PDF File With Text and an Image</a></li>
|
||
<li><a href="#generate-a-code-128-barcode">Generate a Code 128 Barcode</a></li>
|
||
<li><a href="#convert-markdown-to-pdf">Convert Markdown to PDF</a></li>
|
||
</ul></li>
|
||
<li><a href="#FUNCTIONS">Functions</a><ul class="subcontents">
|
||
<li><a href="#pdfioArrayAppendArray">pdfioArrayAppendArray</a></li>
|
||
<li><a href="#pdfioArrayAppendBinary">pdfioArrayAppendBinary</a></li>
|
||
<li><a href="#pdfioArrayAppendBoolean">pdfioArrayAppendBoolean</a></li>
|
||
<li><a href="#pdfioArrayAppendDate">pdfioArrayAppendDate</a></li>
|
||
<li><a href="#pdfioArrayAppendDict">pdfioArrayAppendDict</a></li>
|
||
<li><a href="#pdfioArrayAppendName">pdfioArrayAppendName</a></li>
|
||
<li><a href="#pdfioArrayAppendNumber">pdfioArrayAppendNumber</a></li>
|
||
<li><a href="#pdfioArrayAppendObj">pdfioArrayAppendObj</a></li>
|
||
<li><a href="#pdfioArrayAppendString">pdfioArrayAppendString</a></li>
|
||
<li><a href="#pdfioArrayCopy">pdfioArrayCopy</a></li>
|
||
<li><a href="#pdfioArrayCreate">pdfioArrayCreate</a></li>
|
||
<li><a href="#pdfioArrayCreateColorFromICCObj">pdfioArrayCreateColorFromICCObj</a></li>
|
||
<li><a href="#pdfioArrayCreateColorFromMatrix">pdfioArrayCreateColorFromMatrix</a></li>
|
||
<li><a href="#pdfioArrayCreateColorFromPalette">pdfioArrayCreateColorFromPalette</a></li>
|
||
<li><a href="#pdfioArrayCreateColorFromPrimaries">pdfioArrayCreateColorFromPrimaries</a></li>
|
||
<li><a href="#pdfioArrayCreateColorFromStandard">pdfioArrayCreateColorFromStandard</a></li>
|
||
<li><a href="#pdfioArrayGetArray">pdfioArrayGetArray</a></li>
|
||
<li><a href="#pdfioArrayGetBinary">pdfioArrayGetBinary</a></li>
|
||
<li><a href="#pdfioArrayGetBoolean">pdfioArrayGetBoolean</a></li>
|
||
<li><a href="#pdfioArrayGetDate">pdfioArrayGetDate</a></li>
|
||
<li><a href="#pdfioArrayGetDict">pdfioArrayGetDict</a></li>
|
||
<li><a href="#pdfioArrayGetName">pdfioArrayGetName</a></li>
|
||
<li><a href="#pdfioArrayGetNumber">pdfioArrayGetNumber</a></li>
|
||
<li><a href="#pdfioArrayGetObj">pdfioArrayGetObj</a></li>
|
||
<li><a href="#pdfioArrayGetSize">pdfioArrayGetSize</a></li>
|
||
<li><a href="#pdfioArrayGetString">pdfioArrayGetString</a></li>
|
||
<li><a href="#pdfioArrayGetType">pdfioArrayGetType</a></li>
|
||
<li><a href="#pdfioArrayRemove">pdfioArrayRemove</a></li>
|
||
<li><a href="#pdfioContentClip">pdfioContentClip</a></li>
|
||
<li><a href="#pdfioContentDrawImage">pdfioContentDrawImage</a></li>
|
||
<li><a href="#pdfioContentFill">pdfioContentFill</a></li>
|
||
<li><a href="#pdfioContentFillAndStroke">pdfioContentFillAndStroke</a></li>
|
||
<li><a href="#pdfioContentMatrixConcat">pdfioContentMatrixConcat</a></li>
|
||
<li><a href="#pdfioContentMatrixRotate">pdfioContentMatrixRotate</a></li>
|
||
<li><a href="#pdfioContentMatrixScale">pdfioContentMatrixScale</a></li>
|
||
<li><a href="#pdfioContentMatrixTranslate">pdfioContentMatrixTranslate</a></li>
|
||
<li><a href="#pdfioContentPathClose">pdfioContentPathClose</a></li>
|
||
<li><a href="#pdfioContentPathCurve">pdfioContentPathCurve</a></li>
|
||
<li><a href="#pdfioContentPathCurve13">pdfioContentPathCurve13</a></li>
|
||
<li><a href="#pdfioContentPathCurve23">pdfioContentPathCurve23</a></li>
|
||
<li><a href="#pdfioContentPathEnd">pdfioContentPathEnd</a></li>
|
||
<li><a href="#pdfioContentPathLineTo">pdfioContentPathLineTo</a></li>
|
||
<li><a href="#pdfioContentPathMoveTo">pdfioContentPathMoveTo</a></li>
|
||
<li><a href="#pdfioContentPathRect">pdfioContentPathRect</a></li>
|
||
<li><a href="#pdfioContentRestore">pdfioContentRestore</a></li>
|
||
<li><a href="#pdfioContentSave">pdfioContentSave</a></li>
|
||
<li><a href="#pdfioContentSetDashPattern">pdfioContentSetDashPattern</a></li>
|
||
<li><a href="#pdfioContentSetFillColorDeviceCMYK">pdfioContentSetFillColorDeviceCMYK</a></li>
|
||
<li><a href="#pdfioContentSetFillColorDeviceGray">pdfioContentSetFillColorDeviceGray</a></li>
|
||
<li><a href="#pdfioContentSetFillColorDeviceRGB">pdfioContentSetFillColorDeviceRGB</a></li>
|
||
<li><a href="#pdfioContentSetFillColorGray">pdfioContentSetFillColorGray</a></li>
|
||
<li><a href="#pdfioContentSetFillColorRGB">pdfioContentSetFillColorRGB</a></li>
|
||
<li><a href="#pdfioContentSetFillColorSpace">pdfioContentSetFillColorSpace</a></li>
|
||
<li><a href="#pdfioContentSetFlatness">pdfioContentSetFlatness</a></li>
|
||
<li><a href="#pdfioContentSetLineCap">pdfioContentSetLineCap</a></li>
|
||
<li><a href="#pdfioContentSetLineJoin">pdfioContentSetLineJoin</a></li>
|
||
<li><a href="#pdfioContentSetLineWidth">pdfioContentSetLineWidth</a></li>
|
||
<li><a href="#pdfioContentSetMiterLimit">pdfioContentSetMiterLimit</a></li>
|
||
<li><a href="#pdfioContentSetStrokeColorDeviceCMYK">pdfioContentSetStrokeColorDeviceCMYK</a></li>
|
||
<li><a href="#pdfioContentSetStrokeColorDeviceGray">pdfioContentSetStrokeColorDeviceGray</a></li>
|
||
<li><a href="#pdfioContentSetStrokeColorDeviceRGB">pdfioContentSetStrokeColorDeviceRGB</a></li>
|
||
<li><a href="#pdfioContentSetStrokeColorGray">pdfioContentSetStrokeColorGray</a></li>
|
||
<li><a href="#pdfioContentSetStrokeColorRGB">pdfioContentSetStrokeColorRGB</a></li>
|
||
<li><a href="#pdfioContentSetStrokeColorSpace">pdfioContentSetStrokeColorSpace</a></li>
|
||
<li><a href="#pdfioContentSetTextCharacterSpacing">pdfioContentSetTextCharacterSpacing</a></li>
|
||
<li><a href="#pdfioContentSetTextFont">pdfioContentSetTextFont</a></li>
|
||
<li><a href="#pdfioContentSetTextLeading">pdfioContentSetTextLeading</a></li>
|
||
<li><a href="#pdfioContentSetTextMatrix">pdfioContentSetTextMatrix</a></li>
|
||
<li><a href="#pdfioContentSetTextRenderingMode">pdfioContentSetTextRenderingMode</a></li>
|
||
<li><a href="#pdfioContentSetTextRise">pdfioContentSetTextRise</a></li>
|
||
<li><a href="#pdfioContentSetTextWordSpacing">pdfioContentSetTextWordSpacing</a></li>
|
||
<li><a href="#pdfioContentSetTextXScaling">pdfioContentSetTextXScaling</a></li>
|
||
<li><a href="#pdfioContentStroke">pdfioContentStroke</a></li>
|
||
<li><a href="#pdfioContentTextBegin">pdfioContentTextBegin</a></li>
|
||
<li><a href="#pdfioContentTextEnd">pdfioContentTextEnd</a></li>
|
||
<li><a href="#pdfioContentTextMeasure">pdfioContentTextMeasure</a></li>
|
||
<li><a href="#pdfioContentTextMoveLine">pdfioContentTextMoveLine</a></li>
|
||
<li><a href="#pdfioContentTextMoveTo">pdfioContentTextMoveTo</a></li>
|
||
<li><a href="#pdfioContentTextNewLine">pdfioContentTextNewLine</a></li>
|
||
<li><a href="#pdfioContentTextNewLineShow">pdfioContentTextNewLineShow</a></li>
|
||
<li><a href="#pdfioContentTextNewLineShowf">pdfioContentTextNewLineShowf</a></li>
|
||
<li><a href="#pdfioContentTextShow">pdfioContentTextShow</a></li>
|
||
<li><a href="#pdfioContentTextShowJustified">pdfioContentTextShowJustified</a></li>
|
||
<li><a href="#pdfioContentTextShowf">pdfioContentTextShowf</a></li>
|
||
<li><a href="#pdfioDictClear">pdfioDictClear</a></li>
|
||
<li><a href="#pdfioDictCopy">pdfioDictCopy</a></li>
|
||
<li><a href="#pdfioDictCreate">pdfioDictCreate</a></li>
|
||
<li><a href="#pdfioDictGetArray">pdfioDictGetArray</a></li>
|
||
<li><a href="#pdfioDictGetBinary">pdfioDictGetBinary</a></li>
|
||
<li><a href="#pdfioDictGetBoolean">pdfioDictGetBoolean</a></li>
|
||
<li><a href="#pdfioDictGetDate">pdfioDictGetDate</a></li>
|
||
<li><a href="#pdfioDictGetDict">pdfioDictGetDict</a></li>
|
||
<li><a href="#pdfioDictGetKey">pdfioDictGetKey</a></li>
|
||
<li><a href="#pdfioDictGetName">pdfioDictGetName</a></li>
|
||
<li><a href="#pdfioDictGetNumPairs">pdfioDictGetNumPairs</a></li>
|
||
<li><a href="#pdfioDictGetNumber">pdfioDictGetNumber</a></li>
|
||
<li><a href="#pdfioDictGetObj">pdfioDictGetObj</a></li>
|
||
<li><a href="#pdfioDictGetRect">pdfioDictGetRect</a></li>
|
||
<li><a href="#pdfioDictGetString">pdfioDictGetString</a></li>
|
||
<li><a href="#pdfioDictGetType">pdfioDictGetType</a></li>
|
||
<li><a href="#pdfioDictIterateKeys">pdfioDictIterateKeys</a></li>
|
||
<li><a href="#pdfioDictSetArray">pdfioDictSetArray</a></li>
|
||
<li><a href="#pdfioDictSetBinary">pdfioDictSetBinary</a></li>
|
||
<li><a href="#pdfioDictSetBoolean">pdfioDictSetBoolean</a></li>
|
||
<li><a href="#pdfioDictSetDate">pdfioDictSetDate</a></li>
|
||
<li><a href="#pdfioDictSetDict">pdfioDictSetDict</a></li>
|
||
<li><a href="#pdfioDictSetName">pdfioDictSetName</a></li>
|
||
<li><a href="#pdfioDictSetNull">pdfioDictSetNull</a></li>
|
||
<li><a href="#pdfioDictSetNumber">pdfioDictSetNumber</a></li>
|
||
<li><a href="#pdfioDictSetObj">pdfioDictSetObj</a></li>
|
||
<li><a href="#pdfioDictSetRect">pdfioDictSetRect</a></li>
|
||
<li><a href="#pdfioDictSetString">pdfioDictSetString</a></li>
|
||
<li><a href="#pdfioDictSetStringf">pdfioDictSetStringf</a></li>
|
||
<li><a href="#pdfioFileClose">pdfioFileClose</a></li>
|
||
<li><a href="#pdfioFileCreate">pdfioFileCreate</a></li>
|
||
<li><a href="#pdfioFileCreateArrayObj">pdfioFileCreateArrayObj</a></li>
|
||
<li><a href="#pdfioFileCreateFontObjFromBase">pdfioFileCreateFontObjFromBase</a></li>
|
||
<li><a href="#pdfioFileCreateFontObjFromFile">pdfioFileCreateFontObjFromFile</a></li>
|
||
<li><a href="#pdfioFileCreateICCObjFromFile">pdfioFileCreateICCObjFromFile</a></li>
|
||
<li><a href="#pdfioFileCreateImageObjFromData">pdfioFileCreateImageObjFromData</a></li>
|
||
<li><a href="#pdfioFileCreateImageObjFromFile">pdfioFileCreateImageObjFromFile</a></li>
|
||
<li><a href="#pdfioFileCreateNameObj">pdfioFileCreateNameObj</a></li>
|
||
<li><a href="#pdfioFileCreateNumberObj">pdfioFileCreateNumberObj</a></li>
|
||
<li><a href="#pdfioFileCreateObj">pdfioFileCreateObj</a></li>
|
||
<li><a href="#pdfioFileCreateOutput">pdfioFileCreateOutput</a></li>
|
||
<li><a href="#pdfioFileCreatePage">pdfioFileCreatePage</a></li>
|
||
<li><a href="#pdfioFileCreateStringObj">pdfioFileCreateStringObj</a></li>
|
||
<li><a href="#pdfioFileCreateTemporary">pdfioFileCreateTemporary</a></li>
|
||
<li><a href="#pdfioFileFindObj">pdfioFileFindObj</a></li>
|
||
<li><a href="#pdfioFileGetAuthor">pdfioFileGetAuthor</a></li>
|
||
<li><a href="#pdfioFileGetCatalog">pdfioFileGetCatalog</a></li>
|
||
<li><a href="#pdfioFileGetCreationDate">pdfioFileGetCreationDate</a></li>
|
||
<li><a href="#pdfioFileGetCreator">pdfioFileGetCreator</a></li>
|
||
<li><a href="#pdfioFileGetID">pdfioFileGetID</a></li>
|
||
<li><a href="#pdfioFileGetKeywords">pdfioFileGetKeywords</a></li>
|
||
<li><a href="#pdfioFileGetName">pdfioFileGetName</a></li>
|
||
<li><a href="#pdfioFileGetNumObjs">pdfioFileGetNumObjs</a></li>
|
||
<li><a href="#pdfioFileGetNumPages">pdfioFileGetNumPages</a></li>
|
||
<li><a href="#pdfioFileGetObj">pdfioFileGetObj</a></li>
|
||
<li><a href="#pdfioFileGetPage">pdfioFileGetPage</a></li>
|
||
<li><a href="#pdfioFileGetPermissions">pdfioFileGetPermissions</a></li>
|
||
<li><a href="#pdfioFileGetProducer">pdfioFileGetProducer</a></li>
|
||
<li><a href="#pdfioFileGetSubject">pdfioFileGetSubject</a></li>
|
||
<li><a href="#pdfioFileGetTitle">pdfioFileGetTitle</a></li>
|
||
<li><a href="#pdfioFileGetVersion">pdfioFileGetVersion</a></li>
|
||
<li><a href="#pdfioFileOpen">pdfioFileOpen</a></li>
|
||
<li><a href="#pdfioFileSetAuthor">pdfioFileSetAuthor</a></li>
|
||
<li><a href="#pdfioFileSetCreationDate">pdfioFileSetCreationDate</a></li>
|
||
<li><a href="#pdfioFileSetCreator">pdfioFileSetCreator</a></li>
|
||
<li><a href="#pdfioFileSetKeywords">pdfioFileSetKeywords</a></li>
|
||
<li><a href="#pdfioFileSetPermissions">pdfioFileSetPermissions</a></li>
|
||
<li><a href="#pdfioFileSetSubject">pdfioFileSetSubject</a></li>
|
||
<li><a href="#pdfioFileSetTitle">pdfioFileSetTitle</a></li>
|
||
<li><a href="#pdfioImageGetBytesPerLine">pdfioImageGetBytesPerLine</a></li>
|
||
<li><a href="#pdfioImageGetHeight">pdfioImageGetHeight</a></li>
|
||
<li><a href="#pdfioImageGetWidth">pdfioImageGetWidth</a></li>
|
||
<li><a href="#pdfioObjClose">pdfioObjClose</a></li>
|
||
<li><a href="#pdfioObjCopy">pdfioObjCopy</a></li>
|
||
<li><a href="#pdfioObjCreateStream">pdfioObjCreateStream</a></li>
|
||
<li><a href="#pdfioObjGetArray">pdfioObjGetArray</a></li>
|
||
<li><a href="#pdfioObjGetDict">pdfioObjGetDict</a></li>
|
||
<li><a href="#pdfioObjGetGeneration">pdfioObjGetGeneration</a></li>
|
||
<li><a href="#pdfioObjGetLength">pdfioObjGetLength</a></li>
|
||
<li><a href="#pdfioObjGetName">pdfioObjGetName</a></li>
|
||
<li><a href="#pdfioObjGetNumber">pdfioObjGetNumber</a></li>
|
||
<li><a href="#pdfioObjGetSubtype">pdfioObjGetSubtype</a></li>
|
||
<li><a href="#pdfioObjGetType">pdfioObjGetType</a></li>
|
||
<li><a href="#pdfioObjOpenStream">pdfioObjOpenStream</a></li>
|
||
<li><a href="#pdfioPageCopy">pdfioPageCopy</a></li>
|
||
<li><a href="#pdfioPageDictAddColorSpace">pdfioPageDictAddColorSpace</a></li>
|
||
<li><a href="#pdfioPageDictAddFont">pdfioPageDictAddFont</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="#pdfioStreamConsume">pdfioStreamConsume</a></li>
|
||
<li><a href="#pdfioStreamGetToken">pdfioStreamGetToken</a></li>
|
||
<li><a href="#pdfioStreamPeek">pdfioStreamPeek</a></li>
|
||
<li><a href="#pdfioStreamPrintf">pdfioStreamPrintf</a></li>
|
||
<li><a href="#pdfioStreamPutChar">pdfioStreamPutChar</a></li>
|
||
<li><a href="#pdfioStreamPuts">pdfioStreamPuts</a></li>
|
||
<li><a href="#pdfioStreamRead">pdfioStreamRead</a></li>
|
||
<li><a href="#pdfioStreamWrite">pdfioStreamWrite</a></li>
|
||
<li><a href="#pdfioStringCreate">pdfioStringCreate</a></li>
|
||
<li><a href="#pdfioStringCreatef">pdfioStringCreatef</a></li>
|
||
</ul></li>
|
||
<li><a href="#TYPES">Data Types</a><ul class="subcontents">
|
||
<li><a href="#pdfio_array_t">pdfio_array_t</a></li>
|
||
<li><a href="#pdfio_cs_t">pdfio_cs_t</a></li>
|
||
<li><a href="#pdfio_dict_cb_t">pdfio_dict_cb_t</a></li>
|
||
<li><a href="#pdfio_dict_t">pdfio_dict_t</a></li>
|
||
<li><a href="#pdfio_encryption_t">pdfio_encryption_t</a></li>
|
||
<li><a href="#pdfio_error_cb_t">pdfio_error_cb_t</a></li>
|
||
<li><a href="#pdfio_file_t">pdfio_file_t</a></li>
|
||
<li><a href="#pdfio_filter_t">pdfio_filter_t</a></li>
|
||
<li><a href="#pdfio_linecap_t">pdfio_linecap_t</a></li>
|
||
<li><a href="#pdfio_linejoin_t">pdfio_linejoin_t</a></li>
|
||
<li><a href="#pdfio_matrix_t[3][2]">pdfio_matrix_t[3][2]</a></li>
|
||
<li><a href="#pdfio_obj_t">pdfio_obj_t</a></li>
|
||
<li><a href="#pdfio_output_cb_t">pdfio_output_cb_t</a></li>
|
||
<li><a href="#pdfio_password_cb_t">pdfio_password_cb_t</a></li>
|
||
<li><a href="#pdfio_permission_t">pdfio_permission_t</a></li>
|
||
<li><a href="#pdfio_rect_t">pdfio_rect_t</a></li>
|
||
<li><a href="#pdfio_stream_t">pdfio_stream_t</a></li>
|
||
<li><a href="#pdfio_textrendering_t">pdfio_textrendering_t</a></li>
|
||
<li><a href="#pdfio_valtype_t">pdfio_valtype_t</a></li>
|
||
</ul></li>
|
||
<li><a href="#STRUCTURES">Structures</a><ul class="subcontents">
|
||
<li><a href="#pdfio_rect_s">pdfio_rect_s</a></li>
|
||
</ul></li>
|
||
<li><a href="#ENUMERATIONS">Enumerations</a><ul class="subcontents">
|
||
<li><a href="#pdfio_cs_e">pdfio_cs_e</a></li>
|
||
<li><a href="#pdfio_encryption_e">pdfio_encryption_e</a></li>
|
||
<li><a href="#pdfio_filter_e">pdfio_filter_e</a></li>
|
||
<li><a href="#pdfio_linecap_e">pdfio_linecap_e</a></li>
|
||
<li><a href="#pdfio_linejoin_e">pdfio_linejoin_e</a></li>
|
||
<li><a href="#pdfio_permission_e">pdfio_permission_e</a></li>
|
||
<li><a href="#pdfio_textrendering_e">pdfio_textrendering_e</a></li>
|
||
<li><a href="#pdfio_valtype_e">pdfio_valtype_e</a></li>
|
||
</ul></li>
|
||
</ul>
|
||
</div>
|
||
<div class="body">
|
||
<h2 class="title" id="introduction">Introduction</h2>
|
||
<p>PDFio is a simple C library for reading and writing PDF files. The primary goals of PDFio are:</p>
|
||
<ul>
|
||
<li><p>Read and write any version of PDF file</p>
|
||
</li>
|
||
<li><p>Provide access to pages, objects, and streams within a PDF file</p>
|
||
</li>
|
||
<li><p>Support reading and writing of encrypted PDF files</p>
|
||
</li>
|
||
<li><p>Extract or embed useful metadata (author, creator, page information, etc.)</p>
|
||
</li>
|
||
<li><p>"Filter" PDF files, for example to extract a range of pages or to embed fonts that are missing from a PDF</p>
|
||
</li>
|
||
<li><p>Provide access to objects used for each page</p>
|
||
</li>
|
||
</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 Copyright © 2021-2024 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.</p>
|
||
<h3 class="title" id="requirements">Requirements</h3>
|
||
<p>PDFio requires the following to build the software:</p>
|
||
<ul>
|
||
<li><p>A C99 compiler such as Clang, GCC, or MS Visual C</p>
|
||
</li>
|
||
<li><p>A POSIX-compliant <code>make</code> program</p>
|
||
</li>
|
||
<li><p>A POSIX-compliant <code>sh</code> program</p>
|
||
</li>
|
||
<li><p>ZLIB (<a href="https://www.zlib.net">https://www.zlib.net</a>) 1.0 or higher</p>
|
||
</li>
|
||
</ul>
|
||
<p>IDE files for Xcode (macOS/iOS) and Visual Studio (Windows) are also provided.</p>
|
||
<h3 class="title" id="installing-pdfio">Installing PDFio</h3>
|
||
<p>PDFio comes with a configure script that creates a portable makefile that will work on any POSIX-compliant system with ZLIB installed. To make it, run:</p>
|
||
<pre><code>./configure
|
||
make
|
||
</code></pre>
|
||
<p>To test it, run:</p>
|
||
<pre><code>make test
|
||
</code></pre>
|
||
<p>To install it, run:</p>
|
||
<pre><code>sudo make install
|
||
</code></pre>
|
||
<p>If you want a shared library, run:</p>
|
||
<pre><code>./configure --enable-shared
|
||
make
|
||
sudo make install
|
||
</code></pre>
|
||
<p>The default installation location is "/usr/local". Pass the <code>--prefix</code> option to make to install it to another location:</p>
|
||
<pre><code>./configure --prefix=/some/other/directory
|
||
</code></pre>
|
||
<p>Other configure options can be found using the <code>--help</code> option:</p>
|
||
<pre><code>./configure --help
|
||
</code></pre>
|
||
<h3 class="title" id="visual-studio-project">Visual Studio Project</h3>
|
||
<p>The Visual Studio solution ("pdfio.sln") is provided for Windows developers and generates both a static library and DLL.</p>
|
||
<h3 class="title" id="xcode-project">Xcode Project</h3>
|
||
<p>There is also an Xcode project ("pdfio.xcodeproj") you can use on macOS which generates a static library that will be installed under "/usr/local" with:</p>
|
||
<pre><code>sudo xcodebuild install
|
||
</code></pre>
|
||
<h3 class="title" id="detecting-pdfio">Detecting PDFio</h3>
|
||
<p>PDFio can be detected using the <code>pkg-config</code> command, for example:</p>
|
||
<pre><code>if pkg-config --exists pdfio; then
|
||
...
|
||
fi
|
||
</code></pre>
|
||
<p>In a makefile you can add the necessary compiler and linker options with:</p>
|
||
<pre><code class="language-make">CFLAGS += `pkg-config --cflags pdfio`
|
||
LIBS += `pkg-config --libs pdfio`
|
||
</code></pre>
|
||
<p>On Windows, you need to link to the <code>PDFIO1.LIB</code> (DLL) library and include the <code>zlib_native</code> NuGet package dependency. You can also use the published <code>pdfio_native</code> NuGet package.</p>
|
||
<h3 class="title" id="header-files">Header Files</h3>
|
||
<p>PDFio provides a primary header file that is always used:</p>
|
||
<pre><code class="language-c"><span class="directive">#include <pdfio.h></span>
|
||
</code></pre>
|
||
<p>PDFio also provides <a href="#pdf-content-helper-functions">PDF content helper functions</a> for producing PDF content that are defined in a separate header file:</p>
|
||
<pre><code class="language-c"><span class="directive">#include <pdfio-content.h></span>
|
||
</code></pre>
|
||
<h3 class="title" id="understanding-pdf-files">Understanding PDF Files</h3>
|
||
<p>A PDF file provides data and commands for displaying pages of graphics and text, and is structured in a way that allows it to be displayed in the same way across multiple devices and platforms. The following is a PDF which shows "Hello, World!" on one page:</p>
|
||
<pre><code>%PDF-1.0 % Header starts here
|
||
%âãÏÓ
|
||
1 0 obj % Body starts here
|
||
<<
|
||
/Kids [2 0 R]
|
||
/Count 1
|
||
/Type /Pages
|
||
>>
|
||
endobj
|
||
2 0 obj
|
||
<<
|
||
/Rotate 0
|
||
/Parent 1 0 R
|
||
/Resources 3 0 R
|
||
/MediaBox [0 0 612 792]
|
||
/Contents [4 0 R]/Type /Page
|
||
>>
|
||
endobj
|
||
3 0 obj
|
||
<<
|
||
/Font
|
||
<<
|
||
/F0
|
||
<<
|
||
/BaseFont /Times-Italic
|
||
/Subtype /Type1
|
||
/Type /Font
|
||
>>
|
||
>>
|
||
>>
|
||
endobj
|
||
4 0 obj
|
||
<<
|
||
/Length 65
|
||
>>
|
||
stream
|
||
1. 0. 0. 1. 50. 700. cm
|
||
BT
|
||
/F0 36. Tf
|
||
(Hello, World!) Tj
|
||
ET
|
||
endstream
|
||
endobj
|
||
5 0 obj
|
||
<<
|
||
/Pages 1 0 R
|
||
/Type /Catalog
|
||
>>
|
||
endobj
|
||
xref % Cross-reference table starts here
|
||
0 6
|
||
0000000000 65535 f
|
||
0000000015 00000 n
|
||
0000000074 00000 n
|
||
0000000192 00000 n
|
||
0000000291 00000 n
|
||
0000000409 00000 n
|
||
trailer % Trailer starts here
|
||
<<
|
||
/Root 5 0 R
|
||
/Size 6
|
||
>>
|
||
startxref
|
||
459
|
||
%%EOF
|
||
</code></pre>
|
||
<h4 id="header">Header</h4>
|
||
<p>The header is the first line of a PDF file that specifies the version of the PDF format that has been used, for example <code>%PDF-1.0</code>.</p>
|
||
<p>Since PDF files almost always contain binary data, they can become corrupted if line endings are changed. For example, if the file is transferred using FTP in text mode or is edited in Notepad on Windows. To allow legacy file transfer programs to determine that the file is binary, the PDF standard recommends including some bytes with character codes higher than 127 in the header, for example:</p>
|
||
<pre><code>%âãÏÓ
|
||
</code></pre>
|
||
<p>The percent sign indicates a comment line while the other few bytes are arbitrary character codes in excess of 127. So, the whole header in our example is:</p>
|
||
<pre><code>%PDF-1.0
|
||
%âãÏÓ
|
||
</code></pre>
|
||
<h4 id="body">Body</h4>
|
||
<p>The file body consists of a sequence of objects, each preceded by an object number, generation number, and the obj keyword on one line, and followed by the endobj keyword on another. For example:</p>
|
||
<pre><code>1 0 obj
|
||
<<
|
||
/Kids [2 0 R]
|
||
/Count 1
|
||
/Type /Pages
|
||
>>
|
||
endobj
|
||
</code></pre>
|
||
<p>In this example, the object number is 1 and the generation number is 0, meaning it is the first version of the object. The content for object 1 is between the initial <code>1 0 obj</code> and trailing <code>endobj</code> lines. In this case, the content is the dictionary <code><</Kids [2 0 R] /Count 1 /Type /Pages>></code>.</p>
|
||
<h4 id="cross-reference-table">Cross-Reference Table</h4>
|
||
<p>The cross-reference table lists the byte offset of each object in the file body. This allows random access to objects, meaning they don't have to be read in order. Objects that are not used are never read, making the process efficient. Operations like counting the number of pages in a PDF document are fast, even in large files.</p>
|
||
<p>Each object has an object number and a generation number. Generation numbers are used when a cross-reference table entry is reused. For simplicity, we will assume generation numbers to be always zero and ignore them. The cross-reference table consists of a header line that indicates the number of entries, a free entry line for object 0, and a line for each of the objects in the file body. For example:</p>
|
||
<pre><code>0 6 % Six entries in table, starting at 0
|
||
0000000000 65535 f % Free entry for object 0
|
||
0000000015 00000 n % Object 1 is at byte offset 15
|
||
0000000074 00000 n % Object 2 is at byte offset 74
|
||
0000000192 00000 n % etc...
|
||
0000000291 00000 n
|
||
0000000409 00000 n % Object 5 is at byte offset 409
|
||
</code></pre>
|
||
<h4 id="trailer">Trailer</h4>
|
||
<p>The first line of the trailer is just the <code>trailer</code> keyword. This is followed by the trailer dictionary which contains at least the <code>/Size</code> entry specifying the number of entries in the cross-reference table and the <code>/Root</code> entry which references the object for the document catalog which is the root element of the graph of objects in the body.</p>
|
||
<p>There follows a line with just the <code>startxref</code> keyword, a line with a single number specifying the byte offset of the start of the cross-reference table within the file, and then the line <code>%%EOF</code> which signals the end of the PDF file.</p>
|
||
<pre><code>trailer % Trailer keyword
|
||
<< % The trailer dictinonary
|
||
/Root 5 0 R
|
||
/Size 6
|
||
>>
|
||
startxref % startxref keyword
|
||
459 % Byte offset of cross-reference table
|
||
%%EOF % End-of-file marker
|
||
</code></pre>
|
||
<h2 class="title" id="api-overview">API Overview</h2>
|
||
<p>PDFio exposes several types:</p>
|
||
<ul>
|
||
<li><p><code>pdfio_file_t</code>: A PDF file (for reading or writing)</p>
|
||
</li>
|
||
<li><p><code>pdfio_array_t</code>: An array of values</p>
|
||
</li>
|
||
<li><p><code>pdfio_dict_t</code>: A dictionary of key/value pairs in a PDF file, object, etc.</p>
|
||
</li>
|
||
<li><p><code>pdfio_obj_t</code>: An object in a PDF file</p>
|
||
</li>
|
||
<li><p><code>pdfio_stream_t</code>: An object stream</p>
|
||
</li>
|
||
</ul>
|
||
<h3 class="title" id="reading-pdf-files">Reading PDF Files</h3>
|
||
<p>You open an existing PDF file using the <a href="#pdfioFileOpen"><code>pdfioFileOpen</code></a> function:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf =
|
||
pdfioFileOpen(<span class="string">"myinputfile.pdf"</span>, password_cb, password_data, error_cb,
|
||
error_data);
|
||
</code></pre>
|
||
<p>where the five arguments to the function are the filename ("myinputfile.pdf"), an optional password callback function (<code>password_cb</code>) and data pointer value (<code>password_data</code>), and an optional error callback function (<code>error_cb</code>) and data pointer value (<code>error_data</code>). The password callback is called for encrypted PDF files that are not using the default password, for example:</p>
|
||
<pre><code class="language-c"><span class="reserved">const</span> <span class="reserved">char</span> *
|
||
password_cb(<span class="reserved">void</span> *data, <span class="reserved">const</span> <span class="reserved">char</span> *filename)
|
||
{
|
||
(<span class="reserved">void</span>)data; <span class="comment">// This callback doesn't use the data pointer</span>
|
||
(<span class="reserved">void</span>)filename; <span class="comment">// This callback doesn't use the filename</span>
|
||
|
||
<span class="comment">// Return a password string for the file...</span>
|
||
<span class="reserved">return</span> (<span class="string">"Password42"</span>);
|
||
}
|
||
</code></pre>
|
||
<p>The error callback is called for both errors and warnings and accepts the <code>pdfio_file_t</code> pointer, a message string, and the callback pointer value, for example:</p>
|
||
<pre><code class="language-c"><span class="reserved">bool</span>
|
||
error_cb(pdfio_file_t *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *message, <span class="reserved">void</span> *data)
|
||
{
|
||
(<span class="reserved">void</span>)data; <span class="comment">// This callback does not use the data pointer</span>
|
||
|
||
fprintf(stderr, <span class="string">"%s: %s\n"</span>, pdfioFileGetName(pdf), message);
|
||
|
||
<span class="comment">// Return false to treat warnings as errors</span>
|
||
<span class="reserved">return</span> (<span class="reserved">false</span>);
|
||
}
|
||
</code></pre>
|
||
<p>The default error callback (<code>NULL</code>) does the equivalent of the above.</p>
|
||
<p>Each PDF file contains one or more pages. The <a href="#pdfioFileGetNumPages"><code>pdfioFileGetNumPages</code></a> function returns the number of pages in the file while the <a href="#pdfioFileGetPage"><code>pdfioFileGetPage</code></a> function gets the specified page in the PDF file:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf; <span class="comment">// PDF file</span>
|
||
size_t i; <span class="comment">// Looping var</span>
|
||
size_t count; <span class="comment">// Number of pages</span>
|
||
pdfio_obj_t *page; <span class="comment">// Current page</span>
|
||
|
||
<span class="comment">// Iterate the pages in the PDF file</span>
|
||
<span class="reserved">for</span> (i = <span class="number">0</span>, count = pdfioFileGetNumPages(pdf); i < count; i ++)
|
||
{
|
||
page = pdfioFileGetPage(pdf, i);
|
||
<span class="comment">// do something with page</span>
|
||
}
|
||
</code></pre>
|
||
<p>Each page is represented by a "page tree" object (what <a href="#pdfioFileGetPage"><code>pdfioFileGetPage</code></a> 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 <a href="#pdfioPageGetNumStreams"><code>pdfioPageGetNumStreams</code></a> and <a href="#pdfioPageOpenStream"><code>pdfioPageOpenStream</code></a> functions to access the content streams for each page, and <a href="#pdfioObjGetDict"><code>pdfioObjGetDict</code></a> to get the associated page object dictionary. For example, if you want to display the media and crop boxes for a given page:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf; <span class="comment">// PDF file</span>
|
||
size_t i; <span class="comment">// Looping var</span>
|
||
size_t count; <span class="comment">// Number of pages</span>
|
||
pdfio_obj_t *page; <span class="comment">// Current page</span>
|
||
pdfio_dict_t *dict; <span class="comment">// Current page dictionary</span>
|
||
pdfio_array_t *media_box; <span class="comment">// MediaBox array</span>
|
||
<span class="reserved">double</span> media_values[<span class="number">4</span>]; <span class="comment">// MediaBox values</span>
|
||
pdfio_array_t *crop_box; <span class="comment">// CropBox array</span>
|
||
<span class="reserved">double</span> crop_values[<span class="number">4</span>]; <span class="comment">// CropBox values</span>
|
||
|
||
<span class="comment">// Iterate the pages in the PDF file</span>
|
||
<span class="reserved">for</span> (i = <span class="number">0</span>, count = pdfioFileGetNumPages(pdf); i < count; i ++)
|
||
{
|
||
page = pdfioFileGetPage(pdf, i);
|
||
dict = pdfioObjGetDict(page);
|
||
|
||
media_box = pdfioDictGetArray(dict, <span class="string">"MediaBox"</span>);
|
||
media_values[<span class="number">0</span>] = pdfioArrayGetNumber(media_box, <span class="number">0</span>);
|
||
media_values[<span class="number">1</span>] = pdfioArrayGetNumber(media_box, <span class="number">1</span>);
|
||
media_values[<span class="number">2</span>] = pdfioArrayGetNumber(media_box, <span class="number">2</span>);
|
||
media_values[<span class="number">3</span>] = pdfioArrayGetNumber(media_box, <span class="number">3</span>);
|
||
|
||
crop_box = pdfioDictGetArray(dict, <span class="string">"CropBox"</span>);
|
||
crop_values[<span class="number">0</span>] = pdfioArrayGetNumber(crop_box, <span class="number">0</span>);
|
||
crop_values[<span class="number">1</span>] = pdfioArrayGetNumber(crop_box, <span class="number">1</span>);
|
||
crop_values[<span class="number">2</span>] = pdfioArrayGetNumber(crop_box, <span class="number">2</span>);
|
||
crop_values[<span class="number">3</span>] = pdfioArrayGetNumber(crop_box, <span class="number">3</span>);
|
||
|
||
printf(<span class="string">"Page %u: MediaBox=[%g %g %g %g], CropBox=[%g %g %g %g]\n"</span>,
|
||
(<span class="reserved">unsigned</span>)(i + <span class="number">1</span>),
|
||
media_values[<span class="number">0</span>], media_values[<span class="number">1</span>], media_values[<span class="number">2</span>], media_values[<span class="number">3</span>],
|
||
crop_values[<span class="number">0</span>], crop_values[<span class="number">1</span>], crop_values[<span class="number">2</span>], crop_values[<span class="number">3</span>]);
|
||
}
|
||
</code></pre>
|
||
<p>Page object dictionaries have several (mostly optional) key/value pairs, including:</p>
|
||
<ul>
|
||
<li><p>"Annots": An array of annotation dictionaries for the page; use <a href="#pdfioDictGetArray"><code>pdfioDictGetArray</code></a> to get the array</p>
|
||
</li>
|
||
<li><p>"CropBox": The crop box as an array of four numbers for the left, bottom, right, and top coordinates of the target media; use <a href="#pdfioDictGetArray"><code>pdfioDictGetArray</code></a> to get a pointer to the array of numbers</p>
|
||
</li>
|
||
<li><p>"Dur": The number of seconds the page should be displayed; use <a href="#pdfioDictGetNumber"><code>pdfioDictGetNumber</code></a> to get the page duration value</p>
|
||
</li>
|
||
<li><p>"Group": The dictionary of transparency group values for the page; use <a href="#pdfioDictGetDict"><code>pdfioDictGetDict</code></a> to get a pointer to the resources dictionary</p>
|
||
</li>
|
||
<li><p>"LastModified": The date and time when this page was last modified; use <a href="#pdfioDictGetDate"><code>pdfioDictGetDate</code></a> to get the Unix <code>time_t</code> value</p>
|
||
</li>
|
||
<li><p>"Parent": The parent page tree node object for this page; use <a href="#pdfioDictGetObj"><code>pdfioDictGetObj</code></a> to get a pointer to the object</p>
|
||
</li>
|
||
<li><p>"MediaBox": The media box as an array of four numbers for the left, bottom, right, and top coordinates of the target media; use <a href="#pdfioDictGetArray"><code>pdfioDictGetArray</code></a> to get a pointer to the array of numbers</p>
|
||
</li>
|
||
<li><p>"Resources": The dictionary of resources for the page; use <a href="#pdfioDictGetDict"><code>pdfioDictGetDict</code></a> to get a pointer to the resources dictionary</p>
|
||
</li>
|
||
<li><p>"Rotate": A number indicating the number of degrees of counter-clockwise rotation to apply to the page when viewing; use <a href="#pdfioDictGetNumber"><code>pdfioDictGetNumber</code></a> to get the rotation angle</p>
|
||
</li>
|
||
<li><p>"Thumb": A thumbnail image object for the page; use <a href="#pdfioDictGetObj"><code>pdfioDictGetObj</code></a> to get a pointer to the thumbnail image object</p>
|
||
</li>
|
||
<li><p>"Trans": The page transition dictionary; use <a href="#pdfioDictGetDict"><code>pdfioDictGetDict</code></a> to get a pointer to the dictionary</p>
|
||
</li>
|
||
</ul>
|
||
<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);
|
||
</code></pre>
|
||
<h3 class="title" id="writing-pdf-files">Writing PDF Files</h3>
|
||
<p>You create a new PDF file using the <a href="#pdfioFileCreate"><code>pdfioFileCreate</code></a> function:</p>
|
||
<pre><code class="language-c">pdfio_rect_t media_box = { <span class="number">0.0</span>, <span class="number">0.0</span>, <span class="number">612.0</span>, <span class="number">792.0</span> }; <span class="comment">// US Letter</span>
|
||
pdfio_rect_t crop_box = { <span class="number">36.0</span>, <span class="number">36.0</span>, <span class="number">576.0</span>, <span class="number">756.0</span> }; <span class="comment">// w/0.5" margins</span>
|
||
|
||
pdfio_file_t *pdf = pdfioFileCreate(<span class="string">"myoutputfile.pdf"</span>, <span class="string">"2.0"</span>, &media_box, &crop_box,
|
||
error_cb, error_data);
|
||
</code></pre>
|
||
<p>where the six arguments to the function are the filename ("myoutputfile.pdf"), PDF version ("2.0"), media box (<code>media_box</code>), crop box (<code>crop_box</code>), an optional error callback function (<code>error_cb</code>), and an optional pointer value for the error callback function (<code>error_data</code>). The units for the media and crop boxes are points (1/72nd of an inch).</p>
|
||
<p>Alternately you can stream a PDF file using the <a href="#pdfioFileCreateOutput"><code>pdfioFileCreateOutput</code></a> function:</p>
|
||
<pre><code class="language-c">pdfio_rect_t media_box = { <span class="number">0.0</span>, <span class="number">0.0</span>, <span class="number">612.0</span>, <span class="number">792.0</span> }; <span class="comment">// US Letter</span>
|
||
pdfio_rect_t crop_box = { <span class="number">36.0</span>, <span class="number">36.0</span>, <span class="number">576.0</span>, <span class="number">756.0</span> }; <span class="comment">// w/0.5" margins</span>
|
||
|
||
pdfio_file_t *pdf = pdfioFileCreateOutput(output_cb, output_ctx, <span class="string">"2.0"</span>, &media_box,
|
||
&crop_box, error_cb, error_data);
|
||
</code></pre>
|
||
<p>Once the file is created, use the <a href="#pdfioFileCreateObj"><code>pdfioFileCreateObj</code></a>, <a href="#pdfioFileCreatePage"><code>pdfioFileCreatePage</code></a>, and <a href="#pdfioPageCopy"><code>pdfioPageCopy</code></a> functions to create objects and pages in the file.</p>
|
||
<p>Finally, the <a href="#pdfioFileClose"><code>pdfioFileClose</code></a> function writes the PDF cross-reference and "trailer" information, closes the file, and frees all memory that was used for it.</p>
|
||
<h3 class="title" id="pdf-objects">PDF Objects</h3>
|
||
<p>PDF objects are identified using two numbers - the object number (1 to N) and the object generation (0 to 65535) that specifies a particular version of an object. An object's numbers are returned by the <a href="#pdfioObjGetNumber"><code>pdfioObjGetNumber</code></a> and <a href="#pdfioObjGetGeneration"><code>pdfioObjGetGeneration</code></a> functions. You can find a numbered object using the <a href="#pdfioFileFindObj"><code>pdfioFileFindObj</code></a> function.</p>
|
||
<p>Objects contain values (typically dictionaries) and usually an associated data stream containing images, fonts, ICC profiles, and page content. PDFio provides several accessor functions to get the value(s) associated with an object:</p>
|
||
<ul>
|
||
<li><p><a href="#pdfioObjGetArray"><code>pdfioObjGetArray</code></a> returns an object's array value, if any</p>
|
||
</li>
|
||
<li><p><a href="#pdfioObjGetDict"><code>pdfioObjGetDict</code></a> returns an object's dictionary value, if any</p>
|
||
</li>
|
||
<li><p><a href="#pdfioObjGetLength"><code>pdfioObjGetLength</code></a> returns the length of the data stream, if any</p>
|
||
</li>
|
||
<li><p><a href="#pdfioObjGetSubtype"><code>pdfioObjGetSubtype</code></a> returns the sub-type name of the object, for example "Image" for an image object.</p>
|
||
</li>
|
||
<li><p><a href="#pdfioObjGetType"><code>pdfioObjGetType</code></a> returns the type name of the object, for example "XObject" for an image object.</p>
|
||
</li>
|
||
</ul>
|
||
<h3 class="title" id="pdf-streams">PDF Streams</h3>
|
||
<p>Some PDF objects have an associated data stream, such as for pages, images, ICC color profiles, and fonts. You access the stream for an existing object using the <a href="#pdfioObjOpenStream"><code>pdfioObjOpenStream</code></a> function:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileOpen(...);
|
||
pdfio_obj_t *obj = pdfioFileFindObj(pdf, number);
|
||
pdfio_stream_t *st = pdfioObjOpenStream(obj, <span class="reserved">true</span>);
|
||
</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>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>
|
||
<ul>
|
||
<li><p><a href="#pdfioStreamConsume"><code>pdfioStreamConsume</code></a> reads and discards a number of bytes in the stream</p>
|
||
</li>
|
||
<li><p><a href="#pdfioStreamGetToken"><code>pdfioStreamGetToken</code></a> reads a PDF token from the stream</p>
|
||
</li>
|
||
<li><p><a href="#pdfioStreamPeek"><code>pdfioStreamPeek</code></a> peeks at the next stream data without advancing or "consuming" it</p>
|
||
</li>
|
||
<li><p><a href="#pdfioStreamRead"><code>pdfioStreamRead</code></a> reads a buffer of data</p>
|
||
</li>
|
||
</ul>
|
||
<p>When you are done reading from the stream, call the <a href="#pdfioStreamClose"><code>pdfioStreamClose</code></a> function:</p>
|
||
<pre><code class="language-c">pdfioStreamClose(st);
|
||
</code></pre>
|
||
<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(...);
|
||
pdfio_obj_t *obj = pdfioFileCreateObj(pdf, ...);
|
||
pdfio_stream_t *st = pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE);
|
||
</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>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>
|
||
<ul>
|
||
<li><p><a href="#pdfioStreamPrintf"><code>pdfioStreamPrintf</code></a> writes a formatted string to the stream</p>
|
||
</li>
|
||
<li><p><a href="#pdfioStreamPutChar"><code>pdfioStreamPutChar</code></a> writes a single character to the stream</p>
|
||
</li>
|
||
<li><p><a href="#pdfioStreamPuts"><code>pdfioStreamPuts</code></a> writes a C string to the stream</p>
|
||
</li>
|
||
<li><p><a href="#pdfioStreamWrite"><code>pdfioStreamWrite</code></a> writes a buffer of data to the stream</p>
|
||
</li>
|
||
</ul>
|
||
<p>The <a href="#pdf-content-helper-functions">PDF content helper functions</a> provide additional functions for writing specific PDF page stream commands.</p>
|
||
<p>When you are done writing the stream, call <a href="#pdfioStreamClose"><code>pdfioStreamClose</code></a> to close both the stream and the object.</p>
|
||
<h3 class="title" id="pdf-content-helper-functions">PDF Content Helper Functions</h3>
|
||
<p>PDFio includes many helper functions for embedding or writing specific kinds of content to a PDF file. These functions can be roughly grouped into five categories:</p>
|
||
<ul>
|
||
<li><p><a href="#color-space-functions">Color Space Functions</a></p>
|
||
</li>
|
||
<li><p><a href="#font-object-functions">Font Object Functions</a></p>
|
||
</li>
|
||
<li><p><a href="#image-object-functions">Image Object Functions</a></p>
|
||
</li>
|
||
<li><p><a href="#page-stream-functions">Page Stream Functions</a></p>
|
||
</li>
|
||
<li><p><a href="#page-dictionary-functions">Page Dictionary Functions</a></p>
|
||
</li>
|
||
</ul>
|
||
<h4 id="color-space-functions">Color Space Functions</h4>
|
||
<p>PDF color spaces are specified using well-known names like "DeviceCMYK", "DeviceGray", and "DeviceRGB" or using arrays that define so-called calibrated color spaces. PDFio provides several functions for embedding ICC profiles and creating color space arrays:</p>
|
||
<ul>
|
||
<li><p><a href="#pdfioArrayCreateColorFromICCObj"><code>pdfioArrayCreateColorFromICCObj</code></a> creates a color array for an ICC color profile object</p>
|
||
</li>
|
||
<li><p><a href="#pdfioArrayCreateColorFromMatrix"><code>pdfioArrayCreateColorFromMatrix</code></a> creates a color array using a CIE XYZ color transform matrix, a gamma value, and a CIE XYZ white point</p>
|
||
</li>
|
||
<li><p><a href="#pdfioArrayCreateColorFromPalette"><code>pdfioArrayCreateColorFromPalette</code></a> creates an indexed color array from an array of sRGB values</p>
|
||
</li>
|
||
<li><p><a href="#pdfioArrayCreateColorFromPrimaries"><code>pdfioArrayCreateColorFromPrimaries</code></a> creates a color array using CIE XYZ primaries and a gamma value</p>
|
||
</li>
|
||
<li><p><a href="#pdfioArrayCreateColorFromStandard"><code>pdfioArrayCreateColorFromStandard</code></a> creates a color array for a standard color space</p>
|
||
</li>
|
||
</ul>
|
||
<p>You can embed an ICC color profile using the <a href="#pdfioFileCreateICCObjFromFile"><code>pdfioFileCreateICCObjFromFile</code></a> function:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
|
||
pdfio_obj_t *icc = pdfioFileCreateICCObjFromFile(pdf, <span class="string">"filename.icc"</span>);
|
||
</code></pre>
|
||
<p>where the first argument is the PDF file and the second argument is the filename of the ICC color profile.</p>
|
||
<p>PDFio also includes predefined constants for creating a few standard color spaces:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
|
||
|
||
<span class="comment">// Create an AdobeRGB color array</span>
|
||
pdfio_array_t *adobe_rgb =
|
||
pdfioArrayCreateColorFromStandard(pdf, <span class="number">3</span>, PDFIO_CS_ADOBE);
|
||
|
||
<span class="comment">// Create an Display P3 color array</span>
|
||
pdfio_array_t *display_p3 =
|
||
pdfioArrayCreateColorFromStandard(pdf, <span class="number">3</span>, PDFIO_CS_P3_D65);
|
||
|
||
<span class="comment">// Create an sRGB color array</span>
|
||
pdfio_array_t *srgb =
|
||
pdfioArrayCreateColorFromStandard(pdf, <span class="number">3</span>, PDFIO_CS_SRGB);
|
||
</code></pre>
|
||
<h4 id="font-object-functions">Font Object Functions</h4>
|
||
<p>PDF supports many kinds of fonts, including PostScript Type1, PDF Type3, TrueType/OpenType, and CID. PDFio provides two functions for creating font objects. The first is <a href="#pdfioFileCreateFontObjFromBase"><code>pdfioFileCreateFontObjFromBase</code></a> which creates a font object for one of the base PDF fonts:</p>
|
||
<ul>
|
||
<li><p>"Courier"</p>
|
||
</li>
|
||
<li><p>"Courier-Bold"</p>
|
||
</li>
|
||
<li><p>"Courier-BoldItalic"</p>
|
||
</li>
|
||
<li><p>"Courier-Italic"</p>
|
||
</li>
|
||
<li><p>"Helvetica"</p>
|
||
</li>
|
||
<li><p>"Helvetica-Bold"</p>
|
||
</li>
|
||
<li><p>"Helvetica-BoldOblique"</p>
|
||
</li>
|
||
<li><p>"Helvetica-Oblique"</p>
|
||
</li>
|
||
<li><p>"Symbol"</p>
|
||
</li>
|
||
<li><p>"Times-Bold"</p>
|
||
</li>
|
||
<li><p>"Times-BoldItalic"</p>
|
||
</li>
|
||
<li><p>"Times-Italic"</p>
|
||
</li>
|
||
<li><p>"Times-Roman"</p>
|
||
</li>
|
||
<li><p>"ZapfDingbats"</p>
|
||
</li>
|
||
</ul>
|
||
<p>Except for Symbol and ZapfDingbats (which use a custom 8-bit character set), PDFio always uses the Windows CP1252 subset of Unicode for these fonts.</p>
|
||
<p>The second function is <a href="#pdfioFileCreateFontObjFromFile"><code>pdfioFileCreateFontObjFromFile</code></a> which creates a font object from a TrueType/OpenType font file, for example:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
|
||
pdfio_obj_t *arial =
|
||
pdfioFileCreateFontObjFromFile(pdf, <span class="string">"OpenSans-Regular.ttf"</span>, <span class="reserved">false</span>);
|
||
</code></pre>
|
||
<p>will embed an OpenSans Regular TrueType font using the Windows CP1252 subset of Unicode. Pass <code>true</code> for the third argument to embed it as a Unicode CID font instead, for example:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
|
||
pdfio_obj_t *arial =
|
||
pdfioFileCreateFontObjFromFile(pdf, <span class="string">"NotoSansJP-Regular.otf"</span>, <span class="reserved">true</span>);
|
||
</code></pre>
|
||
<p>will embed the NotoSansJP Regular OpenType font with full support for Unicode.</p>
|
||
<blockquote>
|
||
<p>Note: Not all fonts support Unicode, and most do not contain a full complement of Unicode characters. <code>pdfioFileCreateFontObjFromFile</code> does not perform any character subsetting, so the entire font file is embedded in the PDF file.</p>
|
||
</blockquote>
|
||
<h4 id="image-object-functions">Image Object Functions</h4>
|
||
<p>PDF supports images with many different color spaces and bit depths with optional transparency. PDFio provides two helper functions for creating image objects that can be referenced in page streams. The first function is <a href="#pdfioFileCreateImageObjFromData"><code>pdfioFileCreateImageObjFromData</code></a> which creates an image object from data in memory, for example:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
|
||
<span class="reserved">unsigned</span> <span class="reserved">char</span> data[<span class="number">1024</span> * <span class="number">1024</span> * <span class="number">4</span>]; <span class="comment">// 1024x1024 RGBA image data</span>
|
||
pdfio_obj_t *img =
|
||
pdfioFileCreateImageObjFromData(pdf, data, <span class="comment">/*width*/</span><span class="number">1024</span>, <span class="comment">/*height*/</span><span class="number">1024</span>,
|
||
<span class="comment">/*num_colors*/</span><span class="number">3</span>, <span class="comment">/*color_data*/</span>NULL,
|
||
<span class="comment">/*alpha*/</span><span class="reserved">true</span>, <span class="comment">/*interpolate*/</span><span class="reserved">false</span>);
|
||
</code></pre>
|
||
<p>will create an object for a 1024x1024 RGBA image in memory, using the default color space for 3 colors ("DeviceRGB"). We can use one of the <a href="#color-space-functions">color space functions</a> to use a specific color space for this image, for example:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
|
||
|
||
<span class="comment">// Create an AdobeRGB color array</span>
|
||
pdfio_array_t *adobe_rgb =
|
||
pdfioArrayCreateColorFromMatrix(pdf, <span class="number">3</span>, pdfioAdobeRGBGamma,
|
||
pdfioAdobeRGBMatrix, pdfioAdobeRGBWhitePoint);
|
||
|
||
<span class="comment">// Create a 1024x1024 RGBA image using AdobeRGB</span>
|
||
<span class="reserved">unsigned</span> <span class="reserved">char</span> data[<span class="number">1024</span> * <span class="number">1024</span> * <span class="number">4</span>]; <span class="comment">// 1024x1024 RGBA image data</span>
|
||
pdfio_obj_t *img =
|
||
pdfioFileCreateImageObjFromData(pdf, data, <span class="comment">/*width*/</span><span class="number">1024</span>, <span class="comment">/*height*/</span><span class="number">1024</span>,
|
||
<span class="comment">/*num_colors*/</span><span class="number">3</span>, <span class="comment">/*color_data*/</span>adobe_rgb,
|
||
<span class="comment">/*alpha*/</span><span class="reserved">true</span>, <span class="comment">/*interpolate*/</span><span class="reserved">false</span>);
|
||
</code></pre>
|
||
<p>The "interpolate" argument specifies whether the colors in the image should be smoothed/interpolated when scaling. This is most useful for photographs but should be <code>false</code> for screenshot and barcode images.</p>
|
||
<p>If you have a JPEG or PNG file, use the <a href="#pdfioFileCreateImageObjFromFile"><code>pdfioFileCreateImageObjFromFile</code></a> function to copy the image into a PDF image object, for example:</p>
|
||
<pre><code class="language-c">pdfio_file_t *pdf = pdfioFileCreate(...);
|
||
pdfio_obj_t *img =
|
||
pdfioFileCreateImageObjFromFile(pdf, <span class="string">"myphoto.jpg"</span>, <span class="comment">/*interpolate*/</span><span class="reserved">true</span>);
|
||
</code></pre>
|
||
<blockquote>
|
||
<p>Note: Currently <code>pdfioFileCreateImageObjFromFile</code> does not support 12 bit JPEG files or PNG files with an alpha channel.</p>
|
||
</blockquote>
|
||
<h4 id="page-dictionary-functions">Page Dictionary Functions</h4>
|
||
<p>PDF pages each have an associated dictionary to specify the images, fonts, and color spaces used by the page. PDFio provides functions to add these resources to the dictionary:</p>
|
||
<ul>
|
||
<li><p><a href="#pdfioPageDictAddColorSpace"><code>pdfioPageDictAddColorSpace</code></a> adds a named color space to the page dictionary</p>
|
||
</li>
|
||
<li><p><a href="#pdfioPageDictAddFont"><code>pdfioPageDictAddFont</code></a> adds a named font to the page dictionary</p>
|
||
</li>
|
||
<li><p><a href="#pdfioPageDictAddImage"><code>pdfioPageDictAddImage</code></a> adds a named image to the page dictionary</p>
|
||
</li>
|
||
</ul>
|
||
<h4 id="page-stream-functions">Page Stream Functions</h4>
|
||
<p>PDF page streams contain textual commands for drawing on the page. PDFio provides many functions for writing these commands with the correct format and escaping, as needed:</p>
|
||
<ul>
|
||
<li><p><a href="#pdfioContentClip"><code>pdfioContentClip</code></a> clips future drawing to the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentDrawImage"><code>pdfioContentDrawImage</code></a> draws an image object</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentFill"><code>pdfioContentFill</code></a> fills the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentFillAndStroke"><code>pdfioContentFillAndStroke</code></a> fills and strokes the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentMatrixConcat"><code>pdfioContentMatrixConcat</code></a> concatenates a matrix with the current transform matrix</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentMatrixRotate"><code>pdfioContentMatrixRotate</code></a> concatenates a rotation matrix with the current transform matrix</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentMatrixScale"><code>pdfioContentMatrixScale</code></a> concatenates a scaling matrix with the current transform matrix</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentMatrixTranslate"><code>pdfioContentMatrixTranslate</code></a> concatenates a translation matrix with the current transform matrix</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentPathClose"><code>pdfioContentPathClose</code></a> closes the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentPathCurve"><code>pdfioContentPathCurve</code></a> appends a Bezier curve to the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentPathCurve13"><code>pdfioContentPathCurve13</code></a> appends a Bezier curve with 2 control points to the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentPathCurve23"><code>pdfioContentPathCurve23</code></a> appends a Bezier curve with 2 control points to the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentPathLineTo"><code>pdfioContentPathLineTo</code></a> appends a line to the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentPathMoveTo"><code>pdfioContentPathMoveTo</code></a> moves the current point in the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentPathRect"><code>pdfioContentPathRect</code></a> appends a rectangle to the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentRestore"><code>pdfioContentRestore</code></a> restores a previous graphics state</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSave"><code>pdfioContentSave</code></a> saves the current graphics state</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetDashPattern"><code>pdfioContentSetDashPattern</code></a> sets the line dash pattern</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetFillColorDeviceCMYK"><code>pdfioContentSetFillColorDeviceCMYK</code></a> sets the current fill color using a device CMYK color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetFillColorDeviceGray"><code>pdfioContentSetFillColorDeviceGray</code></a> sets the current fill color using a device gray color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetFillColorDeviceRGB"><code>pdfioContentSetFillColorDeviceRGB</code></a> sets the current fill color using a device RGB color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetFillColorGray"><code>pdfioContentSetFillColorGray</code></a> sets the current fill color using a calibrated gray color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetFillColorRGB"><code>pdfioContentSetFillColorRGB</code></a> sets the current fill color using a calibrated RGB color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetFillColorSpace"><code>pdfioContentSetFillColorSpace</code></a> sets the current fill color space</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetFlatness"><code>pdfioContentSetFlatness</code></a> sets the flatness for curves</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetLineCap"><code>pdfioContentSetLineCap</code></a> sets how the ends of lines are stroked</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetLineJoin"><code>pdfioContentSetLineJoin</code></a> sets how connections between lines are stroked</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetLineWidth"><code>pdfioContentSetLineWidth</code></a> sets the width of stroked lines</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetMiterLimit"><code>pdfioContentSetMiterLimit</code></a> sets the miter limit for stroked lines</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetStrokeColorDeviceCMYK"><code>pdfioContentSetStrokeColorDeviceCMYK</code></a> sets the current stroke color using a device CMYK color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetStrokeColorDeviceGray"><code>pdfioContentSetStrokeColorDeviceGray</code></a> sets the current stroke color using a device gray color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetStrokeColorDeviceRGB"><code>pdfioContentSetStrokeColorDeviceRGB</code></a> sets the current stroke color using a device RGB color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetStrokeColorGray"><code>pdfioContentSetStrokeColorGray</code></a> sets the current stroke color using a calibrated gray color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetStrokeColorRGB"><code>pdfioContentSetStrokeColorRGB</code></a> sets the current stroke color using a calibrated RGB color</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetStrokeColorSpace"><code>pdfioContentSetStrokeColorSpace</code></a> sets the current stroke color space</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextCharacterSpacing"><code>pdfioContentSetTextCharacterSpacing</code></a> sets the spacing between characters for text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextFont"><code>pdfioContentSetTextFont</code></a> sets the font and size for text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextLeading"><code>pdfioContentSetTextLeading</code></a> sets the line height for text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextMatrix"><code>pdfioContentSetTextMatrix</code></a> concatenates a matrix with the current text matrix</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextRenderingMode"><code>pdfioContentSetTextRenderingMode</code></a> sets the text rendering mode</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextRise"><code>pdfioContentSetTextRise</code></a> adjusts the baseline for text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextWordSpacing"><code>pdfioContentSetTextWordSpacing</code></a> sets the spacing between words for text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentSetTextXScaling"><code>pdfioContentSetTextXScaling</code></a> sets the horizontal scaling for text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentStroke"><code>pdfioContentStroke</code></a> strokes the current path</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextBegin"><code>pdfioContentTextBegin</code></a> begins a block of text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextEnd"><code>pdfioContentTextEnd</code></a> ends a block of text</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextMoveLine"><code>pdfioContentTextMoveLine</code></a> moves to the next line with an offset in a text block</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextMoveTo"><code>pdfioContentTextMoveTo</code></a> moves within the current line in a text block</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextNewLine"><code>pdfioContentTextNewLine</code></a> moves to the beginning of the next line in a text block</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextNewLineShow"><code>pdfioContentTextNewLineShow</code></a> moves to the beginning of the next line in a text block and shows literal text with optional word and character spacing</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextNewLineShowf"><code>pdfioContentTextNewLineShowf</code></a> moves to the beginning of the next line in a text block and shows formatted text with optional word and character spacing</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextShow"><code>pdfioContentTextShow</code></a> draws a literal string in a text block</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextShowf"><code>pdfioContentTextShowf</code></a> draws a formatted string in a text block</p>
|
||
</li>
|
||
<li><p><a href="#pdfioContentTextShowJustified"><code>pdfioContentTextShowJustified</code></a> draws an array of literal strings with offsets between them</p>
|
||
</li>
|
||
</ul>
|
||
<h2 class="title" id="examples">Examples</h2>
|
||
<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 <pdfio.h></span>
|
||
<span class="directive">#include <time.h></span>
|
||
|
||
|
||
<span class="reserved">int</span> <span class="comment">// O - Exit status</span>
|
||
main(<span class="reserved">int</span> argc, <span class="comment">// I - Number of command-line arguments</span>
|
||
<span class="reserved">char</span> *argv[]) <span class="comment">// Command-line arguments</span>
|
||
{
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *filename; <span class="comment">// PDF filename</span>
|
||
pdfio_file_t *pdf; <span class="comment">// PDF file</span>
|
||
time_t creation_date; <span class="comment">// Creation date</span>
|
||
<span class="reserved">struct</span> tm *creation_tm; <span class="comment">// Creation date/time information</span>
|
||
<span class="reserved">char</span> creation_text[<span class="number">256</span>]; <span class="comment">// Creation date/time as a string</span>
|
||
|
||
|
||
<span class="comment">// Get the filename from the command-line...</span>
|
||
<span class="reserved">if</span> (argc != <span class="number">2</span>)
|
||
{
|
||
fputs(<span class="string">"Usage: ./pdfioinfo FILENAME.pdf\n"</span>, stderr);
|
||
<span class="reserved">return</span> (<span class="number">1</span>);
|
||
}
|
||
|
||
filename = argv[<span class="number">1</span>];
|
||
|
||
<span class="comment">// Open the PDF file with the default callbacks...</span>
|
||
pdf = pdfioFileOpen(filename, <span class="comment">/*password_cb*/</span>NULL, <span class="comment">/*password_cbdata*/</span>NULL,
|
||
<span class="comment">/*error_cb*/</span>NULL, <span class="comment">/*error_cbdata*/</span>NULL);
|
||
<span class="reserved">if</span> (pdf == NULL)
|
||
<span class="reserved">return</span> (<span class="number">1</span>);
|
||
|
||
<span class="comment">// Get the creation date and convert to a string...</span>
|
||
creation_date = pdfioFileGetCreationDate(pdf);
|
||
creation_tm = localtime(&creation_date);
|
||
strftime(creation_text, <span class="reserved">sizeof</span>(creation_text), <span class="string">"%c"</span>, creation_tm);
|
||
|
||
<span class="comment">// Print file information to stdout...</span>
|
||
printf(<span class="string">"%s:\n"</span>, filename);
|
||
printf(<span class="string">" Title: %s\n"</span>, pdfioFileGetTitle(pdf));
|
||
printf(<span class="string">" Author: %s\n"</span>, pdfioFileGetAuthor(pdf));
|
||
printf(<span class="string">" Created On: %s\n"</span>, creation_text);
|
||
printf(<span class="string">" Number Pages: %u\n"</span>, (<span class="reserved">unsigned</span>)pdfioFileGetNumPages(pdf));
|
||
|
||
<span class="comment">// Close the PDF file...</span>
|
||
pdfioFileClose(pdf);
|
||
|
||
<span class="reserved">return</span> (<span class="number">0</span>);
|
||
}
|
||
</code></pre>
|
||
<h3 class="title" id="extract-text-from-pdf-file">Extract Text from PDF File</h3>
|
||
<p>The <code>pdf2text.c</code> example code extracts non-Unicode text from a PDF file by scanning each page for strings and text drawing commands. Since it doesn't look at the font encoding or support Unicode text, it is really only useful to extract plain ASCII text from a PDF file. And since it writes text in the order it appears in the page stream, it may not come out in the same order as appears on the page.</p>
|
||
<p>The <a href="#pdfioStreamGetToken"><code>pdfioStreamGetToken</code></a> function is used to read individual tokens from the page streams. Tokens starting with the open parenthesis are text strings, while PDF operators are left as-is. We use some simple logic to make sure that we include spaces between text strings and add newlines for the text operators that start a new line in a text block:</p>
|
||
<pre><code class="language-c">pdfio_stream_t *st; <span class="comment">// Page stream</span>
|
||
<span class="reserved">bool</span> first = <span class="reserved">true</span>; <span class="comment">// First string on line?</span>
|
||
<span class="reserved">char</span> buffer[<span class="number">1024</span>]; <span class="comment">// Token buffer</span>
|
||
|
||
<span class="comment">// Read PDF tokens from the page stream...</span>
|
||
<span class="reserved">while</span> (pdfioStreamGetToken(st, buffer, <span class="reserved">sizeof</span>(buffer)))
|
||
{
|
||
<span class="reserved">if</span> (buffer[<span class="number">0</span>] == <span class="string">'('</span>)
|
||
{
|
||
<span class="comment">// Text string using an 8-bit encoding</span>
|
||
<span class="reserved">if</span> (first)
|
||
first = <span class="reserved">false</span>;
|
||
<span class="reserved">else</span> <span class="reserved">if</span> (buffer[<span class="number">1</span>] != <span class="string">' '</span>)
|
||
putchar(<span class="string">' '</span>);
|
||
|
||
fputs(buffer + <span class="number">1</span>, stdout);
|
||
}
|
||
<span class="reserved">else</span> <span class="reserved">if</span> (!strcmp(buffer, <span class="string">"Td"</span>) || !strcmp(buffer, <span class="string">"TD"</span>) || !strcmp(buffer, <span class="string">"T*"</span>) ||
|
||
!strcmp(buffer, <span class="string">"\'"</span>) || !strcmp(buffer, <span class="string">"\""</span>))
|
||
{
|
||
<span class="comment">// Text operators that advance to the next line in the block</span>
|
||
putchar(<span class="string">'\n'</span>);
|
||
first = <span class="reserved">true</span>;
|
||
}
|
||
}
|
||
|
||
<span class="reserved">if</span> (!first)
|
||
putchar(<span class="string">'\n'</span>);
|
||
</code></pre>
|
||
<h3 class="title" id="create-a-pdf-file-with-text-and-an-image">Create a PDF File With Text and an Image</h3>
|
||
<p>The <code>image2pdf.c</code> example code creates a PDF file containing a JPEG or PNG image file and optional caption on a single page. The <code>create_pdf_image_file</code> function creates the PDF file, embeds a base font and the named JPEG or PNG image file, and then creates a page with the image centered on the page with any text centered below:</p>
|
||
<pre><code class="language-c"><span class="directive">#include <pdfio.h></span>
|
||
<span class="directive">#include <pdfio-content.h></span>
|
||
<span class="directive">#include <string.h></span>
|
||
|
||
|
||
<span class="reserved">bool</span> <span class="comment">// O - True on success, false on failure</span>
|
||
create_pdf_image_file(
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfname, <span class="comment">// I - PDF filename</span>
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *imagename, <span class="comment">// I - Image filename</span>
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *caption) <span class="comment">// I - Caption filename</span>
|
||
{
|
||
pdfio_file_t *pdf; <span class="comment">// PDF file</span>
|
||
pdfio_obj_t *font; <span class="comment">// Caption font</span>
|
||
pdfio_obj_t *image; <span class="comment">// Image</span>
|
||
pdfio_dict_t *dict; <span class="comment">// Page dictionary</span>
|
||
pdfio_stream_t *page; <span class="comment">// Page stream</span>
|
||
<span class="reserved">double</span> width, height; <span class="comment">// Width and height of image</span>
|
||
<span class="reserved">double</span> swidth, sheight; <span class="comment">// Scaled width and height on page</span>
|
||
<span class="reserved">double</span> tx, ty; <span class="comment">// Position on page</span>
|
||
|
||
|
||
<span class="comment">// Create the PDF file...</span>
|
||
pdf = pdfioFileCreate(pdfname, <span class="comment">/*version*/</span>NULL, <span class="comment">/*media_box*/</span>NULL, <span class="comment">/*crop_box*/</span>NULL,
|
||
<span class="comment">/*error_cb*/</span>NULL, <span class="comment">/*error_cbdata*/</span>NULL);
|
||
<span class="reserved">if</span> (!pdf)
|
||
<span class="reserved">return</span> (<span class="reserved">false</span>);
|
||
|
||
<span class="comment">// Create a Courier base font for the caption</span>
|
||
font = pdfioFileCreateFontObjFromBase(pdf, <span class="string">"Courier"</span>);
|
||
|
||
<span class="reserved">if</span> (!font)
|
||
{
|
||
pdfioFileClose(pdf);
|
||
<span class="reserved">return</span> (<span class="reserved">false</span>);
|
||
}
|
||
|
||
<span class="comment">// Create an image object from the JPEG/PNG image file...</span>
|
||
image = pdfioFileCreateImageObjFromFile(pdf, imagename, <span class="reserved">true</span>);
|
||
|
||
<span class="reserved">if</span> (!image)
|
||
{
|
||
pdfioFileClose(pdf);
|
||
<span class="reserved">return</span> (<span class="reserved">false</span>);
|
||
}
|
||
|
||
<span class="comment">// Create a page dictionary with the font and image...</span>
|
||
dict = pdfioDictCreate(pdf);
|
||
pdfioPageDictAddFont(dict, <span class="string">"F1"</span>, font);
|
||
pdfioPageDictAddImage(dict, <span class="string">"IM1"</span>, image);
|
||
|
||
<span class="comment">// Create the page and its content stream...</span>
|
||
page = pdfioFileCreatePage(pdf, dict);
|
||
|
||
<span class="comment">// Position and scale the image on the page...</span>
|
||
width = pdfioImageGetWidth(image);
|
||
height = pdfioImageGetHeight(image);
|
||
|
||
<span class="comment">// Default media_box is "universal" 595.28x792 points (8.27x11in or 210x279mm).</span>
|
||
<span class="comment">// Use margins of 36 points (0.5in or 12.7mm) with another 36 points for the</span>
|
||
<span class="comment">// caption underneath...</span>
|
||
swidth = <span class="number">595.28</span> - <span class="number">72.0</span>;
|
||
sheight = swidth * height / width;
|
||
<span class="reserved">if</span> (sheight > (<span class="number">792.0</span> - <span class="number">36.0</span> - <span class="number">72.0</span>))
|
||
{
|
||
sheight = <span class="number">792.0</span> - <span class="number">36.0</span> - <span class="number">72.0</span>;
|
||
swidth = sheight * width / height;
|
||
}
|
||
|
||
tx = <span class="number">0.5</span> * (<span class="number">595.28</span> - swidth);
|
||
ty = <span class="number">0.5</span> * (<span class="number">792</span> - <span class="number">36</span> - sheight);
|
||
|
||
pdfioContentDrawImage(page, <span class="string">"IM1"</span>, tx, ty + <span class="number">36.0</span>, swidth, sheight);
|
||
|
||
<span class="comment">// Draw the caption in black...</span>
|
||
pdfioContentSetFillColorDeviceGray(page, <span class="number">0.0</span>);
|
||
|
||
<span class="comment">// Compute the starting point for the text - Courier is monospaced with a</span>
|
||
<span class="comment">// nominal width of 0.6 times the text height...</span>
|
||
tx = <span class="number">0.5</span> * (<span class="number">595.28</span> - <span class="number">18.0</span> * <span class="number">0.6</span> * strlen(caption));
|
||
|
||
<span class="comment">// Position and draw the caption underneath...</span>
|
||
pdfioContentTextBegin(page);
|
||
pdfioContentSetTextFont(page, <span class="string">"F1"</span>, <span class="number">18.0</span>);
|
||
pdfioContentTextMoveTo(page, tx, ty);
|
||
pdfioContentTextShow(page, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, caption);
|
||
pdfioContentTextEnd(page);
|
||
|
||
<span class="comment">// Close the page stream and the PDF file...</span>
|
||
pdfioStreamClose(page);
|
||
pdfioFileClose(pdf);
|
||
|
||
<span class="reserved">return</span> (<span class="reserved">true</span>);
|
||
}
|
||
</code></pre>
|
||
<h3 class="title" id="generate-a-code-128-barcode">Generate a Code 128 Barcode</h3>
|
||
<p>One-dimensional barcodes are often rendered using special fonts that map ASCII characters to sequences of bars that can be read. The <code>examples</code> directory contains such a font (<code>code128.ttf</code>) to create "Code 128" barcodes, with an accompanying bit of example code in <code>code128.c</code>.</p>
|
||
<p>The first thing you need to do is prepare the barcode string to use with the font. Each barcode begins with a start pattern followed by the characters or digits you want to encode, a weighted sum digit, and a stop pattern. The <code>make_code128</code> function creates this string:</p>
|
||
<pre><code class="language-c"><span class="reserved">static</span> <span class="reserved">char</span> * <span class="comment">// O - Output string</span>
|
||
make_code128(<span class="reserved">char</span> *dst, <span class="comment">// I - Destination buffer</span>
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *src, <span class="comment">// I - Source string</span>
|
||
size_t dstsize) <span class="comment">// I - Size of destination buffer</span>
|
||
{
|
||
<span class="reserved">char</span> *dstptr, <span class="comment">// Pointer into destination buffer</span>
|
||
*dstend; <span class="comment">// End of destination buffer</span>
|
||
<span class="reserved">int</span> sum; <span class="comment">// Weighted sum</span>
|
||
<span class="reserved">static</span> <span class="reserved">const</span> <span class="reserved">char</span> *code128_chars = <span class="comment">// Code 128 characters</span>
|
||
<span class="string">" !\"#$%&'()*+,-./0123456789:;<=>?"</span>
|
||
<span class="string">"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"</span>
|
||
<span class="string">"`abcdefghijklmnopqrstuvwxyz{|}~\303"</span>
|
||
<span class="string">"\304\305\306\307\310\311\312"</span>;
|
||
<span class="reserved">static</span> <span class="reserved">const</span> <span class="reserved">char</span> code128_start_code_b = <span class="string">'\314'</span>;
|
||
<span class="comment">// Start code B</span>
|
||
<span class="reserved">static</span> <span class="reserved">const</span> <span class="reserved">char</span> code128_stop = <span class="string">'\316'</span>;
|
||
<span class="comment">// Stop pattern</span>
|
||
|
||
|
||
<span class="comment">// Start a Code B barcode...</span>
|
||
dstptr = dst;
|
||
dstend = dst + dstsize - <span class="number">3</span>;
|
||
|
||
*dstptr++ = code128_start_code_b;
|
||
sum = code128_start_code_b - <span class="number">100</span>;
|
||
|
||
<span class="reserved">while</span> (*src && dstptr < dstend)
|
||
{
|
||
<span class="reserved">if</span> (*src >= <span class="string">' '</span> && *src < <span class="number">0x7f</span>)
|
||
{
|
||
sum += (dstptr - dst) * (*src - <span class="string">' '</span>);
|
||
*dstptr++ = *src;
|
||
}
|
||
|
||
src ++;
|
||
}
|
||
|
||
<span class="comment">// Add the weighted sum modulo 103</span>
|
||
*dstptr++ = code128_chars[sum % <span class="number">103</span>];
|
||
|
||
<span class="comment">// Add the stop pattern and return...</span>
|
||
*dstptr++ = code128_stop;
|
||
*dstptr = <span class="string">'\0'</span>;
|
||
|
||
<span class="reserved">return</span> (dst);
|
||
}
|
||
</code></pre>
|
||
<p>The <code>main</code> function does the rest of the work. The barcode font is imported using the <a href="#pdfioFileCreateFontObjFromFile"><code>pdfioFileCreateFontObjFromFile</code></a> function. We pass <code>false</code> for the "unicode" argument since we just want the (default) ASCII encoding:</p>
|
||
<pre><code class="language-c">barcode_font = pdfioFileCreateFontObjFromFile(pdf, <span class="string">"code128.ttf"</span>, <span class="comment">/*unicode*/</span><span class="reserved">false</span>);
|
||
</code></pre>
|
||
<p>Since barcodes usually have the number or text represented by the barcode printed underneath it, we also need a regular text font, for which we can choose one of the standard 14 PostScript base fonts using the <a href="#pdfioFIleCreateFontObjFromBase"><code>pdfioFIleCreateFontObjFromBase</code></a> function:</p>
|
||
<pre><code class="language-c">text_font = pdfioFileCreateFontObjFromBase(pdf, <span class="string">"Helvetica"</span>);
|
||
</code></pre>
|
||
<p>Once we have these fonts we can measure the barcode and regular text labels using the <a href="#pdfioContentTextMeasure"><code>pdfioContentTextMeasure</code></a> function to determine how large the PDF page needs to be to hold the barcode and text:</p>
|
||
<pre><code class="language-c"><span class="comment">// Compute sizes of the text...</span>
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *barcode = argv[<span class="number">1</span>];
|
||
<span class="reserved">char</span> barcode_temp[<span class="number">256</span>];
|
||
|
||
<span class="reserved">if</span> (!(barcode[<span class="number">0</span>] & <span class="number">0x80</span>))
|
||
barcode = make_code128(barcode_temp, barcode, <span class="reserved">sizeof</span>(barcode_temp));
|
||
|
||
<span class="reserved">double</span> barcode_height = <span class="number">36.0</span>;
|
||
<span class="reserved">double</span> barcode_width =
|
||
pdfioContentTextMeasure(barcode_font, barcode, barcode_height);
|
||
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *text = argv[<span class="number">2</span>];
|
||
<span class="reserved">double</span> text_height = <span class="number">0.0</span>;
|
||
<span class="reserved">double</span> text_width = <span class="number">0.0</span>;
|
||
|
||
<span class="reserved">if</span> (text && text_font)
|
||
{
|
||
text_height = <span class="number">9.0</span>;
|
||
text_width = pdfioContentTextMeasure(text_font, text, text_height);
|
||
}
|
||
|
||
<span class="comment">// Compute the size of the PDF page...</span>
|
||
pdfio_rect_t media_box;
|
||
|
||
media_box.x1 = <span class="number">0.0</span>;
|
||
media_box.y1 = <span class="number">0.0</span>;
|
||
media_box.x2 = (barcode_width > text_width ? barcode_width : text_width) + <span class="number">18.0</span>;
|
||
media_box.y2 = barcode_height + text_height + <span class="number">18.0</span>;
|
||
</code></pre>
|
||
<p>Finally, we just need to create a page of the specified size that references the two fonts:</p>
|
||
<pre><code class="language-c"><span class="comment">// Start a page for the barcode...</span>
|
||
page_dict = pdfioDictCreate(pdf);
|
||
|
||
pdfioDictSetRect(page_dict, <span class="string">"MediaBox"</span>, &media_box);
|
||
pdfioDictSetRect(page_dict, <span class="string">"CropBox"</span>, &media_box);
|
||
|
||
pdfioPageDictAddFont(page_dict, <span class="string">"B128"</span>, barcode_font);
|
||
<span class="reserved">if</span> (text_font)
|
||
pdfioPageDictAddFont(page_dict, <span class="string">"TEXT"</span>, text_font);
|
||
|
||
page_st = pdfioFileCreatePage(pdf, page_dict);
|
||
</code></pre>
|
||
<p>With the barcode font called "B128" and the text font called "TEXT", we can use them to draw two strings:</p>
|
||
<pre><code class="language-c"><span class="comment">// Draw the page...</span>
|
||
pdfioContentSetFillColorGray(page_st, <span class="number">0.0</span>);
|
||
|
||
pdfioContentSetTextFont(page_st, <span class="string">"B128"</span>, barcode_height);
|
||
pdfioContentTextBegin(page_st);
|
||
pdfioContentTextMoveTo(page_st, <span class="number">0.5</span> * (media_box.x2 - barcode_width),
|
||
<span class="number">9.0</span> + text_height);
|
||
pdfioContentTextShow(page_st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, barcode);
|
||
pdfioContentTextEnd(page_st);
|
||
|
||
<span class="reserved">if</span> (text && text_font)
|
||
{
|
||
pdfioContentSetTextFont(page_st, <span class="string">"TEXT"</span>, text_height);
|
||
pdfioContentTextBegin(page_st);
|
||
pdfioContentTextMoveTo(page_st, <span class="number">0.5</span> * (media_box.x2 - text_width), <span class="number">9.0</span>);
|
||
pdfioContentTextShow(page_st, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, text);
|
||
pdfioContentTextEnd(page_st);
|
||
}
|
||
|
||
pdfioStreamClose(page_st);
|
||
</code></pre>
|
||
<h3 class="title" id="convert-markdown-to-pdf">Convert Markdown to PDF</h3>
|
||
<p>Markdown is a simple plain text format that supports things like headings, links, character styles, tables, and embedded images. The <code>md2pdf.c</code> example code uses the <a href="https://www.msweet.org/mmd/">mmd</a> library to convert markdown to a PDF file that can be distributed.</p>
|
||
<blockquote>
|
||
<p>Note: The md2pdf example is by far the most complex example code included with PDFio and shows how to layout text, add headers and footers, add links, embed images, format tables, and add an outline (table of contents) for navigation.</p>
|
||
</blockquote>
|
||
<h4 id="managing-document-state">Managing Document State</h4>
|
||
<p>The <code>md2pdf</code> program needs to maintain three sets of state - one for the markdown document which is represented by nodes of type <code>mmd_t</code> and the others for the PDF document and current PDF page which are contained in the <code>docdata_t</code> structure:</p>
|
||
<pre><code class="language-c"><span class="reserved">typedef</span> <span class="reserved">struct</span> docdata_s <span class="comment">// Document formatting data</span>
|
||
{
|
||
<span class="comment">// State for the whole document</span>
|
||
pdfio_file_t *pdf; <span class="comment">// PDF file</span>
|
||
pdfio_rect_t media_box; <span class="comment">// Media (page) box</span>
|
||
pdfio_rect_t crop_box; <span class="comment">// Crop box (for margins)</span>
|
||
pdfio_rect_t art_box; <span class="comment">// Art box (for markdown content)</span>
|
||
pdfio_obj_t *fonts[DOCFONT_MAX]; <span class="comment">// Embedded fonts</span>
|
||
<span class="reserved">double</span> font_space; <span class="comment">// Unit width of a space</span>
|
||
size_t num_images; <span class="comment">// Number of embedded images</span>
|
||
docimage_t images[DOCIMAGE_MAX]; <span class="comment">// Embedded images</span>
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *title; <span class="comment">// Document title</span>
|
||
<span class="reserved">char</span> *heading; <span class="comment">// Current document heading</span>
|
||
size_t num_actions; <span class="comment">// Number of actions for this document</span>
|
||
docaction_t actions[DOCACTION_MAX]; <span class="comment">// Actions for this document</span>
|
||
size_t num_targets; <span class="comment">// Number of targets for this document</span>
|
||
doctarget_t targets[DOCTARGET_MAX]; <span class="comment">// Targets for this document</span>
|
||
size_t num_toc; <span class="comment">// Number of table-of-contents entries</span>
|
||
doctoc_t toc[DOCTOC_MAX]; <span class="comment">// Table-of-contents entries</span>
|
||
|
||
<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>
|
||
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>
|
||
pdfio_array_t *annots_array; <span class="comment">// Annotations array (for links)</span>
|
||
pdfio_obj_t *annots_obj; <span class="comment">// Annotations object (for links)</span>
|
||
size_t num_links; <span class="comment">// Number of links for this page</span>
|
||
doclink_t links[DOCLINK_MAX]; <span class="comment">// Links for this page</span>
|
||
} docdata_t;
|
||
</code></pre>
|
||
<h5 id="document-state">Document State</h5>
|
||
<p>The output is fixed to the "universal" media size (the intersection of US Letter and ISO A4) with 1/2 inch margins - the <code>PAGE_</code> constants can be changed to select a different size or margins. The <code>media_box</code> member contains the "MediaBox" rectangle for the PDF pages, while the <code>crop_box</code> and <code>art_box</code> members contain the "CropBox" and "ArtBox" values, respectively.</p>
|
||
<p>Four embedded fonts are used:</p>
|
||
<ul>
|
||
<li><p><code>DOCFONT_REGULAR</code>: the default font used for text,</p>
|
||
</li>
|
||
<li><p><code>DOCFONT_BOLD</code>: a boldface font used for heading and strong text,</p>
|
||
</li>
|
||
<li><p><code>DOCFONT_ITALIC</code>: an italic/oblique font used for emphasized text, and</p>
|
||
</li>
|
||
<li><p><code>DOCFONT_MONOSPACE</code>: a fixed-width font used for code.</p>
|
||
</li>
|
||
</ul>
|
||
<p>By default the code uses the base PostScript fonts Helvetica, Helvetica-Bold, Helvetica-Oblique, and Courier. The <code>USE_TRUETYPE</code> define can be used to replace these with the Roboto TrueType fonts.</p>
|
||
<p>Embedded JPEG and PNG images are copied into the PDF document, with the <code>images</code> array containing the list of the images and their objects.</p>
|
||
<p>The <code>title</code> member contains the document title, while the <code>heading</code> member contains the current heading text.</p>
|
||
<p>The <code>actions</code> array contains a list of action dictionaries for interior document links that need to be resolved, while the <code>targets</code> array keeps track of the location of the headings in the PDF document.</p>
|
||
<p>The <code>toc</code> array contains a list of headings and is used to construct the PDF outlines dictionaries/objects, which provides a table of contents for navigation in most PDF readers.</p>
|
||
<h5 id="page-state">Page State</h5>
|
||
<p>The <code>st</code> member provides the stream for the current page content. The <code>color</code>, <code>font</code>, <code>fsize</code>, and <code>y</code> members provide the current graphics state on the page.</p>
|
||
<p>The <code>annots_array</code>, <code>annots_obj</code>, <code>num_links</code>, and <code>links</code> members contain a list of hyperlinks on the current page.</p>
|
||
<h4 id="creating-pages">Creating Pages</h4>
|
||
<p>The <code>new_page</code> function is used to start a new page. Aside from creating the new page object and stream, it adds a standard header and footer to the page. It starts by closing the current page if it is open:</p>
|
||
<pre><code class="language-c"><span class="comment">// Close the current page...</span>
|
||
<span class="reserved">if</span> (dd->st)
|
||
{
|
||
pdfioStreamClose(dd->st);
|
||
add_links(dd);
|
||
}
|
||
</code></pre>
|
||
<p>The new page needs a dictionary containing any link annotations, the media and art boxes, the four fonts, and any images:</p>
|
||
<pre><code class="language-c"><span class="comment">// Prep the new page...</span>
|
||
page_dict = pdfioDictCreate(dd->pdf);
|
||
|
||
dd->annots_array = pdfioArrayCreate(dd->pdf);
|
||
dd->annots_obj = pdfioFileCreateArrayObj(dd->pdf, dd->annots_array);
|
||
pdfioDictSetObj(page_dict, <span class="string">"Annots"</span>, dd->annots_obj);
|
||
|
||
pdfioDictSetRect(page_dict, <span class="string">"MediaBox"</span>, &dd->media_box);
|
||
pdfioDictSetRect(page_dict, <span class="string">"ArtBox"</span>, &dd->art_box);
|
||
|
||
<span class="reserved">for</span> (fontface = DOCFONT_REGULAR; fontface < DOCFONT_MAX; fontface ++)
|
||
pdfioPageDictAddFont(page_dict, docfont_names[fontface], dd->fonts[fontface]);
|
||
|
||
<span class="reserved">for</span> (i = <span class="number">0</span>; i < dd->num_images; i ++)
|
||
pdfioPageDictAddImage(page_dict, pdfioStringCreatef(dd->pdf, <span class="string">"I%u"</span>, (<span class="reserved">unsigned</span>)i),
|
||
dd->images[i].obj);
|
||
</code></pre>
|
||
<p>Once the page dictionary is initialized, we create a new page and initialize the current graphics state:</p>
|
||
<pre><code class="language-c">dd->st = pdfioFileCreatePage(dd->pdf, page_dict);
|
||
dd->color = DOCCOLOR_BLACK;
|
||
dd->font = DOCFONT_MAX;
|
||
dd->fsize = <span class="number">0.0</span>;
|
||
dd->y = dd->art_box.y2;
|
||
</code></pre>
|
||
<p>The header consists of a dark gray separating line and the document title. We don't show the header on the first page:</p>
|
||
<pre><code class="language-c"><span class="comment">// Add header/footer text</span>
|
||
set_color(dd, DOCCOLOR_GRAY);
|
||
set_font(dd, DOCFONT_REGULAR, SIZE_HEADFOOT);
|
||
|
||
<span class="reserved">if</span> (pdfioFileGetNumPages(dd->pdf) > <span class="number">1</span> && dd->title)
|
||
{
|
||
<span class="comment">// Show title in header...</span>
|
||
width = pdfioContentTextMeasure(dd->fonts[DOCFONT_REGULAR], dd->title,
|
||
SIZE_HEADFOOT);
|
||
|
||
pdfioContentTextBegin(dd->st);
|
||
pdfioContentTextMoveTo(dd->st,
|
||
dd->crop_box.x1 + <span class="number">0.5</span> * (dd->crop_box.x2 -
|
||
dd->crop_box.x1 - width),
|
||
dd->crop_box.y2 - SIZE_HEADFOOT);
|
||
pdfioContentTextShow(dd->st, UNICODE_VALUE, dd->title);
|
||
pdfioContentTextEnd(dd->st);
|
||
|
||
pdfioContentPathMoveTo(dd->st, dd->crop_box.x1,
|
||
dd->crop_box.y2 - <span class="number">2</span> * SIZE_HEADFOOT * LINE_HEIGHT +
|
||
SIZE_HEADFOOT);
|
||
pdfioContentPathLineTo(dd->st, dd->crop_box.x2,
|
||
dd->crop_box.y2 - <span class="number">2</span> * SIZE_HEADFOOT * LINE_HEIGHT +
|
||
SIZE_HEADFOOT);
|
||
pdfioContentStroke(dd->st);
|
||
}
|
||
</code></pre>
|
||
<p>The footer contains the same dark gray separating line with the current heading and page number on opposite sides. The page number is always positioned on the outer edge for a two-sided print - right justified on odd numbered pages and left justified on even numbered pages:</p>
|
||
<pre><code class="language-c"><span class="comment">// Show page number and current heading...</span>
|
||
pdfioContentPathMoveTo(dd->st, dd->crop_box.x1,
|
||
dd->crop_box.y1 + SIZE_HEADFOOT * LINE_HEIGHT);
|
||
pdfioContentPathLineTo(dd->st, dd->crop_box.x2,
|
||
dd->crop_box.y1 + SIZE_HEADFOOT * LINE_HEIGHT);
|
||
pdfioContentStroke(dd->st);
|
||
|
||
pdfioContentTextBegin(dd->st);
|
||
snprintf(temp, <span class="reserved">sizeof</span>(temp), <span class="string">"%u"</span>, (<span class="reserved">unsigned</span>)pdfioFileGetNumPages(dd->pdf));
|
||
<span class="reserved">if</span> (pdfioFileGetNumPages(dd->pdf) & <span class="number">1</span>)
|
||
{
|
||
<span class="comment">// Page number on right...</span>
|
||
width = pdfioContentTextMeasure(dd->fonts[DOCFONT_REGULAR], temp, SIZE_HEADFOOT);
|
||
pdfioContentTextMoveTo(dd->st, dd->crop_box.x2 - width, dd->crop_box.y1);
|
||
}
|
||
<span class="reserved">else</span>
|
||
{
|
||
<span class="comment">// Page number on left...</span>
|
||
pdfioContentTextMoveTo(dd->st, dd->crop_box.x1, dd->crop_box.y1);
|
||
}
|
||
|
||
pdfioContentTextShow(dd->st, UNICODE_VALUE, temp);
|
||
pdfioContentTextEnd(dd->st);
|
||
|
||
<span class="reserved">if</span> (dd->heading)
|
||
{
|
||
pdfioContentTextBegin(dd->st);
|
||
|
||
<span class="reserved">if</span> (pdfioFileGetNumPages(dd->pdf) & <span class="number">1</span>)
|
||
{
|
||
<span class="comment">// Current heading on left...</span>
|
||
pdfioContentTextMoveTo(dd->st, dd->crop_box.x1, dd->crop_box.y1);
|
||
}
|
||
<span class="reserved">else</span>
|
||
{
|
||
width = pdfioContentTextMeasure(dd->fonts[DOCFONT_REGULAR], dd->heading,
|
||
SIZE_HEADFOOT);
|
||
pdfioContentTextMoveTo(dd->st, dd->crop_box.x2 - width, dd->crop_box.y1);
|
||
}
|
||
|
||
pdfioContentTextShow(dd->st, UNICODE_VALUE, dd->heading);
|
||
pdfioContentTextEnd(dd->st);
|
||
}
|
||
</code></pre>
|
||
<h4 id="formatting-the-markdown-document">Formatting the Markdown Document</h4>
|
||
<p>Four functions handle the formatting of the markdown document:</p>
|
||
<ul>
|
||
<li><p><code>format_block</code> formats a single paragraph, heading, or table cell,</p>
|
||
</li>
|
||
<li><p><code>format_code</code>: formats a block of code,</p>
|
||
</li>
|
||
<li><p><code>format_doc</code>: formats the document as a whole, and</p>
|
||
</li>
|
||
<li><p><code>format_table</code>: formats a table.</p>
|
||
</li>
|
||
</ul>
|
||
<p>Formatted content is organized into arrays of <code>linefrag_t</code> and <code>tablerow_t</code> structures for a line of content or row of table cells, respectively.</p>
|
||
<h5 id="high-level-formatting">High-Level Formatting</h5>
|
||
<p>The <code>format_doc</code> function iterates over the block nodes in the markdown document. We map a "thematic break" (horizontal rule) to a page break, which is implemented by moving the current vertical position to the bottom of the page:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_THEMATIC_BREAK :
|
||
<span class="comment">// Force a page break</span>
|
||
dd->y = dd->art_box.y1;
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<p>A block quote is indented and uses the italic font by default:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_BLOCK_QUOTE :
|
||
format_doc(dd, current, DOCFONT_ITALIC, left + BQ_PADDING, right - BQ_PADDING);
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<p>Lists have a leading blank line and are indented:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_ORDERED_LIST :
|
||
<span class="reserved">case</span> MMD_TYPE_UNORDERED_LIST :
|
||
<span class="reserved">if</span> (dd->st)
|
||
dd->y -= SIZE_BODY * LINE_HEIGHT;
|
||
|
||
format_doc(dd, current, deffont, left + LIST_PADDING, right);
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<p>List items do not have a leading blank line and make use of leader text that is shown in front of the list text. The leader text is either the current item number or a bullet, which then is directly formatted using the <code>format_block</code> function:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_LIST_ITEM :
|
||
<span class="reserved">if</span> (doctype == MMD_TYPE_ORDERED_LIST)
|
||
{
|
||
snprintf(leader, <span class="reserved">sizeof</span>(leader), <span class="string">"%d. "</span>, i);
|
||
format_block(dd, current, deffont, SIZE_BODY, left, right, leader);
|
||
}
|
||
<span class="reserved">else</span>
|
||
{
|
||
format_block(dd, current, deffont, SIZE_BODY, left, right, <span class="comment">/*leader*/</span><span class="string">"• "</span>);
|
||
}
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<p>Paragraphs have a leading blank line and are likewise directly formatted:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_PARAGRAPH :
|
||
<span class="comment">// Add a blank line before the paragraph...</span>
|
||
dd->y -= SIZE_BODY * LINE_HEIGHT;
|
||
|
||
<span class="comment">// Format the paragraph...</span>
|
||
format_block(dd, current, deffont, SIZE_BODY, left, right, <span class="comment">/*leader*/</span>NULL);
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<p>Tables have a leading blank line and are formatted using the <code>format_table</code> function:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_TABLE :
|
||
<span class="comment">// Add a blank line before the paragraph...</span>
|
||
dd->y -= SIZE_BODY * LINE_HEIGHT;
|
||
|
||
<span class="comment">// Format the table...</span>
|
||
format_table(dd, current, left, right);
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<p>Code blocks have a leading blank line, are indented slightly (to account for the padded background), and are formatted using the <code>format_code</code> function:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_CODE_BLOCK :
|
||
<span class="comment">// Add a blank line before the code block...</span>
|
||
dd->y -= SIZE_BODY * LINE_HEIGHT;
|
||
|
||
<span class="comment">// Format the code block...</span>
|
||
format_code(dd, current, left + CODE_PADDING, right - CODE_PADDING);
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<p>Headings get some extra processing. First, the current heading is remembered in the <code>docdata_t</code> structure so it can be used in the page footer:</p>
|
||
<pre><code class="language-c"><span class="reserved">case</span> MMD_TYPE_HEADING_1 :
|
||
<span class="reserved">case</span> MMD_TYPE_HEADING_2 :
|
||
<span class="reserved">case</span> MMD_TYPE_HEADING_3 :
|
||
<span class="reserved">case</span> MMD_TYPE_HEADING_4 :
|
||
<span class="reserved">case</span> MMD_TYPE_HEADING_5 :
|
||
<span class="reserved">case</span> MMD_TYPE_HEADING_6 :
|
||
<span class="comment">// Update the current heading</span>
|
||
free(dd->heading);
|
||
dd->heading = mmdCopyAllText(current);
|
||
</code></pre>
|
||
<p>Then we add a blank line and format the heading with the boldface font at a larger size using the <code>format_block</code> function:</p>
|
||
<pre><code class="language-c"> <span class="comment">// Add a blank line before the heading...</span>
|
||
dd->y -= heading_sizes[curtype - MMD_TYPE_HEADING_1] * LINE_HEIGHT;
|
||
|
||
<span class="comment">// Format the heading...</span>
|
||
format_block(dd, current, DOCFONT_BOLD,
|
||
heading_sizes[curtype - MMD_TYPE_HEADING_1], left, right,
|
||
<span class="comment">/*leader*/</span>NULL);
|
||
</code></pre>
|
||
<p>Once the heading is formatted, we record it in the <code>toc</code> array as a PDF outline item object/dictionary:</p>
|
||
<pre><code class="language-c"> <span class="comment">// Add the heading to the table-of-contents...</span>
|
||
<span class="reserved">if</span> (dd->num_toc < DOCTOC_MAX)
|
||
{
|
||
doctoc_t *t = dd->toc + dd->num_toc;
|
||
<span class="comment">// New TOC</span>
|
||
pdfio_array_t *dest; <span class="comment">// Destination array</span>
|
||
|
||
t->level = curtype - MMD_TYPE_HEADING_1;
|
||
t->dict = pdfioDictCreate(dd->pdf);
|
||
t->obj = pdfioFileCreateObj(dd->pdf, t->dict);
|
||
dest = pdfioArrayCreate(dd->pdf);
|
||
|
||
pdfioArrayAppendObj(dest,
|
||
pdfioFileGetPage(dd->pdf, pdfioFileGetNumPages(dd->pdf) - <span class="number">1</span>));
|
||
pdfioArrayAppendName(dest, <span class="string">"XYZ"</span>);
|
||
pdfioArrayAppendNumber(dest, PAGE_LEFT);
|
||
pdfioArrayAppendNumber(dest,
|
||
dd->y + heading_sizes[curtype - MMD_TYPE_HEADING_1] * LINE_HEIGHT);
|
||
pdfioArrayAppendNumber(dest, <span class="number">0.0</span>);
|
||
|
||
pdfioDictSetArray(t->dict, <span class="string">"Dest"</span>, dest);
|
||
pdfioDictSetString(t->dict, <span class="string">"Title"</span>, pdfioStringCreate(dd->pdf, dd->heading));
|
||
|
||
dd->num_toc ++;
|
||
}
|
||
</code></pre>
|
||
<p>Finally, we also save the heading's target name and its location in the <code>targets</code> array to allow interior links to work:</p>
|
||
<pre><code class="language-c"> <span class="comment">// Add the heading to the list of link targets...</span>
|
||
<span class="reserved">if</span> (dd->num_targets < DOCTARGET_MAX)
|
||
{
|
||
doctarget_t *t = dd->targets + dd->num_targets;
|
||
<span class="comment">// New target</span>
|
||
|
||
make_target_name(t->name, dd->heading, <span class="reserved">sizeof</span>(t->name));
|
||
t->page = pdfioFileGetNumPages(dd->pdf) - <span class="number">1</span>;
|
||
t->y = dd->y + heading_sizes[curtype - MMD_TYPE_HEADING_1] * LINE_HEIGHT;
|
||
|
||
dd->num_targets ++;
|
||
}
|
||
<span class="reserved">break</span>;
|
||
</code></pre>
|
||
<h5 id="formatting-paragraphs-headings-list-items-and-table-cells">Formatting Paragraphs, Headings, List Items, and Table Cells</h5>
|
||
<p>Paragraphs, headings, list items, and table cells all use the same basic formatting algorithm. Text, checkboxes, and images are collected until the nodes in the current block are used up or the content reaches the right margin.</p>
|
||
<p>In order to keep adjacent blocks of text together, the formatting algorithm makes sure that at least 3 lines of text can fit before the bottom edge of the page:</p>
|
||
<pre><code class="language-c"><span class="reserved">if</span> (mmdGetNextSibling(block))
|
||
need_bottom = <span class="number">3.0</span> * SIZE_BODY * LINE_HEIGHT;
|
||
<span class="reserved">else</span>
|
||
need_bottom = <span class="number">0.0</span>;
|
||
</code></pre>
|
||
<p>Leader text (used for list items) is right justified to the left margin and becomes the first fragment on the line when present.</p>
|
||
<pre><code class="language-c"><span class="reserved">if</span> (leader)
|
||
{
|
||
<span class="comment">// Add leader text on first line...</span>
|
||
frags[<span class="number">0</span>].type = MMD_TYPE_NORMAL_TEXT;
|
||
frags[<span class="number">0</span>].width = pdfioContentTextMeasure(dd->fonts[deffont], leader, fsize);
|
||
frags[<span class="number">0</span>].height = fsize;
|
||
frags[<span class="number">0</span>].x = left - frags[<span class="number">0</span>].width;
|
||
frags[<span class="number">0</span>].imagenum = <span class="number">0</span>;
|
||
frags[<span class="number">0</span>].text = leader;
|
||
frags[<span class="number">0</span>].url = NULL;
|
||
frags[<span class="number">0</span>].ws = <span class="reserved">false</span>;
|
||
frags[<span class="number">0</span>].font = deffont;
|
||
frags[<span class="number">0</span>].color = DOCCOLOR_BLACK;
|
||
|
||
num_frags = <span class="number">1</span>;
|
||
lineheight = fsize * LINE_HEIGHT;
|
||
}
|
||
<span class="reserved">else</span>
|
||
{
|
||
<span class="comment">// No leader text...</span>
|
||
num_frags = <span class="number">0</span>;
|
||
lineheight = <span class="number">0.0</span>;
|
||
}
|
||
|
||
frag = frags + num_frags;
|
||
</code></pre>
|
||
<p>If the current content fragment won't fit, we call <code>render_line</code> to draw what we have, adjusting the left margin as needed for table cells:</p>
|
||
<pre><code class="language-c"> <span class="comment">// See if this node will fit on the current line...</span>
|
||
<span class="reserved">if</span> ((num_frags > <span class="number">0</span> && (x + width + wswidth) >= right) || num_frags == LINEFRAG_MAX)
|
||
{
|
||
<span class="comment">// No, render this line and start over...</span>
|
||
<span class="reserved">if</span> (blocktype == MMD_TYPE_TABLE_HEADER_CELL ||
|
||
blocktype == MMD_TYPE_TABLE_BODY_CELL_CENTER)
|
||
margin_left = <span class="number">0.5</span> * (right - x);
|
||
<span class="reserved">else</span> <span class="reserved">if</span> (blocktype == MMD_TYPE_TABLE_BODY_CELL_RIGHT)
|
||
margin_left = right - x;
|
||
<span class="reserved">else</span>
|
||
margin_left = <span class="number">0.0</span>;
|
||
|
||
render_line(dd, margin_left, need_bottom, lineheight, num_frags, frags);
|
||
|
||
num_frags = <span class="number">0</span>;
|
||
frag = frags;
|
||
x = left;
|
||
lineheight = <span class="number">0.0</span>;
|
||
need_bottom = <span class="number">0.0</span>;
|
||
</code></pre>
|
||
<p>Block quotes (blocks use a default font of italic) have an orange bar to the left of the block:</p>
|
||
<pre><code class="language-c"> <span class="reserved">if</span> (deffont == DOCFONT_ITALIC)
|
||
{
|
||
<span class="comment">// Add an orange bar to the left of block quotes...</span>
|
||
set_color(dd, DOCCOLOR_ORANGE);
|
||
pdfioContentSave(dd->st);
|
||
pdfioContentSetLineWidth(dd->st, <span class="number">3.0</span>);
|
||
pdfioContentPathMoveTo(dd->st, left - <span class="number">6.0</span>, dd->y - (LINE_HEIGHT - <span class="number">1.0</span>) * fsize);
|
||
pdfioContentPathLineTo(dd->st, left - <span class="number">6.0</span>, dd->y + fsize);
|
||
pdfioContentStroke(dd->st);
|
||
pdfioContentRestore(dd->st);
|
||
}
|
||
</code></pre>
|
||
<p>Finally, we add the current content fragment to the array:</p>
|
||
<pre><code class="language-c"> <span class="comment">// Add the current node to the fragment list</span>
|
||
<span class="reserved">if</span> (num_frags == <span class="number">0</span>)
|
||
{
|
||
<span class="comment">// No leading whitespace at the start of the line</span>
|
||
ws = <span class="reserved">false</span>;
|
||
wswidth = <span class="number">0.0</span>;
|
||
}
|
||
|
||
frag->type = type;
|
||
frag->x = x;
|
||
frag->width = width + wswidth;
|
||
frag->height = text ? fsize : height;
|
||
frag->imagenum = imagenum;
|
||
frag->text = text;
|
||
frag->url = url;
|
||
frag->ws = ws;
|
||
frag->font = font;
|
||
frag->color = color;
|
||
|
||
num_frags ++;
|
||
frag ++;
|
||
x += width + wswidth;
|
||
<span class="reserved">if</span> (height > lineheight)
|
||
lineheight = height;
|
||
</code></pre>
|
||
<h5 id="formatting-code-blocks">Formatting Code Blocks</h5>
|
||
<p>Code blocks consist of one or more lines of plain monospaced text. We draw a light gray background behind each line with a small bit of padding at the top and bottom:</p>
|
||
<pre><code class="language-c"><span class="comment">// Draw the top padding...</span>
|
||
set_color(dd, DOCCOLOR_LTGRAY);
|
||
pdfioContentPathRect(dd->st, left - CODE_PADDING, dd->y + SIZE_CODEBLOCK,
|
||
right - left + <span class="number">2.0</span> * CODE_PADDING, CODE_PADDING);
|
||
pdfioContentFillAndStroke(dd->st, <span class="reserved">false</span>);
|
||
|
||
<span class="comment">// Start a code text block...</span>
|
||
set_font(dd, DOCFONT_MONOSPACE, SIZE_CODEBLOCK);
|
||
pdfioContentTextBegin(dd->st);
|
||
pdfioContentTextMoveTo(dd->st, left, dd->y);
|
||
|
||
<span class="reserved">for</span> (code = mmdGetFirstChild(block); code; code = mmdGetNextSibling(code))
|
||
{
|
||
set_color(dd, DOCCOLOR_LTGRAY);
|
||
pdfioContentPathRect(dd->st, left - CODE_PADDING,
|
||
dd->y - (LINE_HEIGHT - <span class="number">1.0</span>) * SIZE_CODEBLOCK,
|
||
right - left + <span class="number">2.0</span> * CODE_PADDING, lineheight);
|
||
pdfioContentFillAndStroke(dd->st, <span class="reserved">false</span>);
|
||
|
||
set_color(dd, DOCCOLOR_RED);
|
||
pdfioContentTextShow(dd->st, UNICODE_VALUE, mmdGetText(code));
|
||
dd->y -= lineheight;
|
||
|
||
<span class="reserved">if</span> (dd->y < dd->art_box.y1)
|
||
{
|
||
<span class="comment">// End the current text block...</span>
|
||
pdfioContentTextEnd(dd->st);
|
||
|
||
<span class="comment">// Start a new page...</span>
|
||
new_page(dd);
|
||
set_font(dd, DOCFONT_MONOSPACE, SIZE_CODEBLOCK);
|
||
|
||
dd->y -= lineheight;
|
||
|
||
pdfioContentTextBegin(dd->st);
|
||
pdfioContentTextMoveTo(dd->st, left, dd->y);
|
||
}
|
||
}
|
||
|
||
<span class="comment">// End the current text block...</span>
|
||
pdfioContentTextEnd(dd->st);
|
||
dd->y += lineheight;
|
||
|
||
<span class="comment">// Draw the bottom padding...</span>
|
||
set_color(dd, DOCCOLOR_LTGRAY);
|
||
pdfioContentPathRect(dd->st, left - CODE_PADDING,
|
||
dd->y - CODE_PADDING - (LINE_HEIGHT - <span class="number">1.0</span>) * SIZE_CODEBLOCK,
|
||
right - left + <span class="number">2.0</span> * CODE_PADDING, CODE_PADDING);
|
||
pdfioContentFillAndStroke(dd->st, <span class="reserved">false</span>);
|
||
</code></pre>
|
||
<h5 id="formatting-tables">Formatting Tables</h5>
|
||
<p>Tables are the most difficult to format. We start by scanning the entire table and measuring every cell with the <code>measure_cell</code> function:</p>
|
||
<pre><code class="language-c"><span class="reserved">for</span> (num_cols = <span class="number">0</span>, num_rows = <span class="number">0</span>, rowptr = rows, current = mmdGetFirstChild(table);
|
||
current && num_rows < TABLEROW_MAX;
|
||
current = next)
|
||
{
|
||
next = mmd_walk_next(table, current);
|
||
type = mmdGetType(current);
|
||
|
||
<span class="reserved">if</span> (type == MMD_TYPE_TABLE_ROW)
|
||
{
|
||
<span class="comment">// Parse row...</span>
|
||
<span class="reserved">for</span> (col = <span class="number">0</span>, current = mmdGetFirstChild(current);
|
||
current && num_cols < TABLECOL_MAX;
|
||
current = mmdGetNextSibling(current), col ++)
|
||
{
|
||
rowptr->cells[col] = current;
|
||
|
||
measure_cell(dd, current, cols + col);
|
||
|
||
<span class="reserved">if</span> (col >= num_cols)
|
||
num_cols = col + <span class="number">1</span>;
|
||
}
|
||
|
||
rowptr ++;
|
||
num_rows ++;
|
||
}
|
||
}
|
||
</code></pre>
|
||
<p>The <code>measure_cell</code> function also updates the minimum and maximum width needed for each column. To this we add the cell padding to compute the total table width:</p>
|
||
<pre><code class="language-c"><span class="comment">// Figure out the width of each column...</span>
|
||
<span class="reserved">for</span> (col = <span class="number">0</span>, table_width = <span class="number">0.0</span>; col < num_cols; col ++)
|
||
{
|
||
cols[col].max_width += <span class="number">2.0</span> * TABLE_PADDING;
|
||
|
||
table_width += cols[col].max_width;
|
||
cols[col].width = cols[col].max_width;
|
||
}
|
||
</code></pre>
|
||
<p>If the calculated width is more than the available width, we need to adjust the width of the columns. The algorithm used here breaks the available width into N equal-width columns - any columns wider than this will be scaled proportionately. This works out as two steps - one to calculate the the base width of "narrow" columns and a second to distribute the remaining width amongst the wider columns:</p>
|
||
<pre><code class="language-c">format_width = right - left - <span class="number">2.0</span> * TABLE_PADDING * num_cols;
|
||
|
||
<span class="reserved">if</span> (table_width > format_width)
|
||
{
|
||
<span class="comment">// Content too wide, try scaling the widths...</span>
|
||
<span class="reserved">double</span> avg_width, <span class="comment">// Average column width</span>
|
||
base_width, <span class="comment">// Base width</span>
|
||
remaining_width, <span class="comment">// Remaining width</span>
|
||
scale_width; <span class="comment">// Width for scaling</span>
|
||
size_t num_remaining_cols = <span class="number">0</span>; <span class="comment">// Number of remaining columns</span>
|
||
|
||
<span class="comment">// First mark any columns that are narrower than the average width...</span>
|
||
avg_width = format_width / num_cols;
|
||
|
||
<span class="reserved">for</span> (col = <span class="number">0</span>, base_width = <span class="number">0.0</span>, remaining_width = <span class="number">0.0</span>; col < num_cols; col ++)
|
||
{
|
||
<span class="reserved">if</span> (cols[col].width > avg_width)
|
||
{
|
||
remaining_width += cols[col].width;
|
||
num_remaining_cols ++;
|
||
}
|
||
<span class="reserved">else</span>
|
||
{
|
||
base_width += cols[col].width;
|
||
}
|
||
}
|
||
|
||
<span class="comment">// Then proportionately distribute the remaining width to the other columns...</span>
|
||
format_width -= base_width;
|
||
|
||
<span class="reserved">for</span> (col = <span class="number">0</span>, table_width = <span class="number">0.0</span>; col < num_cols; col ++)
|
||
{
|
||
<span class="reserved">if</span> (cols[col].width > avg_width)
|
||
cols[col].width = cols[col].width * format_width / remaining_width;
|
||
|
||
table_width += cols[col].width;
|
||
}
|
||
}
|
||
</code></pre>
|
||
<p>Now that we have the widths of the columns, we can calculate the left and right margins of each column for formatting the cell text:</p>
|
||
<pre><code class="language-c"><span class="comment">// Calculate the margins of each column in preparation for formatting</span>
|
||
<span class="reserved">for</span> (col = <span class="number">0</span>, x = left + TABLE_PADDING; col < num_cols; col ++)
|
||
{
|
||
cols[col].left = x;
|
||
cols[col].right = x + cols[col].width;
|
||
|
||
x += cols[col].width + <span class="number">2.0</span> * TABLE_PADDING;
|
||
}
|
||
</code></pre>
|
||
<p>Then we re-measure the cells using the final column widths to determine the height of each cell and row:</p>
|
||
<pre><code class="language-c"><span class="comment">// Calculate the height of each row and cell in preparation for formatting</span>
|
||
<span class="reserved">for</span> (row = <span class="number">0</span>, rowptr = rows; row < num_rows; row ++, rowptr ++)
|
||
{
|
||
<span class="reserved">for</span> (col = <span class="number">0</span>; col < num_cols; col ++)
|
||
{
|
||
height = measure_cell(dd, rowptr->cells[col], cols + col) + <span class="number">2.0</span> * TABLE_PADDING;
|
||
<span class="reserved">if</span> (height > rowptr->height)
|
||
rowptr->height = height;
|
||
}
|
||
}
|
||
</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>
|
||
<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);
|
||
</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>
|
||
<h5 id="rendering-a-line-in-a-paragraph-heading-or-table-cell">Rendering a Line in a Paragraph, Heading, or Table Cell</h5>
|
||
<p>The <code>render_line</code> function adds content from the <code>linefrag_t</code> array to a PDF page. It starts by determining whether a new page is needed:</p>
|
||
<pre><code class="language-c"><span class="reserved">if</span> (!dd->st)
|
||
{
|
||
new_page(dd);
|
||
margin_top = <span class="number">0.0</span>;
|
||
}
|
||
|
||
dd->y -= margin_top + lineheight;
|
||
<span class="reserved">if</span> ((dd->y - need_bottom) < dd->art_box.y1)
|
||
{
|
||
new_page(dd);
|
||
|
||
dd->y -= lineheight;
|
||
}
|
||
</code></pre>
|
||
<p>We then loops through the fragments for the current line, drawing checkboxes, images, and text as needed. When a hyperlink is present, we add the link to the <code>links</code> array in the <code>docdata_t</code> structure, mapping "@" and "@@" to an internal link corresponding to the linked text:</p>
|
||
<pre><code class="language-c"><span class="reserved">if</span> (frag->url && dd->num_links < DOCLINK_MAX)
|
||
{
|
||
doclink_t *l = dd->links + dd->num_links;
|
||
<span class="comment">// Pointer to this link record</span>
|
||
|
||
<span class="reserved">if</span> (!strcmp(frag->url, <span class="string">"@"</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->text, s<>zeof(targetlink) - <span class="number">1</span>);
|
||
|
||
l->url = pdfioStringCreate(dd->pdf, targetlink);
|
||
}
|
||
<span class="reserved">else</span> <span class="reserved">if</span> (!strcmp(frag->url, <span class="string">"@@"</span>))
|
||
{
|
||
<span class="comment">// Use literal text as anchor...</span>
|
||
l->url = pdfioStringCreatef(dd->pdf, <span class="string">"#%s"</span>, frag->text);
|
||
}
|
||
<span class="reserved">else</span>
|
||
{
|
||
<span class="comment">// Use URL as-is...</span>
|
||
l->url = frag->url;
|
||
}
|
||
|
||
l->box.x1 = frag->x;
|
||
l->box.y1 = dd->y;
|
||
l->box.x2 = frag->x + frag->width;
|
||
l->box.y2 = dd->y + frag->height;
|
||
|
||
dd->num_links ++;
|
||
}
|
||
</code></pre>
|
||
<p>These are later written as annotations in the <code>add_links</code> function.</p>
|
||
<h5 id="rendering-a-table-row">Rendering a Table Row</h5>
|
||
<p>The <code>render_row</code> function takes a row of cells and the corresponding column definitions. It starts by drawing the border boxes around body cells:</p>
|
||
<pre><code class="language-c"><span class="reserved">if</span> (mmdGetType(row->cells[<span class="number">0</span>]) == MMD_TYPE_TABLE_HEADER_CELL)
|
||
{
|
||
<span class="comment">// Header row, no border...</span>
|
||
deffont = DOCFONT_BOLD;
|
||
}
|
||
<span class="reserved">else</span>
|
||
{
|
||
<span class="comment">// Regular body row, add borders...</span>
|
||
deffont = DOCFONT_REGULAR;
|
||
|
||
set_color(dd, DOCCOLOR_GRAY);
|
||
pdfioContentPathRect(dd->st, cols[<span class="number">0</span>].left - TABLE_PADDING, dd->y - row->height,
|
||
cols[num_cols - <span class="number">1</span>].right - cols[<span class="number">0</span>].left +
|
||
<span class="number">2.0</span> * TABLE_PADDING, row->height);
|
||
<span class="reserved">for</span> (col = <span class="number">1</span>; col < num_cols; col ++)
|
||
{
|
||
pdfioContentPathMoveTo(dd->st, cols[col].left - TABLE_PADDING, dd->y);
|
||
pdfioContentPathLineTo(dd->st, cols[col].left - TABLE_PADDING, dd->y - row->height);
|
||
}
|
||
pdfioContentStroke(dd->st);
|
||
}
|
||
</code></pre>
|
||
<p>Then it formats each cell using the <code>format_block</code> function described previously. The page <code>y</code> value is reset before formatting each cell:</p>
|
||
<pre><code class="language-c">row_y = dd->y;
|
||
|
||
<span class="reserved">for</span> (col = <span class="number">0</span>; col < num_cols; col ++)
|
||
{
|
||
dd->y = row_y;
|
||
|
||
format_block(dd, row->cells[col], deffont, SIZE_TABLE, cols[col].left,
|
||
cols[col].right, <span class="comment">/*leader*/</span>NULL);
|
||
}
|
||
|
||
dd->y = row_y - row->height;
|
||
</code></pre>
|
||
<h2 class="title"><a id="FUNCTIONS">Functions</a></h2>
|
||
<h3 class="function"><a id="pdfioArrayAppendArray">pdfioArrayAppendArray</a></h3>
|
||
<p class="description">Add an array value to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendArray(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <a href="#pdfio_array_t">pdfio_array_t</a> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayAppendBinary">pdfioArrayAppendBinary</a></h3>
|
||
<p class="description">Add a binary string value to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendBinary(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <span class="reserved">const</span> <span class="reserved">unsigned</span> <span class="reserved">char</span> *value, size_t valuelen);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
<tr><th>valuelen</th>
|
||
<td class="description">Length of value</td></tr>
|
||
</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"><a id="pdfioArrayAppendBoolean">pdfioArrayAppendBoolean</a></h3>
|
||
<p class="description">Add a boolean value to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendBoolean(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <span class="reserved">bool</span> value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayAppendDate">pdfioArrayAppendDate</a></h3>
|
||
<p class="description">Add a date value to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendDate(<a href="#pdfio_array_t">pdfio_array_t</a> *a, time_t value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayAppendDict">pdfioArrayAppendDict</a></h3>
|
||
<p class="description">Add a dictionary to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendDict(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <a href="#pdfio_dict_t">pdfio_dict_t</a> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayAppendName">pdfioArrayAppendName</a></h3>
|
||
<p class="description">Add a name to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendName(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayAppendNumber">pdfioArrayAppendNumber</a></h3>
|
||
<p class="description">Add a number to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendNumber(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <span class="reserved">double</span> value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayAppendObj">pdfioArrayAppendObj</a></h3>
|
||
<p class="description">Add an indirect object reference to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendObj(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <a href="#pdfio_obj_t">pdfio_obj_t</a> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayAppendString">pdfioArrayAppendString</a></h3>
|
||
<p class="description">Add a string to an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayAppendString(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioArrayCopy">pdfioArrayCopy</a></h3>
|
||
<p class="description">Copy an array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCopy(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_array_t">pdfio_array_t</a> *a);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>a</th>
|
||
<td class="description">Original array</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New array or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioArrayCreate">pdfioArrayCreate</a></h3>
|
||
<p class="description">Create an empty array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreate(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New array or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioArrayCreateColorFromICCObj">pdfioArrayCreateColorFromICCObj</a></h3>
|
||
<p class="description">Create an ICC-based color space array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateColorFromICCObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_obj_t">pdfio_obj_t</a> *icc_object);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>icc_object</th>
|
||
<td class="description">ICC profile object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Color array</p>
|
||
<h3 class="function"><a id="pdfioArrayCreateColorFromMatrix">pdfioArrayCreateColorFromMatrix</a></h3>
|
||
<p class="description">Create a calibrated color space array using a CIE XYZ transform matrix.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateColorFromMatrix(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t num_colors, <span class="reserved">double</span> gamma, <span class="reserved">const</span> <span class="reserved">double</span> matrix[3][3], <span class="reserved">const</span> <span class="reserved">double</span> white_point[3]);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>num_colors</th>
|
||
<td class="description">Number of colors (1 or 3)</td></tr>
|
||
<tr><th>gamma</th>
|
||
<td class="description">Gamma value</td></tr>
|
||
<tr><th>matrix[3][3]</th>
|
||
<td class="description">XYZ transform</td></tr>
|
||
<tr><th>white_point[3]</th>
|
||
<td class="description">White point</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Color space array</p>
|
||
<h3 class="function"><a id="pdfioArrayCreateColorFromPalette">pdfioArrayCreateColorFromPalette</a></h3>
|
||
<p class="description">Create an indexed color space array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateColorFromPalette(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t num_colors, <span class="reserved">const</span> <span class="reserved">unsigned</span> <span class="reserved">char</span> *colors);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>num_colors</th>
|
||
<td class="description">Number of colors</td></tr>
|
||
<tr><th>colors</th>
|
||
<td class="description">RGB values for colors</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Color array</p>
|
||
<h3 class="function"><a id="pdfioArrayCreateColorFromPrimaries">pdfioArrayCreateColorFromPrimaries</a></h3>
|
||
<p class="description">Create a calibrated color sapce array using CIE xy primary chromacities.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateColorFromPrimaries(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t num_colors, <span class="reserved">double</span> gamma, <span class="reserved">double</span> wx, <span class="reserved">double</span> wy, <span class="reserved">double</span> rx, <span class="reserved">double</span> ry, <span class="reserved">double</span> gx, <span class="reserved">double</span> gy, <span class="reserved">double</span> bx, <span class="reserved">double</span> by);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>num_colors</th>
|
||
<td class="description">Number of colors (1 or 3)</td></tr>
|
||
<tr><th>gamma</th>
|
||
<td class="description">Gama value</td></tr>
|
||
<tr><th>wx</th>
|
||
<td class="description">White point X chromacity</td></tr>
|
||
<tr><th>wy</th>
|
||
<td class="description">White point Y chromacity</td></tr>
|
||
<tr><th>rx</th>
|
||
<td class="description">Red X chromacity</td></tr>
|
||
<tr><th>ry</th>
|
||
<td class="description">Red Y chromacity</td></tr>
|
||
<tr><th>gx</th>
|
||
<td class="description">Green X chromacity</td></tr>
|
||
<tr><th>gy</th>
|
||
<td class="description">Green Y chromacity</td></tr>
|
||
<tr><th>bx</th>
|
||
<td class="description">Blue X chromacity</td></tr>
|
||
<tr><th>by</th>
|
||
<td class="description">Blue Y chromacity</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Color space array</p>
|
||
<h3 class="function"><a id="pdfioArrayCreateColorFromStandard">pdfioArrayCreateColorFromStandard</a></h3>
|
||
<p class="description">Create a color array for a standard color space.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateColorFromStandard(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t num_colors, <a href="#pdfio_cs_t">pdfio_cs_t</a> cs);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>num_colors</th>
|
||
<td class="description">Number of colors (1 or 3)</td></tr>
|
||
<tr><th>cs</th>
|
||
<td class="description">Color space enumeration</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Color array</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a color array for a standard <code>PDFIO_CS_</code> enumerated color space.
|
||
The "num_colors" argument must be <code>1</code> for grayscale and <code>3</code> for RGB color.</p>
|
||
<h3 class="function"><a id="pdfioArrayGetArray">pdfioArrayGetArray</a></h3>
|
||
<p class="description">Get an array value from an array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayGetArray(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetBinary">pdfioArrayGetBinary</a></h3>
|
||
<p class="description">Get a binary string value from an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">unsigned</span> <span class="reserved">char</span> *pdfioArrayGetBinary(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n, size_t *length);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
<tr><th>length</th>
|
||
<td class="description">Length of string</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetBoolean">pdfioArrayGetBoolean</a></h3>
|
||
<p class="description">Get a boolean value from an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayGetBoolean(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetDate">pdfioArrayGetDate</a></h3>
|
||
<p class="description">Get a date value from an array.</p>
|
||
<p class="code">
|
||
time_t pdfioArrayGetDate(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetDict">pdfioArrayGetDict</a></h3>
|
||
<p class="description">Get a dictionary value from an array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_dict_t">pdfio_dict_t</a> *pdfioArrayGetDict(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetName">pdfioArrayGetName</a></h3>
|
||
<p class="description">Get a name value from an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioArrayGetName(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetNumber">pdfioArrayGetNumber</a></h3>
|
||
<p class="description">Get a number from an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">double</span> pdfioArrayGetNumber(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetObj">pdfioArrayGetObj</a></h3>
|
||
<p class="description">Get an indirect object reference from an array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioArrayGetObj(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetSize">pdfioArrayGetSize</a></h3>
|
||
<p class="description">Get the length of an array.</p>
|
||
<p class="code">
|
||
size_t pdfioArrayGetSize(<a href="#pdfio_array_t">pdfio_array_t</a> *a);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Length of array</p>
|
||
<h3 class="function"><a id="pdfioArrayGetString">pdfioArrayGetString</a></h3>
|
||
<p class="description">Get a string value from an array.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioArrayGetString(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioArrayGetType">pdfioArrayGetType</a></h3>
|
||
<p class="description">Get a value type from an array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_valtype_t">pdfio_valtype_t</a> pdfioArrayGetType(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value type</p>
|
||
<h3 class="function"><a id="pdfioArrayRemove">pdfioArrayRemove</a></h3>
|
||
<p class="description">Remove an array entry.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioArrayRemove(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>a</th>
|
||
<td class="description">Array</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Index</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description"><code>true</code> on success, <code>false</code> otherwise</p>
|
||
<h3 class="function"><a id="pdfioContentClip">pdfioContentClip</a></h3>
|
||
<p class="description">Clip output to the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentClip(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">bool</span> even_odd);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>even_odd</th>
|
||
<td class="description">Even/odd fill vs. non-zero winding rule</td></tr>
|
||
</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"><a id="pdfioContentDrawImage">pdfioContentDrawImage</a></h3>
|
||
<p class="description">Draw an image object.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentDrawImage(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">char</span> *name, <span class="reserved">double</span> x, <span class="reserved">double</span> y, <span class="reserved">double</span> width, <span class="reserved">double</span> height);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Image name</td></tr>
|
||
<tr><th>x</th>
|
||
<td class="description">X offset of image</td></tr>
|
||
<tr><th>y</th>
|
||
<td class="description">Y offset of image</td></tr>
|
||
<tr><th>width</th>
|
||
<td class="description">Width of image</td></tr>
|
||
<tr><th>height</th>
|
||
<td class="description">Height of image</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">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"><a id="pdfioContentFill">pdfioContentFill</a></h3>
|
||
<p class="description">Fill the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentFill(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">bool</span> even_odd);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>even_odd</th>
|
||
<td class="description">Even/odd fill vs. non-zero winding rule</td></tr>
|
||
</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"><a id="pdfioContentFillAndStroke">pdfioContentFillAndStroke</a></h3>
|
||
<p class="description">Fill and stroke the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentFillAndStroke(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">bool</span> even_odd);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>even_odd</th>
|
||
<td class="description">Even/odd fill vs. non-zero winding</td></tr>
|
||
</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"><a id="pdfioContentMatrixConcat">pdfioContentMatrixConcat</a></h3>
|
||
<p class="description">Concatenate a matrix to the current graphics
|
||
state.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentMatrixConcat(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, pdfio_matrix_t m);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>m</th>
|
||
<td class="description">Transform matrix</td></tr>
|
||
</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"><a id="pdfioContentMatrixRotate">pdfioContentMatrixRotate</a></h3>
|
||
<p class="description">Rotate the current transform matrix.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentMatrixRotate(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> degrees);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>degrees</th>
|
||
<td class="description">Rotation angle in degrees counter-clockwise</td></tr>
|
||
</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"><a id="pdfioContentMatrixScale">pdfioContentMatrixScale</a></h3>
|
||
<p class="description">Scale the current transform matrix.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentMatrixScale(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> sx, <span class="reserved">double</span> sy);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>sx</th>
|
||
<td class="description">X scale</td></tr>
|
||
<tr><th>sy</th>
|
||
<td class="description">Y scale</td></tr>
|
||
</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"><a id="pdfioContentMatrixTranslate">pdfioContentMatrixTranslate</a></h3>
|
||
<p class="description">Translate the current transform matrix.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentMatrixTranslate(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> tx, <span class="reserved">double</span> ty);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>tx</th>
|
||
<td class="description">X offset</td></tr>
|
||
<tr><th>ty</th>
|
||
<td class="description">Y offset</td></tr>
|
||
</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"><a id="pdfioContentPathClose">pdfioContentPathClose</a></h3>
|
||
<p class="description">Close the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathClose(<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>
|
||
<h3 class="function"><a id="pdfioContentPathCurve">pdfioContentPathCurve</a></h3>
|
||
<p class="description">Add a Bezier curve with two control points.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathCurve(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> x1, <span class="reserved">double</span> y1, <span class="reserved">double</span> x2, <span class="reserved">double</span> y2, <span class="reserved">double</span> x3, <span class="reserved">double</span> y3);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>x1</th>
|
||
<td class="description">X position 1</td></tr>
|
||
<tr><th>y1</th>
|
||
<td class="description">Y position 1</td></tr>
|
||
<tr><th>x2</th>
|
||
<td class="description">X position 2</td></tr>
|
||
<tr><th>y2</th>
|
||
<td class="description">Y position 2</td></tr>
|
||
<tr><th>x3</th>
|
||
<td class="description">X position 3</td></tr>
|
||
<tr><th>y3</th>
|
||
<td class="description">Y position 3</td></tr>
|
||
</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"><a id="pdfioContentPathCurve13">pdfioContentPathCurve13</a></h3>
|
||
<p class="description">Add a Bezier curve with an initial control point.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathCurve13(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> x1, <span class="reserved">double</span> y1, <span class="reserved">double</span> x3, <span class="reserved">double</span> y3);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>x1</th>
|
||
<td class="description">X position 1</td></tr>
|
||
<tr><th>y1</th>
|
||
<td class="description">Y position 1</td></tr>
|
||
<tr><th>x3</th>
|
||
<td class="description">X position 3</td></tr>
|
||
<tr><th>y3</th>
|
||
<td class="description">Y position 3</td></tr>
|
||
</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"><a id="pdfioContentPathCurve23">pdfioContentPathCurve23</a></h3>
|
||
<p class="description">Add a Bezier curve with a trailing control point.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathCurve23(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> x2, <span class="reserved">double</span> y2, <span class="reserved">double</span> x3, <span class="reserved">double</span> y3);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>x2</th>
|
||
<td class="description">X position 2</td></tr>
|
||
<tr><th>y2</th>
|
||
<td class="description">Y position 2</td></tr>
|
||
<tr><th>x3</th>
|
||
<td class="description">X position 3</td></tr>
|
||
<tr><th>y3</th>
|
||
<td class="description">Y position 3</td></tr>
|
||
</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"><a id="pdfioContentPathEnd">pdfioContentPathEnd</a></h3>
|
||
<p class="description">Clear the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathEnd(<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>
|
||
<h3 class="function"><a id="pdfioContentPathLineTo">pdfioContentPathLineTo</a></h3>
|
||
<p class="description">Add a straight line to the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathLineTo(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> x, <span class="reserved">double</span> y);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>x</th>
|
||
<td class="description">X position</td></tr>
|
||
<tr><th>y</th>
|
||
<td class="description">Y position</td></tr>
|
||
</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"><a id="pdfioContentPathMoveTo">pdfioContentPathMoveTo</a></h3>
|
||
<p class="description">Start a new subpath.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathMoveTo(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> x, <span class="reserved">double</span> y);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>x</th>
|
||
<td class="description">X position</td></tr>
|
||
<tr><th>y</th>
|
||
<td class="description">Y position</td></tr>
|
||
</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"><a id="pdfioContentPathRect">pdfioContentPathRect</a></h3>
|
||
<p class="description">Add a rectangle to the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentPathRect(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> x, <span class="reserved">double</span> y, <span class="reserved">double</span> width, <span class="reserved">double</span> height);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>x</th>
|
||
<td class="description">X offset</td></tr>
|
||
<tr><th>y</th>
|
||
<td class="description">Y offset</td></tr>
|
||
<tr><th>width</th>
|
||
<td class="description">Width</td></tr>
|
||
<tr><th>height</th>
|
||
<td class="description">Height</td></tr>
|
||
</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"><a id="pdfioContentRestore">pdfioContentRestore</a></h3>
|
||
<p class="description">Restore a previous graphics state.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentRestore(<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>
|
||
<h3 class="function"><a id="pdfioContentSave">pdfioContentSave</a></h3>
|
||
<p class="description">Save the current graphics state.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSave(<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>
|
||
<h3 class="function"><a id="pdfioContentSetDashPattern">pdfioContentSetDashPattern</a></h3>
|
||
<p class="description">Set the stroke pattern.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetDashPattern(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> phase, <span class="reserved">double</span> on, <span class="reserved">double</span> off);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>phase</th>
|
||
<td class="description">Phase (offset within pattern)</td></tr>
|
||
<tr><th>on</th>
|
||
<td class="description">On length</td></tr>
|
||
<tr><th>off</th>
|
||
<td class="description">Off length</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 sets the stroke pattern when drawing lines. If "on" and "off"
|
||
are 0, a solid line is drawn.</p>
|
||
<h3 class="function"><a id="pdfioContentSetFillColorDeviceCMYK">pdfioContentSetFillColorDeviceCMYK</a></h3>
|
||
<p class="description">Set device CMYK fill color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetFillColorDeviceCMYK(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> c, <span class="reserved">double</span> m, <span class="reserved">double</span> y, <span class="reserved">double</span> k);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>c</th>
|
||
<td class="description">Cyan value (0.0 to 1.0)</td></tr>
|
||
<tr><th>m</th>
|
||
<td class="description">Magenta value (0.0 to 1.0)</td></tr>
|
||
<tr><th>y</th>
|
||
<td class="description">Yellow value (0.0 to 1.0)</td></tr>
|
||
<tr><th>k</th>
|
||
<td class="description">Black value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetFillColorDeviceGray">pdfioContentSetFillColorDeviceGray</a></h3>
|
||
<p class="description">Set the device gray fill color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetFillColorDeviceGray(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> g);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Gray value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetFillColorDeviceRGB">pdfioContentSetFillColorDeviceRGB</a></h3>
|
||
<p class="description">Set the device RGB fill color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetFillColorDeviceRGB(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> r, <span class="reserved">double</span> g, <span class="reserved">double</span> b);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>r</th>
|
||
<td class="description">Red value (0.0 to 1.0)</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Green value (0.0 to 1.0)</td></tr>
|
||
<tr><th>b</th>
|
||
<td class="description">Blue value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetFillColorGray">pdfioContentSetFillColorGray</a></h3>
|
||
<p class="description">Set the calibrated gray fill color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetFillColorGray(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> g);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Gray value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetFillColorRGB">pdfioContentSetFillColorRGB</a></h3>
|
||
<p class="description">Set the calibrated RGB fill color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetFillColorRGB(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> r, <span class="reserved">double</span> g, <span class="reserved">double</span> b);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>r</th>
|
||
<td class="description">Red value (0.0 to 1.0)</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Green value (0.0 to 1.0)</td></tr>
|
||
<tr><th>b</th>
|
||
<td class="description">Blue value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetFillColorSpace">pdfioContentSetFillColorSpace</a></h3>
|
||
<p class="description">Set the fill colorspace.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetFillColorSpace(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">char</span> *name);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Color space name</td></tr>
|
||
</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"><a id="pdfioContentSetFlatness">pdfioContentSetFlatness</a></h3>
|
||
<p class="description">Set the flatness tolerance.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetFlatness(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> flatness);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>flatness</th>
|
||
<td class="description">Flatness value (0.0 to 100.0)</td></tr>
|
||
</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"><a id="pdfioContentSetLineCap">pdfioContentSetLineCap</a></h3>
|
||
<p class="description">Set the line ends style.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetLineCap(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <a href="#pdfio_linecap_t">pdfio_linecap_t</a> lc);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>lc</th>
|
||
<td class="description">Line cap value</td></tr>
|
||
</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"><a id="pdfioContentSetLineJoin">pdfioContentSetLineJoin</a></h3>
|
||
<p class="description">Set the line joining style.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetLineJoin(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <a href="#pdfio_linejoin_t">pdfio_linejoin_t</a> lj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>lj</th>
|
||
<td class="description">Line join value</td></tr>
|
||
</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"><a id="pdfioContentSetLineWidth">pdfioContentSetLineWidth</a></h3>
|
||
<p class="description">Set the line width.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetLineWidth(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> width);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>width</th>
|
||
<td class="description">Line width value</td></tr>
|
||
</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"><a id="pdfioContentSetMiterLimit">pdfioContentSetMiterLimit</a></h3>
|
||
<p class="description">Set the miter limit.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetMiterLimit(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> limit);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>limit</th>
|
||
<td class="description">Miter limit value</td></tr>
|
||
</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"><a id="pdfioContentSetStrokeColorDeviceCMYK">pdfioContentSetStrokeColorDeviceCMYK</a></h3>
|
||
<p class="description">Set the device CMYK stroke color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetStrokeColorDeviceCMYK(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> c, <span class="reserved">double</span> m, <span class="reserved">double</span> y, <span class="reserved">double</span> k);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>c</th>
|
||
<td class="description">Cyan value (0.0 to 1.0)</td></tr>
|
||
<tr><th>m</th>
|
||
<td class="description">Magenta value (0.0 to 1.0)</td></tr>
|
||
<tr><th>y</th>
|
||
<td class="description">Yellow value (0.0 to 1.0)</td></tr>
|
||
<tr><th>k</th>
|
||
<td class="description">Black value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetStrokeColorDeviceGray">pdfioContentSetStrokeColorDeviceGray</a></h3>
|
||
<p class="description">Set the device gray stroke color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetStrokeColorDeviceGray(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> g);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Gray value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetStrokeColorDeviceRGB">pdfioContentSetStrokeColorDeviceRGB</a></h3>
|
||
<p class="description">Set the device RGB stroke color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetStrokeColorDeviceRGB(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> r, <span class="reserved">double</span> g, <span class="reserved">double</span> b);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>r</th>
|
||
<td class="description">Red value (0.0 to 1.0)</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Green value (0.0 to 1.0)</td></tr>
|
||
<tr><th>b</th>
|
||
<td class="description">Blue value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetStrokeColorGray">pdfioContentSetStrokeColorGray</a></h3>
|
||
<p class="description">Set the calibrated gray stroke color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetStrokeColorGray(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> g);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Gray value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetStrokeColorRGB">pdfioContentSetStrokeColorRGB</a></h3>
|
||
<p class="description">Set the calibrated RGB stroke color.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetStrokeColorRGB(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> r, <span class="reserved">double</span> g, <span class="reserved">double</span> b);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>r</th>
|
||
<td class="description">Red value (0.0 to 1.0)</td></tr>
|
||
<tr><th>g</th>
|
||
<td class="description">Green value (0.0 to 1.0)</td></tr>
|
||
<tr><th>b</th>
|
||
<td class="description">Blue value (0.0 to 1.0)</td></tr>
|
||
</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"><a id="pdfioContentSetStrokeColorSpace">pdfioContentSetStrokeColorSpace</a></h3>
|
||
<p class="description">Set the stroke color space.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetStrokeColorSpace(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">char</span> *name);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Color space name</td></tr>
|
||
</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"><a id="pdfioContentSetTextCharacterSpacing">pdfioContentSetTextCharacterSpacing</a></h3>
|
||
<p class="description">Set the spacing between characters.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextCharacterSpacing(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> spacing);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>spacing</th>
|
||
<td class="description">Character spacing</td></tr>
|
||
</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"><a id="pdfioContentSetTextFont">pdfioContentSetTextFont</a></h3>
|
||
<p class="description">Set the text font and size.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextFont(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">char</span> *name, <span class="reserved">double</span> size);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Font name</td></tr>
|
||
<tr><th>size</th>
|
||
<td class="description">Font size</td></tr>
|
||
</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"><a id="pdfioContentSetTextLeading">pdfioContentSetTextLeading</a></h3>
|
||
<p class="description">Set text leading (line height) value.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextLeading(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> leading);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>leading</th>
|
||
<td class="description">Leading (line height) value</td></tr>
|
||
</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"><a id="pdfioContentSetTextMatrix">pdfioContentSetTextMatrix</a></h3>
|
||
<p class="description">Set the text transform matrix.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextMatrix(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, pdfio_matrix_t m);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>m</th>
|
||
<td class="description">Transform matrix</td></tr>
|
||
</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"><a id="pdfioContentSetTextRenderingMode">pdfioContentSetTextRenderingMode</a></h3>
|
||
<p class="description">Set the text rendering mode.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextRenderingMode(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <a href="#pdfio_textrendering_t">pdfio_textrendering_t</a> mode);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>mode</th>
|
||
<td class="description">Text rendering mode</td></tr>
|
||
</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"><a id="pdfioContentSetTextRise">pdfioContentSetTextRise</a></h3>
|
||
<p class="description">Set the text baseline offset.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextRise(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> rise);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>rise</th>
|
||
<td class="description">Y offset</td></tr>
|
||
</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"><a id="pdfioContentSetTextWordSpacing">pdfioContentSetTextWordSpacing</a></h3>
|
||
<p class="description">Set the inter-word spacing.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextWordSpacing(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> spacing);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>spacing</th>
|
||
<td class="description">Spacing between words</td></tr>
|
||
</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"><a id="pdfioContentSetTextXScaling">pdfioContentSetTextXScaling</a></h3>
|
||
<p class="description">Set the horizontal scaling value.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentSetTextXScaling(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> percent);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>percent</th>
|
||
<td class="description">Horizontal scaling in percent</td></tr>
|
||
</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"><a id="pdfioContentStroke">pdfioContentStroke</a></h3>
|
||
<p class="description">Stroke the current path.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentStroke(<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>
|
||
<h3 class="function"><a id="pdfioContentTextBegin">pdfioContentTextBegin</a></h3>
|
||
<p class="description">Begin a text block.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextBegin(<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>
|
||
<h3 class="function"><a id="pdfioContentTextEnd">pdfioContentTextEnd</a></h3>
|
||
<p class="description">End a text block.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextEnd(<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>
|
||
<h3 class="function"><a id="pdfioContentTextMeasure">pdfioContentTextMeasure</a></h3>
|
||
<p class="description">Measure a text string and return its width.</p>
|
||
<p class="code">
|
||
<span class="reserved">double</span> pdfioContentTextMeasure(<a href="#pdfio_obj_t">pdfio_obj_t</a> *font, <span class="reserved">const</span> <span class="reserved">char</span> *s, <span class="reserved">double</span> size);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>font</th>
|
||
<td class="description">Font object created by <a href="#pdfioFileCreateFontObjFromFile"><code>pdfioFileCreateFontObjFromFile</code></a></td></tr>
|
||
<tr><th>s</th>
|
||
<td class="description">UTF-8 string</td></tr>
|
||
<tr><th>size</th>
|
||
<td class="description">Font size/height</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Width</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function measures the given text string "s" and returns its width based
|
||
on "size". The text string must always use the UTF-8 (Unicode) encoding but
|
||
any control characters (such as newlines) are ignored.</p>
|
||
<h3 class="function"><a id="pdfioContentTextMoveLine">pdfioContentTextMoveLine</a></h3>
|
||
<p class="description">Move to the next line and offset.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextMoveLine(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> tx, <span class="reserved">double</span> ty);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>tx</th>
|
||
<td class="description">X offset</td></tr>
|
||
<tr><th>ty</th>
|
||
<td class="description">Y offset</td></tr>
|
||
</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"><a id="pdfioContentTextMoveTo">pdfioContentTextMoveTo</a></h3>
|
||
<p class="description">Offset within the current line.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextMoveTo(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> tx, <span class="reserved">double</span> ty);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>tx</th>
|
||
<td class="description">X offset</td></tr>
|
||
<tr><th>ty</th>
|
||
<td class="description">Y offset</td></tr>
|
||
</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"><a id="pdfioContentTextNewLine">pdfioContentTextNewLine</a></h3>
|
||
<p class="description">Move to the next line.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextNewLine(<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>
|
||
<h3 class="function"><a id="pdfioContentTextNewLineShow">pdfioContentTextNewLineShow</a></h3>
|
||
<p class="description">Move to the next line and show text.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextNewLineShow(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> ws, <span class="reserved">double</span> cs, <span class="reserved">bool</span> unicode, <span class="reserved">const</span> <span class="reserved">char</span> *s);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>ws</th>
|
||
<td class="description">Word spacing or <code>0.0</code> for none</td></tr>
|
||
<tr><th>cs</th>
|
||
<td class="description">Character spacing or <code>0.0</code> for none</td></tr>
|
||
<tr><th>unicode</th>
|
||
<td class="description">Unicode text?</td></tr>
|
||
<tr><th>s</th>
|
||
<td class="description">String to show</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 moves to the next line and then shows some text with optional
|
||
word and character spacing in a PDF content stream. The "unicode" argument
|
||
specifies that the current font maps to full Unicode. The "s" argument
|
||
specifies a UTF-8 encoded string.</p>
|
||
<h3 class="function"><a id="pdfioContentTextNewLineShowf">pdfioContentTextNewLineShowf</a></h3>
|
||
<p class="description">Show formatted text.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextNewLineShowf(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">double</span> ws, <span class="reserved">double</span> cs, <span class="reserved">bool</span> unicode, <span class="reserved">const</span> <span class="reserved">char</span> *format, ...);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>ws</th>
|
||
<td class="description">Word spacing or <code>0.0</code> for none</td></tr>
|
||
<tr><th>cs</th>
|
||
<td class="description">Character spacing or <code>0.0</code> for none</td></tr>
|
||
<tr><th>unicode</th>
|
||
<td class="description">Unicode text?</td></tr>
|
||
<tr><th>format</th>
|
||
<td class="description"><code>printf</code>-style format string</td></tr>
|
||
<tr><th>...</th>
|
||
<td class="description">Additional arguments as needed</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 moves to the next line and shows some formatted text with
|
||
optional word and character spacing in a PDF content stream. The "unicode"
|
||
argument specifies that the current font maps to full Unicode. The "format"
|
||
argument specifies a UTF-8 encoded <code>printf</code>-style format string.</p>
|
||
<h3 class="function"><a id="pdfioContentTextShow">pdfioContentTextShow</a></h3>
|
||
<p class="description">Show text.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextShow(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">bool</span> unicode, <span class="reserved">const</span> <span class="reserved">char</span> *s);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>unicode</th>
|
||
<td class="description">Unicode text?</td></tr>
|
||
<tr><th>s</th>
|
||
<td class="description">String to show</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 shows some text in a PDF content stream. The "unicode" argument
|
||
specifies that the current font maps to full Unicode. The "s" argument
|
||
specifies a UTF-8 encoded string.</p>
|
||
<h3 class="function"><a id="pdfioContentTextShowJustified">pdfioContentTextShowJustified</a></h3>
|
||
<p class="description">Show justified text.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextShowJustified(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">bool</span> unicode, size_t num_fragments, <span class="reserved">const</span> <span class="reserved">double</span> *offsets, <span class="reserved">const</span> <span class="reserved">char</span> *<span class="reserved">const</span> *fragments);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>unicode</th>
|
||
<td class="description">Unicode text?</td></tr>
|
||
<tr><th>num_fragments</th>
|
||
<td class="description">Number of text fragments</td></tr>
|
||
<tr><th>offsets</th>
|
||
<td class="description">Text offsets before fragments</td></tr>
|
||
<tr><th>fragments</th>
|
||
<td class="description">Text fragments</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 shows some text in a PDF content stream. The "unicode" argument
|
||
specifies that the current font maps to full Unicode. The "fragments"
|
||
argument specifies an array of UTF-8 encoded strings.</p>
|
||
<h3 class="function"><a id="pdfioContentTextShowf">pdfioContentTextShowf</a></h3>
|
||
<p class="description"></p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioContentTextShowf(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">bool</span> unicode, <span class="reserved">const</span> <span class="reserved">char</span> *format, ...);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>unicode</th>
|
||
<td class="description">Unicode text?</td></tr>
|
||
<tr><th>format</th>
|
||
<td class="description"><code>printf</code>-style format string</td></tr>
|
||
<tr><th>...</th>
|
||
<td class="description">Additional arguments as needed</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Show formatted text.</p>
|
||
<p class="discussion">This function shows some formatted text in a PDF content stream. The
|
||
"unicode" argument specifies that the current font maps to full Unicode.
|
||
The "format" argument specifies a UTF-8 encoded <code>printf</code>-style format string.</p>
|
||
<h3 class="function"><a id="pdfioDictClear">pdfioDictClear</a></h3>
|
||
<p class="description">Remove a key/value pair from a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictClear(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description"><code>true</code> if cleared, <code>false</code> otherwise</p>
|
||
<h3 class="function"><a id="pdfioDictCopy">pdfioDictCopy</a></h3>
|
||
<p class="description">Copy a dictionary to a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_dict_t">pdfio_dict_t</a> *pdfioDictCopy(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_dict_t">pdfio_dict_t</a> *dict);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>dict</th>
|
||
<td class="description">Original dictionary</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New dictionary</p>
|
||
<h3 class="function"><a id="pdfioDictCreate">pdfioDictCreate</a></h3>
|
||
<p class="description">Create a dictionary to hold key/value pairs.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_dict_t">pdfio_dict_t</a> *pdfioDictCreate(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New dictionary</p>
|
||
<h3 class="function"><a id="pdfioDictGetArray">pdfioDictGetArray</a></h3>
|
||
<p class="description">Get a key array value from a dictionary.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioDictGetArray(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetBinary">pdfioDictGetBinary</a></h3>
|
||
<p class="description">Get a key binary string value from a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">unsigned</span> <span class="reserved">char</span> *pdfioDictGetBinary(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <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>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">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">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetBoolean">pdfioDictGetBoolean</a></h3>
|
||
<p class="description">Get a key boolean value from a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictGetBoolean(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetDate">pdfioDictGetDate</a></h3>
|
||
<p class="description">Get a date value from a dictionary.</p>
|
||
<p class="code">
|
||
time_t pdfioDictGetDate(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetDict">pdfioDictGetDict</a></h3>
|
||
<p class="description">Get a key dictionary value from a dictionary.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_dict_t">pdfio_dict_t</a> *pdfioDictGetDict(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetKey">pdfioDictGetKey</a></h3>
|
||
<p class="description">Get the key for the specified pair.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioDictGetKey(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Pair index (<code>0</code>-based)</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Key for specified pair</p>
|
||
<h3 class="function"><a id="pdfioDictGetName">pdfioDictGetName</a></h3>
|
||
<p class="description">Get a key name value from a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioDictGetName(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetNumPairs">pdfioDictGetNumPairs</a></h3>
|
||
<p class="description">Get the number of key/value pairs in a dictionary.</p>
|
||
<p class="code">
|
||
size_t pdfioDictGetNumPairs(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Number of pairs</p>
|
||
<h3 class="function"><a id="pdfioDictGetNumber">pdfioDictGetNumber</a></h3>
|
||
<p class="description">Get a key number value from a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">double</span> pdfioDictGetNumber(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetObj">pdfioDictGetObj</a></h3>
|
||
<p class="description">Get a key indirect object value from a dictionary.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioDictGetObj(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetRect">pdfioDictGetRect</a></h3>
|
||
<p class="description">Get a key rectangle value from a dictionary.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_rect_t">pdfio_rect_t</a> *pdfioDictGetRect(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <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>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">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</p>
|
||
<h3 class="function"><a id="pdfioDictGetString">pdfioDictGetString</a></h3>
|
||
<p class="description">Get a key string value from a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioDictGetString(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value</p>
|
||
<h3 class="function"><a id="pdfioDictGetType">pdfioDictGetType</a></h3>
|
||
<p class="description">Get a key value type from a dictionary.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_valtype_t">pdfio_valtype_t</a> pdfioDictGetType(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Value type</p>
|
||
<h3 class="function"><a id="pdfioDictIterateKeys">pdfioDictIterateKeys</a></h3>
|
||
<p class="description">Iterate the keys in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">void</span> pdfioDictIterateKeys(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <a href="#pdfio_dict_cb_t">pdfio_dict_cb_t</a> cb, <span class="reserved">void</span> *cb_data);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>cb</th>
|
||
<td class="description">Callback function</td></tr>
|
||
<tr><th>cb_data</th>
|
||
<td class="description">Callback data</td></tr>
|
||
</tbody></table>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function iterates the keys in a dictionary, calling the supplied
|
||
function "cb":
|
||
|
||
<pre>
|
||
bool
|
||
my_dict_cb(pdfio_dict_t *dict, const char *key, void *cb_data)
|
||
{
|
||
... "key" contains the dictionary key ...
|
||
... return true to continue or false to stop ...
|
||
}
|
||
</pre>
|
||
|
||
The iteration continues as long as the callback returns <code>true</code> or all keys
|
||
have been iterated.</p>
|
||
<h3 class="function"><a id="pdfioDictSetArray">pdfioDictSetArray</a></h3>
|
||
<p class="description">Set a key array in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetArray(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <a href="#pdfio_array_t">pdfio_array_t</a> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetBinary">pdfioDictSetBinary</a></h3>
|
||
<p class="description">Set a key binary string in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetBinary(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <span class="reserved">const</span> <span class="reserved">unsigned</span> <span class="reserved">char</span> *value, size_t valuelen);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
<tr><th>valuelen</th>
|
||
<td class="description">Length of value</td></tr>
|
||
</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"><a id="pdfioDictSetBoolean">pdfioDictSetBoolean</a></h3>
|
||
<p class="description">Set a key boolean in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetBoolean(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <span class="reserved">bool</span> value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetDate">pdfioDictSetDate</a></h3>
|
||
<p class="description">Set a date value in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetDate(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, time_t value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetDict">pdfioDictSetDict</a></h3>
|
||
<p class="description">Set a key dictionary in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetDict(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <a href="#pdfio_dict_t">pdfio_dict_t</a> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetName">pdfioDictSetName</a></h3>
|
||
<p class="description">Set a key name in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetName(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetNull">pdfioDictSetNull</a></h3>
|
||
<p class="description">Set a key null in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetNull(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
</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"><a id="pdfioDictSetNumber">pdfioDictSetNumber</a></h3>
|
||
<p class="description">Set a key number in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetNumber(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <span class="reserved">double</span> value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetObj">pdfioDictSetObj</a></h3>
|
||
<p class="description">Set a key indirect object reference in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetObj(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <a href="#pdfio_obj_t">pdfio_obj_t</a> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetRect">pdfioDictSetRect</a></h3>
|
||
<p class="description">Set a key rectangle in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetRect(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <a href="#pdfio_rect_t">pdfio_rect_t</a> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetString">pdfioDictSetString</a></h3>
|
||
<p class="description">Set a key literal string in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetString(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</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"><a id="pdfioDictSetStringf">pdfioDictSetStringf</a></h3>
|
||
<p class="description">Set a key formatted string in a dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioDictSetStringf(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *key, <span class="reserved">const</span> <span class="reserved">char</span> *format, ...);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Dictionary</td></tr>
|
||
<tr><th>key</th>
|
||
<td class="description">Key</td></tr>
|
||
<tr><th>format</th>
|
||
<td class="description"><code>printf</code>-style format string</td></tr>
|
||
<tr><th>...</th>
|
||
<td class="description">Additional arguments as needed</td></tr>
|
||
</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"><a id="pdfioFileClose">pdfioFileClose</a></h3>
|
||
<p class="description">Close a PDF file and free all memory used for it.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioFileClose(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description"><code>true</code> on success and <code>false</code> on failure</p>
|
||
<h3 class="function"><a id="pdfioFileCreate">pdfioFileCreate</a></h3>
|
||
<p class="description">Create a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_file_t">pdfio_file_t</a> *pdfioFileCreate(<span class="reserved">const</span> <span class="reserved">char</span> *filename, <span class="reserved">const</span> <span class="reserved">char</span> *version, <a href="#pdfio_rect_t">pdfio_rect_t</a> *media_box, <a href="#pdfio_rect_t">pdfio_rect_t</a> *crop_box, <a href="#pdfio_error_cb_t">pdfio_error_cb_t</a> error_cb, <span class="reserved">void</span> *error_cbdata);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>filename</th>
|
||
<td class="description">Filename</td></tr>
|
||
<tr><th>version</th>
|
||
<td class="description">PDF version number or <code>NULL</code> for default (2.0)</td></tr>
|
||
<tr><th>media_box</th>
|
||
<td class="description">Default MediaBox for pages</td></tr>
|
||
<tr><th>crop_box</th>
|
||
<td class="description">Default CropBox for pages</td></tr>
|
||
<tr><th>error_cb</th>
|
||
<td class="description">Error callback or <code>NULL</code> for default</td></tr>
|
||
<tr><th>error_cbdata</th>
|
||
<td class="description">Error callback data, if any</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">PDF file or <code>NULL</code> on error</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a new PDF file. The "filename" argument specifies the
|
||
name of the PDF file to create.<br>
|
||
<br>
|
||
The "version" argument specifies the PDF version number for the file or
|
||
<code>NULL</code> for the default ("2.0").<br>
|
||
<br>
|
||
The "media_box" and "crop_box" arguments specify the default MediaBox and
|
||
CropBox for pages in the PDF file - if <code>NULL</code> then a default "Universal" size
|
||
of 8.27x11in (the intersection of US Letter and ISO A4) is used.<br>
|
||
<br>
|
||
The "error_cb" and "error_cbdata" arguments specify an error handler callback
|
||
and its data pointer - if <code>NULL</code> the default error handler is used that
|
||
writes error messages to <code>stderr</code>.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateArrayObj">pdfioFileCreateArrayObj</a></h3>
|
||
<p class="description">Create a new object in a PDF file containing an array.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateArrayObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_array_t">pdfio_array_t</a> *array);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>array</th>
|
||
<td class="description">Object array</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a new object with an array value in a PDF file.
|
||
You must call <a href="#pdfioObjClose"><code>pdfioObjClose</code></a> to write the object to the file.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateFontObjFromBase">pdfioFileCreateFontObjFromBase</a></h3>
|
||
<p class="description">Create one of the base 14 PDF fonts.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateFontObjFromBase(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *name);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Font name</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Font object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates one of the base 14 PDF fonts. The "name" parameter
|
||
specifies the font nane:
|
||
|
||
</p><ul>
|
||
<li>"Courier"
|
||
</li>
|
||
<li>"Courier-Bold"
|
||
</li>
|
||
<li>"Courier-BoldItalic"
|
||
</li>
|
||
<li>"Courier-Italic"
|
||
</li>
|
||
<li>"Helvetica"
|
||
</li>
|
||
<li>"Helvetica-Bold"
|
||
</li>
|
||
<li>"Helvetica-BoldOblique"
|
||
</li>
|
||
<li>"Helvetica-Oblique"
|
||
</li>
|
||
<li>"Symbol"
|
||
</li>
|
||
<li>"Times-Bold"
|
||
</li>
|
||
<li>"Times-BoldItalic"
|
||
</li>
|
||
<li>"Times-Italic"
|
||
</li>
|
||
<li>"Times-Roman"
|
||
</li>
|
||
<li>"ZapfDingbats"</li>
|
||
</ul>
|
||
<p class="discussion">Aside from "Symbol" and "Zapf-Dingbats", Base fonts use the Windows CP1252
|
||
(ISO-8859-1 with additional characters such as the Euro symbol) subset of
|
||
Unicode.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateFontObjFromFile">pdfioFileCreateFontObjFromFile</a></h3>
|
||
<p class="description">Add a font object to a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateFontObjFromFile(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *filename, <span class="reserved">bool</span> unicode);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>filename</th>
|
||
<td class="description">Filename</td></tr>
|
||
<tr><th>unicode</th>
|
||
<td class="description">Force Unicode</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Font object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function embeds a TrueType/OpenType font into a PDF file. The
|
||
"unicode" parameter controls whether the font is encoded for two-byte
|
||
characters (potentially full Unicode, but more typically a subset)
|
||
or to only support the Windows CP1252 (ISO-8859-1 with additional
|
||
characters such as the Euro symbol) subset of Unicode.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateICCObjFromFile">pdfioFileCreateICCObjFromFile</a></h3>
|
||
<p class="description">Add an ICC profile object to a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateICCObjFromFile(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *filename, size_t num_colors);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>filename</th>
|
||
<td class="description">Filename</td></tr>
|
||
<tr><th>num_colors</th>
|
||
<td class="description">Number of color components (1, 3, or 4)</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object</p>
|
||
<h3 class="function"><a id="pdfioFileCreateImageObjFromData">pdfioFileCreateImageObjFromData</a></h3>
|
||
<p class="description">Add image object(s) to a PDF file from memory.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateImageObjFromData(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">unsigned</span> <span class="reserved">char</span> *data, size_t width, size_t height, size_t num_colors, <a href="#pdfio_array_t">pdfio_array_t</a> *color_data, <span class="reserved">bool</span> alpha, <span class="reserved">bool</span> interpolate);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>data</th>
|
||
<td class="description">Pointer to image data</td></tr>
|
||
<tr><th>width</th>
|
||
<td class="description">Width of image</td></tr>
|
||
<tr><th>height</th>
|
||
<td class="description">Height of image</td></tr>
|
||
<tr><th>num_colors</th>
|
||
<td class="description">Number of colors</td></tr>
|
||
<tr><th>color_data</th>
|
||
<td class="description">Colorspace data or <code>NULL</code> for default</td></tr>
|
||
<tr><th>alpha</th>
|
||
<td class="description"><code>true</code> if data contains an alpha channel</td></tr>
|
||
<tr><th>interpolate</th>
|
||
<td class="description">Interpolate image data?</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates image object(s) in a PDF file from a data buffer in
|
||
memory. The "data" parameter points to the image data as 8-bit color values.
|
||
The "width" and "height" parameters specify the image dimensions. The
|
||
"num_colors" parameter specifies the number of color components (<code>1</code> for
|
||
grayscale, <code>3</code> for RGB, and <code>4</code> for CMYK) and the "alpha" parameter specifies
|
||
whether each color tuple is followed by an alpha value. The "color_data"
|
||
parameter specifies an optional color space array for the image - if <code>NULL</code>,
|
||
the image is encoded in the corresponding device color space. The
|
||
"interpolate" parameter specifies whether to interpolate when scaling the
|
||
image on the page.<br>
|
||
<br>
|
||
Note: When creating an image object with alpha, a second image object is
|
||
created to hold the "soft mask" data for the primary image.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateImageObjFromFile">pdfioFileCreateImageObjFromFile</a></h3>
|
||
<p class="description">Add an image object to a PDF file from a file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateImageObjFromFile(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *filename, <span class="reserved">bool</span> interpolate);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>filename</th>
|
||
<td class="description">Filename</td></tr>
|
||
<tr><th>interpolate</th>
|
||
<td class="description">Interpolate image data?</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates an image object in a PDF file from a JPEG or PNG file.
|
||
The "filename" parameter specifies the name of the JPEG or PNG file, while
|
||
the "interpolate" parameter specifies whether to interpolate when scaling the
|
||
image on the page.<br>
|
||
<br>
|
||
</p><blockquote>
|
||
Note: Currently PNG support is limited to grayscale, RGB, or indexed files
|
||
without interlacing or alpha. Transparency (masking) based on color/index
|
||
is supported.</blockquote>
|
||
<h3 class="function"><a id="pdfioFileCreateNameObj">pdfioFileCreateNameObj</a></h3>
|
||
<p class="description">Create a new object in a PDF file containing a name.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateNameObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *name);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Name value</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a new object with a name value in a PDF file.
|
||
You must call <a href="#pdfioObjClose"><code>pdfioObjClose</code></a> to write the object to the file.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateNumberObj">pdfioFileCreateNumberObj</a></h3>
|
||
<p class="description">Create a new object in a PDF file containing a number.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateNumberObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">double</span> number);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>number</th>
|
||
<td class="description">Number value</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a new object with a number value in a PDF file.
|
||
You must call <a href="#pdfioObjClose"><code>pdfioObjClose</code></a> to write the object to the file.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateObj">pdfioFileCreateObj</a></h3>
|
||
<p class="description">Create a new object in a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_dict_t">pdfio_dict_t</a> *dict);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>dict</th>
|
||
<td class="description">Object dictionary</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New object</p>
|
||
<h3 class="function"><a id="pdfioFileCreateOutput">pdfioFileCreateOutput</a></h3>
|
||
<p class="description">Create a PDF file through an output callback.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_file_t">pdfio_file_t</a> *pdfioFileCreateOutput(<a href="#pdfio_output_cb_t">pdfio_output_cb_t</a> output_cb, <span class="reserved">void</span> *output_cbdata, <span class="reserved">const</span> <span class="reserved">char</span> *version, <a href="#pdfio_rect_t">pdfio_rect_t</a> *media_box, <a href="#pdfio_rect_t">pdfio_rect_t</a> *crop_box, <a href="#pdfio_error_cb_t">pdfio_error_cb_t</a> error_cb, <span class="reserved">void</span> *error_cbdata);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>output_cb</th>
|
||
<td class="description">Output callback function</td></tr>
|
||
<tr><th>output_cbdata</th>
|
||
<td class="description">Output callback data</td></tr>
|
||
<tr><th>version</th>
|
||
<td class="description">PDF version number or <code>NULL</code> for default (2.0)</td></tr>
|
||
<tr><th>media_box</th>
|
||
<td class="description">Default MediaBox for pages</td></tr>
|
||
<tr><th>crop_box</th>
|
||
<td class="description">Default CropBox for pages</td></tr>
|
||
<tr><th>error_cb</th>
|
||
<td class="description">Error callback or <code>NULL</code> for default</td></tr>
|
||
<tr><th>error_cbdata</th>
|
||
<td class="description">Error callback data, if any</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">PDF file or <code>NULL</code> on error</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a new PDF file that is streamed though an output
|
||
callback. The "output_cb" and "output_cbdata" arguments specify the output
|
||
callback and its data pointer which is called whenever data needs to be
|
||
written:
|
||
|
||
<pre>
|
||
ssize_t
|
||
output_cb(void *output_cbdata, const void *buffer, size_t bytes)
|
||
{
|
||
// Write buffer to output and return the number of bytes written
|
||
}
|
||
</pre>
|
||
|
||
The "version" argument specifies the PDF version number for the file or
|
||
<code>NULL</code> for the default ("2.0").<br>
|
||
<br>
|
||
The "media_box" and "crop_box" arguments specify the default MediaBox and
|
||
CropBox for pages in the PDF file - if <code>NULL</code> then a default "Universal" size
|
||
of 8.27x11in (the intersection of US Letter and ISO A4) is used.<br>
|
||
<br>
|
||
The "error_cb" and "error_cbdata" arguments specify an error handler callback
|
||
and its data pointer - if <code>NULL</code> the default error handler is used that
|
||
writes error messages to <code>stderr</code>.<br>
|
||
<br>
|
||
</p><blockquote>
|
||
<em>Note</em>: Files created using this API are slightly larger than those
|
||
created using the <a href="#pdfioFileCreate"><code>pdfioFileCreate</code></a> function since stream lengths are
|
||
stored as indirect object references.</blockquote>
|
||
<h3 class="function"><a id="pdfioFileCreatePage">pdfioFileCreatePage</a></h3>
|
||
<p class="description">Create a page in a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_stream_t">pdfio_stream_t</a> *pdfioFileCreatePage(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_dict_t">pdfio_dict_t</a> *dict);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>dict</th>
|
||
<td class="description">Page dictionary</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Contents stream</p>
|
||
<h3 class="function"><a id="pdfioFileCreateStringObj">pdfioFileCreateStringObj</a></h3>
|
||
<p class="description">Create a new object in a PDF file containing a string.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateStringObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *string);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>string</th>
|
||
<td class="description">String</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New object</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a new object with a string value in a PDF file.
|
||
You must call <a href="#pdfioObjClose"><code>pdfioObjClose</code></a> to write the object to the file.</p>
|
||
<h3 class="function"><a id="pdfioFileCreateTemporary">pdfioFileCreateTemporary</a></h3>
|
||
<p class="description"></p>
|
||
<p class="code">
|
||
<a href="#pdfio_file_t">pdfio_file_t</a> *pdfioFileCreateTemporary(<span class="reserved">char</span> *buffer, size_t bufsize, <span class="reserved">const</span> <span class="reserved">char</span> *version, <a href="#pdfio_rect_t">pdfio_rect_t</a> *media_box, <a href="#pdfio_rect_t">pdfio_rect_t</a> *crop_box, <a href="#pdfio_error_cb_t">pdfio_error_cb_t</a> error_cb, <span class="reserved">void</span> *error_cbdata);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>buffer</th>
|
||
<td class="description">Filename buffer</td></tr>
|
||
<tr><th>bufsize</th>
|
||
<td class="description">Size of filename buffer</td></tr>
|
||
<tr><th>version</th>
|
||
<td class="description">PDF version number or <code>NULL</code> for default (2.0)</td></tr>
|
||
<tr><th>media_box</th>
|
||
<td class="description">Default MediaBox for pages</td></tr>
|
||
<tr><th>crop_box</th>
|
||
<td class="description">Default CropBox for pages</td></tr>
|
||
<tr><th>error_cb</th>
|
||
<td class="description">Error callback or <code>NULL</code> for default</td></tr>
|
||
<tr><th>error_cbdata</th>
|
||
<td class="description">Error callback data, if any</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Create a temporary PDF file.</p>
|
||
<p class="discussion">This function creates a PDF file with a unique filename in the current
|
||
temporary directory. The temporary file is stored in the string "buffer" an
|
||
will have a ".pdf" extension. Otherwise, this function works the same as
|
||
the <a href="#pdfioFileCreate"><code>pdfioFileCreate</code></a> function.
|
||
|
||
</p>
|
||
<h3 class="function"><a id="pdfioFileFindObj">pdfioFileFindObj</a></h3>
|
||
<p class="description">Find an object using its object number.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileFindObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t number);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>number</th>
|
||
<td class="description">Object number (1 to N)</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object or <code>NULL</code> if not found</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This differs from <a href="#pdfioFileGetObj"><code>pdfioFileGetObj</code></a> which takes an index into the
|
||
list of objects while this function takes the object number.</p>
|
||
<h3 class="function"><a id="pdfioFileGetAuthor">pdfioFileGetAuthor</a></h3>
|
||
<p class="description">Get the author for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetAuthor(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Author or <code>NULL</code> for none</p>
|
||
<h3 class="function"><span class="info"> PDFio 1.3 </span><a id="pdfioFileGetCatalog">pdfioFileGetCatalog</a></h3>
|
||
<p class="description">Get the document catalog dictionary.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_dict_t">pdfio_dict_t</a> *pdfioFileGetCatalog(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Catalog dictionary</p>
|
||
<h3 class="function"><a id="pdfioFileGetCreationDate">pdfioFileGetCreationDate</a></h3>
|
||
<p class="description">Get the creation date for a PDF file.</p>
|
||
<p class="code">
|
||
time_t pdfioFileGetCreationDate(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Creation date or <code>0</code> for none</p>
|
||
<h3 class="function"><a id="pdfioFileGetCreator">pdfioFileGetCreator</a></h3>
|
||
<p class="description">Get the creator string for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetCreator(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Creator string or <code>NULL</code> for none</p>
|
||
<h3 class="function"><a id="pdfioFileGetID">pdfioFileGetID</a></h3>
|
||
<p class="description">Get the PDF file's ID strings.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioFileGetID(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Array with binary strings</p>
|
||
<h3 class="function"><a id="pdfioFileGetKeywords">pdfioFileGetKeywords</a></h3>
|
||
<p class="description">Get the keywords for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetKeywords(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Keywords string or <code>NULL</code> for none</p>
|
||
<h3 class="function"><a id="pdfioFileGetName">pdfioFileGetName</a></h3>
|
||
<p class="description">Get a PDF's filename.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetName(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Filename</p>
|
||
<h3 class="function"><a id="pdfioFileGetNumObjs">pdfioFileGetNumObjs</a></h3>
|
||
<p class="description">Get the number of objects in a PDF file.</p>
|
||
<p class="code">
|
||
size_t pdfioFileGetNumObjs(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Number of objects</p>
|
||
<h3 class="function"><a id="pdfioFileGetNumPages">pdfioFileGetNumPages</a></h3>
|
||
<p class="description">Get the number of pages in a PDF file.</p>
|
||
<p class="code">
|
||
size_t pdfioFileGetNumPages(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Number of pages</p>
|
||
<h3 class="function"><a id="pdfioFileGetObj">pdfioFileGetObj</a></h3>
|
||
<p class="description">Get an object from a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileGetObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Object index (starting at 0)</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object</p>
|
||
<h3 class="function"><a id="pdfioFileGetPage">pdfioFileGetPage</a></h3>
|
||
<p class="description">Get a page object from a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileGetPage(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t n);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>n</th>
|
||
<td class="description">Page index (starting at 0)</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object</p>
|
||
<h3 class="function"><a id="pdfioFileGetPermissions">pdfioFileGetPermissions</a></h3>
|
||
<p class="description">Get the access permissions of a PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_permission_t">pdfio_permission_t</a> pdfioFileGetPermissions(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_encryption_t">pdfio_encryption_t</a> *encryption);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>encryption</th>
|
||
<td class="description">Type of encryption used or <code>NULL</code> to ignore</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Permission bits</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function returns the access permissions of a PDF file and (optionally)
|
||
the type of encryption that has been used.</p>
|
||
<h3 class="function"><a id="pdfioFileGetProducer">pdfioFileGetProducer</a></h3>
|
||
<p class="description">Get the producer string for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetProducer(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Producer string or <code>NULL</code> for none</p>
|
||
<h3 class="function"><a id="pdfioFileGetSubject">pdfioFileGetSubject</a></h3>
|
||
<p class="description">Get the subject for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetSubject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Subject or <code>NULL</code> for none</p>
|
||
<h3 class="function"><a id="pdfioFileGetTitle">pdfioFileGetTitle</a></h3>
|
||
<p class="description">Get the title for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetTitle(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Title or <code>NULL</code> for none</p>
|
||
<h3 class="function"><a id="pdfioFileGetVersion">pdfioFileGetVersion</a></h3>
|
||
<p class="description">Get the PDF version number for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioFileGetVersion(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Version number or <code>NULL</code></p>
|
||
<h3 class="function"><a id="pdfioFileOpen">pdfioFileOpen</a></h3>
|
||
<p class="description">Open a PDF file for reading.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_file_t">pdfio_file_t</a> *pdfioFileOpen(<span class="reserved">const</span> <span class="reserved">char</span> *filename, <a href="#pdfio_password_cb_t">pdfio_password_cb_t</a> password_cb, <span class="reserved">void</span> *password_cbdata, <a href="#pdfio_error_cb_t">pdfio_error_cb_t</a> error_cb, <span class="reserved">void</span> *error_cbdata);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>filename</th>
|
||
<td class="description">Filename</td></tr>
|
||
<tr><th>password_cb</th>
|
||
<td class="description">Password callback or <code>NULL</code> for none</td></tr>
|
||
<tr><th>password_cbdata</th>
|
||
<td class="description">Password callback data, if any</td></tr>
|
||
<tr><th>error_cb</th>
|
||
<td class="description">Error callback or <code>NULL</code> for default</td></tr>
|
||
<tr><th>error_cbdata</th>
|
||
<td class="description">Error callback data, if any</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">PDF file</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function opens an existing PDF file. The "filename" argument specifies
|
||
the name of the PDF file to create.<br>
|
||
<br>
|
||
The "password_cb" and "password_cbdata" arguments specify a password callback
|
||
and its data pointer for PDF files that use one of the standard Adobe
|
||
"security" handlers. The callback returns a password string or <code>NULL</code> to
|
||
cancel the open. If <code>NULL</code> is specified for the callback function and the
|
||
PDF file requires a password, the open will always fail.<br>
|
||
<br>
|
||
The "error_cb" and "error_cbdata" arguments specify an error handler callback
|
||
and its data pointer - if <code>NULL</code> the default error handler is used that
|
||
writes error messages to <code>stderr</code>.</p>
|
||
<h3 class="function"><a id="pdfioFileSetAuthor">pdfioFileSetAuthor</a></h3>
|
||
<p class="description">Set the author for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">void</span> pdfioFileSetAuthor(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</tbody></table>
|
||
<h3 class="function"><a id="pdfioFileSetCreationDate">pdfioFileSetCreationDate</a></h3>
|
||
<p class="description">Set the creation date for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">void</span> pdfioFileSetCreationDate(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, time_t value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</tbody></table>
|
||
<h3 class="function"><a id="pdfioFileSetCreator">pdfioFileSetCreator</a></h3>
|
||
<p class="description">Set the creator string for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">void</span> pdfioFileSetCreator(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</tbody></table>
|
||
<h3 class="function"><a id="pdfioFileSetKeywords">pdfioFileSetKeywords</a></h3>
|
||
<p class="description">Set the keywords string for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">void</span> pdfioFileSetKeywords(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</tbody></table>
|
||
<h3 class="function"><a id="pdfioFileSetPermissions">pdfioFileSetPermissions</a></h3>
|
||
<p class="description">Set the PDF permissions, encryption mode, and passwords.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioFileSetPermissions(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_permission_t">pdfio_permission_t</a> permissions, <a href="#pdfio_encryption_t">pdfio_encryption_t</a> encryption, <span class="reserved">const</span> <span class="reserved">char</span> *owner_password, <span class="reserved">const</span> <span class="reserved">char</span> *user_password);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>permissions</th>
|
||
<td class="description">Use permissions</td></tr>
|
||
<tr><th>encryption</th>
|
||
<td class="description">Type of encryption to use</td></tr>
|
||
<tr><th>owner_password</th>
|
||
<td class="description">Owner password, if any</td></tr>
|
||
<tr><th>user_password</th>
|
||
<td class="description">User password, if any</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description"><code>true</code> on success, <code>false</code> otherwise</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function sets the PDF usage permissions, encryption mode, and
|
||
passwords.<br>
|
||
<br>
|
||
</p><blockquote>
|
||
<em>Note</em>: This function must be called before creating or copying any
|
||
objects. Due to fundamental limitations in the PDF format, PDF encryption
|
||
offers little protection from disclosure. Permissions are not enforced in
|
||
any meaningful way.</blockquote>
|
||
<h3 class="function"><a id="pdfioFileSetSubject">pdfioFileSetSubject</a></h3>
|
||
<p class="description">Set the subject for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">void</span> pdfioFileSetSubject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</tbody></table>
|
||
<h3 class="function"><a id="pdfioFileSetTitle">pdfioFileSetTitle</a></h3>
|
||
<p class="description">Set the title for a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">void</span> pdfioFileSetTitle(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *value);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>value</th>
|
||
<td class="description">Value</td></tr>
|
||
</tbody></table>
|
||
<h3 class="function"><a id="pdfioImageGetBytesPerLine">pdfioImageGetBytesPerLine</a></h3>
|
||
<p class="description">Get the number of bytes to read for each line.</p>
|
||
<p class="code">
|
||
size_t pdfioImageGetBytesPerLine(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Image object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Number of bytes per line</p>
|
||
<h3 class="function"><a id="pdfioImageGetHeight">pdfioImageGetHeight</a></h3>
|
||
<p class="description">Get the height of an image object.</p>
|
||
<p class="code">
|
||
<span class="reserved">double</span> pdfioImageGetHeight(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Image object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Height in lines</p>
|
||
<h3 class="function"><a id="pdfioImageGetWidth">pdfioImageGetWidth</a></h3>
|
||
<p class="description">Get the width of an image object.</p>
|
||
<p class="code">
|
||
<span class="reserved">double</span> pdfioImageGetWidth(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Image object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Width in columns</p>
|
||
<h3 class="function"><a id="pdfioObjClose">pdfioObjClose</a></h3>
|
||
<p class="description">Close an object, writing any data as needed to the PDF
|
||
file.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioObjClose(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</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"><a id="pdfioObjCopy">pdfioObjCopy</a></h3>
|
||
<p class="description">Copy an object to another PDF file.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioObjCopy(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_obj_t">pdfio_obj_t</a> *srcobj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>srcobj</th>
|
||
<td class="description">Object to copy</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">New object or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioObjCreateStream">pdfioObjCreateStream</a></h3>
|
||
<p class="description">Create an object (data) stream for writing.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_stream_t">pdfio_stream_t</a> *pdfioObjCreateStream(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj, <a href="#pdfio_filter_t">pdfio_filter_t</a> filter);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
<tr><th>filter</th>
|
||
<td class="description">Type of compression to apply</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Stream or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioObjGetArray">pdfioObjGetArray</a></h3>
|
||
<p class="description">Get the array associated with an object.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioObjGetArray(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Array or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioObjGetDict">pdfioObjGetDict</a></h3>
|
||
<p class="description">Get the dictionary associated with an object.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_dict_t">pdfio_dict_t</a> *pdfioObjGetDict(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Dictionary or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioObjGetGeneration">pdfioObjGetGeneration</a></h3>
|
||
<p class="description">Get the object's generation number.</p>
|
||
<p class="code">
|
||
<span class="reserved">unsigned</span> <span class="reserved">short</span> pdfioObjGetGeneration(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Generation number (0 to 65535)</p>
|
||
<h3 class="function"><a id="pdfioObjGetLength">pdfioObjGetLength</a></h3>
|
||
<p class="description">Get the length of the object's (data) stream.</p>
|
||
<p class="code">
|
||
size_t pdfioObjGetLength(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Length in bytes or <code>0</code> for none</p>
|
||
<h3 class="function"><a id="pdfioObjGetName">pdfioObjGetName</a></h3>
|
||
<p class="description">Get the name value associated with an object.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioObjGetName(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Dictionary or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioObjGetNumber">pdfioObjGetNumber</a></h3>
|
||
<p class="description">Get the object's number.</p>
|
||
<p class="code">
|
||
size_t pdfioObjGetNumber(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object number (1 to 9999999999)</p>
|
||
<h3 class="function"><a id="pdfioObjGetSubtype">pdfioObjGetSubtype</a></h3>
|
||
<p class="description">Get an object's subtype.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioObjGetSubtype(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object subtype name or <code>NULL</code> for none</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function returns an object's PDF subtype name, if any. Common subtype
|
||
names include:
|
||
|
||
</p><ul>
|
||
<li>"CIDFontType0": A CID Type0 font
|
||
</li>
|
||
<li>"CIDFontType2": A CID TrueType font
|
||
</li>
|
||
<li>"Image": An image or image mask
|
||
</li>
|
||
<li>"Form": A fillable form
|
||
</li>
|
||
<li>"OpenType": An OpenType font
|
||
</li>
|
||
<li>"Type0": A composite font
|
||
</li>
|
||
<li>"Type1": A PostScript Type1 font
|
||
</li>
|
||
<li>"Type3": A PDF Type3 font
|
||
</li>
|
||
<li>"TrueType": A TrueType font</li>
|
||
</ul>
|
||
<h3 class="function"><a id="pdfioObjGetType">pdfioObjGetType</a></h3>
|
||
<p class="description">Get an object's type.</p>
|
||
<p class="code">
|
||
<span class="reserved">const</span> <span class="reserved">char</span> *pdfioObjGetType(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Object type name or <code>NULL</code> for none</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function returns an object's PDF type name, if any. Common type names
|
||
include:
|
||
|
||
</p><ul>
|
||
<li>"CMap": A character map for composite fonts
|
||
</li>
|
||
<li>"Font": An embedded font (<a href="#pdfioObjGetSubtype"><code>pdfioObjGetSubtype</code></a> will tell you the
|
||
font format)
|
||
</li>
|
||
<li>"FontDescriptor": A font descriptor
|
||
</li>
|
||
<li>"Page": A (visible) page
|
||
</li>
|
||
<li>"Pages": A page tree node
|
||
</li>
|
||
<li>"Template": An invisible template page
|
||
</li>
|
||
<li>"XObject": An image, image mask, or form (<a href="#pdfioObjGetSubtype"><code>pdfioObjGetSubtype</code></a> will
|
||
tell you which)</li>
|
||
</ul>
|
||
<h3 class="function"><a id="pdfioObjOpenStream">pdfioObjOpenStream</a></h3>
|
||
<p class="description">Open an object's (data) stream for reading.</p>
|
||
<p class="code">
|
||
<a href="#pdfio_stream_t">pdfio_stream_t</a> *pdfioObjOpenStream(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj, <span class="reserved">bool</span> decode);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>obj</th>
|
||
<td class="description">Object</td></tr>
|
||
<tr><th>decode</th>
|
||
<td class="description">Decode/decompress data?</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Stream or <code>NULL</code> on error</p>
|
||
<h3 class="function"><a id="pdfioPageCopy">pdfioPageCopy</a></h3>
|
||
<p class="description">Copy a page to a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioPageCopy(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_obj_t">pdfio_obj_t</a> *srcpage);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>srcpage</th>
|
||
<td class="description">Source page</td></tr>
|
||
</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"><a id="pdfioPageDictAddColorSpace">pdfioPageDictAddColorSpace</a></h3>
|
||
<p class="description">Add a color space to the page dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioPageDictAddColorSpace(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *name, <a href="#pdfio_array_t">pdfio_array_t</a> *data);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Page dictionary</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Color space name</td></tr>
|
||
<tr><th>data</th>
|
||
<td class="description">Color space array</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 adds a named color space to the page dictionary.<br>
|
||
<br>
|
||
The names "DefaultCMYK", "DefaultGray", and "DefaultRGB" specify the default
|
||
device color space used for the page.<br>
|
||
<br>
|
||
The "data" array contains a calibrated, indexed, or ICC-based color space
|
||
array that was created using the
|
||
<a href="#pdfioArrayCreateCalibratedColorFromMatrix"><code>pdfioArrayCreateCalibratedColorFromMatrix</code></a>,
|
||
<a href="#pdfioArrayCreateCalibratedColorFromPrimaries"><code>pdfioArrayCreateCalibratedColorFromPrimaries</code></a>,
|
||
<a href="#pdfioArrayCreateICCBasedColor"><code>pdfioArrayCreateICCBasedColor</code></a>, or
|
||
<a href="#pdfioArrayCreateIndexedColor"><code>pdfioArrayCreateIndexedColor</code></a> functions.</p>
|
||
<h3 class="function"><a id="pdfioPageDictAddFont">pdfioPageDictAddFont</a></h3>
|
||
<p class="description">Add a font object to the page dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioPageDictAddFont(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *name, <a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Page dictionary</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Font name; must not contain spaces</td></tr>
|
||
<tr><th>obj</th>
|
||
<td class="description">Font object</td></tr>
|
||
</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"><a id="pdfioPageDictAddImage">pdfioPageDictAddImage</a></h3>
|
||
<p class="description">Add an image object to the page dictionary.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioPageDictAddImage(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, <span class="reserved">const</span> <span class="reserved">char</span> *name, <a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>dict</th>
|
||
<td class="description">Page dictionary</td></tr>
|
||
<tr><th>name</th>
|
||
<td class="description">Image name</td></tr>
|
||
<tr><th>obj</th>
|
||
<td class="description">Image object</td></tr>
|
||
</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"><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, <span class="reserved">bool</span> 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>
|
||
<p class="description">Close a (data) stream in a PDF file.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioStreamClose(<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>
|
||
<h3 class="function"><a id="pdfioStreamConsume">pdfioStreamConsume</a></h3>
|
||
<p class="description">Consume bytes from the stream.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioStreamConsume(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, size_t bytes);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>bytes</th>
|
||
<td class="description">Number of bytes to consume</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description"><code>true</code> on success, <code>false</code> on EOF</p>
|
||
<h3 class="function"><a id="pdfioStreamGetToken">pdfioStreamGetToken</a></h3>
|
||
<p class="description">Read a single PDF token from a stream.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioStreamGetToken(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">char</span> *buffer, size_t bufsize);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>buffer</th>
|
||
<td class="description">String buffer</td></tr>
|
||
<tr><th>bufsize</th>
|
||
<td class="description">Size of string buffer</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description"><code>true</code> on success, <code>false</code> on EOF</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function reads a single PDF token from a stream. Operator tokens,
|
||
boolean values, and numbers are returned as-is in the provided string buffer.
|
||
String values start with the opening parenthesis ('(') but have all escaping
|
||
resolved and the terminating parenthesis removed. Hexadecimal string values
|
||
start with the opening angle bracket ('<') and have all whitespace and the
|
||
terminating angle bracket removed.</p>
|
||
<h3 class="function"><a id="pdfioStreamPeek">pdfioStreamPeek</a></h3>
|
||
<p class="description">Peek at data in a stream.</p>
|
||
<p class="code">
|
||
ssize_t pdfioStreamPeek(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">void</span> *buffer, size_t bytes);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>buffer</th>
|
||
<td class="description">Buffer</td></tr>
|
||
<tr><th>bytes</th>
|
||
<td class="description">Size of buffer</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Bytes returned or <code>-1</code> on error</p>
|
||
<h3 class="function"><a id="pdfioStreamPrintf">pdfioStreamPrintf</a></h3>
|
||
<p class="description">Write a formatted string to a stream.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioStreamPrintf(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">char</span> *format, ...);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>format</th>
|
||
<td class="description"><code>printf</code>-style format string</td></tr>
|
||
<tr><th>...</th>
|
||
<td class="description">Additional arguments as needed</td></tr>
|
||
</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"><a id="pdfioStreamPutChar">pdfioStreamPutChar</a></h3>
|
||
<p class="description">Write a single character to a stream.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioStreamPutChar(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">int</span> ch);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>ch</th>
|
||
<td class="description">Character</td></tr>
|
||
</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"><a id="pdfioStreamPuts">pdfioStreamPuts</a></h3>
|
||
<p class="description">Write a literal string to a stream.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioStreamPuts(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">char</span> *s);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>s</th>
|
||
<td class="description">Literal string</td></tr>
|
||
</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"><a id="pdfioStreamRead">pdfioStreamRead</a></h3>
|
||
<p class="description">Read data from a stream.</p>
|
||
<p class="code">
|
||
ssize_t pdfioStreamRead(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">void</span> *buffer, size_t bytes);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>buffer</th>
|
||
<td class="description">Buffer</td></tr>
|
||
<tr><th>bytes</th>
|
||
<td class="description">Bytes to read</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Number of bytes read or <code>-1</code> on error</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function reads data from a stream. When reading decoded image data
|
||
from a stream, you <em>must</em> read whole scanlines. The
|
||
<a href="#pdfioImageGetBytesPerLine"><code>pdfioImageGetBytesPerLine</code></a> function can be used to determine the
|
||
proper read length.</p>
|
||
<h3 class="function"><a id="pdfioStreamWrite">pdfioStreamWrite</a></h3>
|
||
<p class="description">Write data to a stream.</p>
|
||
<p class="code">
|
||
<span class="reserved">bool</span> pdfioStreamWrite(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <span class="reserved">const</span> <span class="reserved">void</span> *buffer, size_t bytes);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>st</th>
|
||
<td class="description">Stream</td></tr>
|
||
<tr><th>buffer</th>
|
||
<td class="description">Data to write</td></tr>
|
||
<tr><th>bytes</th>
|
||
<td class="description">Number of bytes to write</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description"><code>true</code> on success or <code>false</code> on failure</p>
|
||
<h3 class="function"><a id="pdfioStringCreate">pdfioStringCreate</a></h3>
|
||
<p class="description">Create a durable literal string.</p>
|
||
<p class="code">
|
||
<span class="reserved">char</span> *pdfioStringCreate(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *s);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>s</th>
|
||
<td class="description">Nul-terminated string</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Durable string pointer or <code>NULL</code> on error</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a literal string associated with the PDF file
|
||
"pdf". The "s" string points to a nul-terminated C string.<br>
|
||
<br>
|
||
<code>NULL</code> is returned on error, otherwise a <code>char *</code> that is valid until
|
||
<code>pdfioFileClose</code> is called.</p>
|
||
<h3 class="function"><a id="pdfioStringCreatef">pdfioStringCreatef</a></h3>
|
||
<p class="description">Create a durable formatted string.</p>
|
||
<p class="code">
|
||
<span class="reserved">char</span> *pdfioStringCreatef(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <span class="reserved">const</span> <span class="reserved">char</span> *format, ...);</p>
|
||
<h4 class="parameters">Parameters</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>pdf</th>
|
||
<td class="description">PDF file</td></tr>
|
||
<tr><th>format</th>
|
||
<td class="description"><code>printf</code>-style format string</td></tr>
|
||
<tr><th>...</th>
|
||
<td class="description">Additional args as needed</td></tr>
|
||
</tbody></table>
|
||
<h4 class="returnvalue">Return Value</h4>
|
||
<p class="description">Durable string pointer or <code>NULL</code> on error</p>
|
||
<h4 class="discussion">Discussion</h4>
|
||
<p class="discussion">This function creates a formatted string associated with the PDF file
|
||
"pdf". The "format" string contains <code>printf</code>-style format characters.<br>
|
||
<br>
|
||
<code>NULL</code> is returned on error, otherwise a <code>char *</code> that is valid until
|
||
<code>pdfioFileClose</code> is called.</p>
|
||
<h2 class="title"><a id="TYPES">Data Types</a></h2>
|
||
<h3 class="typedef"><a id="pdfio_array_t">pdfio_array_t</a></h3>
|
||
<p class="description">Array of PDF values</p>
|
||
<p class="code">
|
||
typedef struct _pdfio_array_s pdfio_array_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_cs_t">pdfio_cs_t</a></h3>
|
||
<p class="description">Standard color spaces</p>
|
||
<p class="code">
|
||
typedef enum <a href="#pdfio_cs_e">pdfio_cs_e</a> pdfio_cs_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_dict_cb_t">pdfio_dict_cb_t</a></h3>
|
||
<p class="description">Dictionary iterator callback</p>
|
||
<p class="code">
|
||
typedef bool (*pdfio_dict_cb_t)(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *key, void *cb_data);
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_dict_t">pdfio_dict_t</a></h3>
|
||
<p class="description">Key/value dictionary</p>
|
||
<p class="code">
|
||
typedef struct _pdfio_dict_s pdfio_dict_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_encryption_t">pdfio_encryption_t</a></h3>
|
||
<p class="description">PDF encryption modes</p>
|
||
<p class="code">
|
||
typedef enum <a href="#pdfio_encryption_e">pdfio_encryption_e</a> pdfio_encryption_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_error_cb_t">pdfio_error_cb_t</a></h3>
|
||
<p class="description">Error callback</p>
|
||
<p class="code">
|
||
typedef bool (*pdfio_error_cb_t)(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *message, void *data);
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_file_t">pdfio_file_t</a></h3>
|
||
<p class="description">PDF file</p>
|
||
<p class="code">
|
||
typedef struct _pdfio_file_s pdfio_file_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_filter_t">pdfio_filter_t</a></h3>
|
||
<p class="description">Compression/decompression filters for streams</p>
|
||
<p class="code">
|
||
typedef enum <a href="#pdfio_filter_e">pdfio_filter_e</a> pdfio_filter_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_linecap_t">pdfio_linecap_t</a></h3>
|
||
<p class="description">Line capping modes</p>
|
||
<p class="code">
|
||
typedef enum <a href="#pdfio_linecap_e">pdfio_linecap_e</a> pdfio_linecap_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_linejoin_t">pdfio_linejoin_t</a></h3>
|
||
<p class="description">Line joining modes</p>
|
||
<p class="code">
|
||
typedef enum <a href="#pdfio_linejoin_e">pdfio_linejoin_e</a> pdfio_linejoin_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_matrix_t[3][2]">pdfio_matrix_t[3][2]</a></h3>
|
||
<p class="description">Transform matrix</p>
|
||
<p class="code">
|
||
typedef double pdfio_matrix_t[3][2];
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_obj_t">pdfio_obj_t</a></h3>
|
||
<p class="description">Numbered object in PDF file</p>
|
||
<p class="code">
|
||
typedef struct _pdfio_obj_s pdfio_obj_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_output_cb_t">pdfio_output_cb_t</a></h3>
|
||
<p class="description">Output callback for pdfioFileCreateOutput</p>
|
||
<p class="code">
|
||
typedef ssize_t (*pdfio_output_cb_t)(void *ctx const void *data size_t datalen);
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_password_cb_t">pdfio_password_cb_t</a></h3>
|
||
<p class="description">Password callback for pdfioFileOpen</p>
|
||
<p class="code">
|
||
typedef const char *(*pdfio_password_cb_t)(void *data const char *filename);
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_permission_t">pdfio_permission_t</a></h3>
|
||
<p class="description">PDF permission bitfield</p>
|
||
<p class="code">
|
||
typedef int pdfio_permission_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_rect_t">pdfio_rect_t</a></h3>
|
||
<p class="description">PDF rectangle</p>
|
||
<p class="code">
|
||
typedef struct <a href="#pdfio_rect_s">pdfio_rect_s</a> pdfio_rect_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_stream_t">pdfio_stream_t</a></h3>
|
||
<p class="description">Object data stream in PDF file</p>
|
||
<p class="code">
|
||
typedef struct _pdfio_stream_s pdfio_stream_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_textrendering_t">pdfio_textrendering_t</a></h3>
|
||
<p class="description">Text rendering modes</p>
|
||
<p class="code">
|
||
typedef enum <a href="#pdfio_textrendering_e">pdfio_textrendering_e</a> pdfio_textrendering_t;
|
||
</p>
|
||
<h3 class="typedef"><a id="pdfio_valtype_t">pdfio_valtype_t</a></h3>
|
||
<p class="description">PDF value types</p>
|
||
<p class="code">
|
||
typedef enum <a href="#pdfio_valtype_e">pdfio_valtype_e</a> pdfio_valtype_t;
|
||
</p>
|
||
<h2 class="title"><a id="STRUCTURES">Structures</a></h2>
|
||
<h3 class="struct"><a id="pdfio_rect_s">pdfio_rect_s</a></h3>
|
||
<p class="description">PDF rectangle</p>
|
||
<p class="code"><span class="reserved">struct</span> pdfio_rect_s {<br>
|
||
    <span class="reserved">double</span> x1;<br>
|
||
    <span class="reserved">double</span> x2;<br>
|
||
    <span class="reserved">double</span> y1;<br>
|
||
    <span class="reserved">double</span> y2;<br>
|
||
};</p>
|
||
<h4 class="members">Members</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>x1 </th>
|
||
<td class="description">Lower-left X coordinate</td></tr>
|
||
<tr><th>x2 </th>
|
||
<td class="description">Upper-right X coordinate</td></tr>
|
||
<tr><th>y1 </th>
|
||
<td class="description">Lower-left Y coordinate</td></tr>
|
||
<tr><th>y2 </th>
|
||
<td class="description">Upper-right Y coordinate</td></tr>
|
||
</tbody></table>
|
||
<h2 class="title"><a id="ENUMERATIONS">Constants</a></h2>
|
||
<h3 class="enumeration"><a id="pdfio_cs_e">pdfio_cs_e</a></h3>
|
||
<p class="description">Standard color spaces</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>PDFIO_CS_ADOBE </th><td class="description">AdobeRGB 1998</td></tr>
|
||
<tr><th>PDFIO_CS_P3_D65 </th><td class="description">Display P3</td></tr>
|
||
<tr><th>PDFIO_CS_SRGB </th><td class="description">sRGB</td></tr>
|
||
</tbody></table>
|
||
<h3 class="enumeration"><a id="pdfio_encryption_e">pdfio_encryption_e</a></h3>
|
||
<p class="description">PDF encryption modes</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>PDFIO_ENCRYPTION_AES_128 </th><td class="description">128-bit AES encryption (PDF 1.6)</td></tr>
|
||
<tr><th>PDFIO_ENCRYPTION_NONE </th><td class="description">No encryption</td></tr>
|
||
<tr><th>PDFIO_ENCRYPTION_RC4_128 </th><td class="description">128-bit RC4 encryption (PDF 1.4)</td></tr>
|
||
<tr><th>PDFIO_ENCRYPTION_RC4_40 </th><td class="description">40-bit RC4 encryption (PDF 1.3)</td></tr>
|
||
</tbody></table>
|
||
<h3 class="enumeration"><a id="pdfio_filter_e">pdfio_filter_e</a></h3>
|
||
<p class="description">Compression/decompression filters for streams</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<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_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_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>
|
||
<tr><th>PDFIO_FILTER_RUNLENGTH </th><td class="description">RunLengthDecode filter (reading only)</td></tr>
|
||
</tbody></table>
|
||
<h3 class="enumeration"><a id="pdfio_linecap_e">pdfio_linecap_e</a></h3>
|
||
<p class="description">Line capping modes</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>PDFIO_LINECAP_BUTT </th><td class="description">Butt ends</td></tr>
|
||
<tr><th>PDFIO_LINECAP_ROUND </th><td class="description">Round ends</td></tr>
|
||
<tr><th>PDFIO_LINECAP_SQUARE </th><td class="description">Square ends</td></tr>
|
||
</tbody></table>
|
||
<h3 class="enumeration"><a id="pdfio_linejoin_e">pdfio_linejoin_e</a></h3>
|
||
<p class="description">Line joining modes</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>PDFIO_LINEJOIN_BEVEL </th><td class="description">Bevel joint</td></tr>
|
||
<tr><th>PDFIO_LINEJOIN_MITER </th><td class="description">Miter joint</td></tr>
|
||
<tr><th>PDFIO_LINEJOIN_ROUND </th><td class="description">Round joint</td></tr>
|
||
</tbody></table>
|
||
<h3 class="enumeration"><a id="pdfio_permission_e">pdfio_permission_e</a></h3>
|
||
<p class="description">PDF permission bits</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>PDFIO_PERMISSION_ANNOTATE </th><td class="description">PDF allows annotation</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_ASSEMBLE </th><td class="description">PDF allows assembly (insert, delete, or rotate pages, add document outlines and thumbnails)</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_COPY </th><td class="description">PDF allows copying</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_FORMS </th><td class="description">PDF allows filling in forms</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_MODIFY </th><td class="description">PDF allows modification</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_NONE </th><td class="description">No permissions</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_PRINT </th><td class="description">PDF allows printing</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_PRINT_HIGH </th><td class="description">PDF allows high quality printing</td></tr>
|
||
<tr><th>PDFIO_PERMISSION_READING </th><td class="description">PDF allows screen reading/accessibility (deprecated in PDF 2.0)</td></tr>
|
||
<tr><th>~0 </th><td class="description">All permissions</td></tr>
|
||
</tbody></table>
|
||
<h3 class="enumeration"><a id="pdfio_textrendering_e">pdfio_textrendering_e</a></h3>
|
||
<p class="description">Text rendering modes</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>PDFIO_TEXTRENDERING_FILL </th><td class="description">Fill text</td></tr>
|
||
<tr><th>PDFIO_TEXTRENDERING_FILL_AND_STROKE </th><td class="description">Fill then stroke text</td></tr>
|
||
<tr><th>PDFIO_TEXTRENDERING_FILL_AND_STROKE_PATH </th><td class="description">Fill then stroke text and add to path</td></tr>
|
||
<tr><th>PDFIO_TEXTRENDERING_FILL_PATH </th><td class="description">Fill text and add to path</td></tr>
|
||
<tr><th>PDFIO_TEXTRENDERING_INVISIBLE </th><td class="description">Don't fill or stroke (invisible)</td></tr>
|
||
<tr><th>PDFIO_TEXTRENDERING_STROKE </th><td class="description">Stroke text</td></tr>
|
||
<tr><th>PDFIO_TEXTRENDERING_STROKE_PATH </th><td class="description">Stroke text and add to path</td></tr>
|
||
<tr><th>PDFIO_TEXTRENDERING_TEXT_PATH </th><td class="description">Add text to path (invisible)</td></tr>
|
||
</tbody></table>
|
||
<h3 class="enumeration"><a id="pdfio_valtype_e">pdfio_valtype_e</a></h3>
|
||
<p class="description">PDF value types</p>
|
||
<h4 class="constants">Constants</h4>
|
||
<table class="list"><tbody>
|
||
<tr><th>PDFIO_VALTYPE_ARRAY </th><td class="description">Array</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_BINARY </th><td class="description">Binary data</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_BOOLEAN </th><td class="description">Boolean</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_DATE </th><td class="description">Date/time</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_DICT </th><td class="description">Dictionary</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_INDIRECT </th><td class="description">Indirect object (N G obj)</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_NAME </th><td class="description">Name</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_NONE </th><td class="description">No value, not set</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_NULL </th><td class="description">Null object</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_NUMBER </th><td class="description">Number (integer or real)</td></tr>
|
||
<tr><th>PDFIO_VALTYPE_STRING </th><td class="description">String</td></tr>
|
||
</tbody></table>
|
||
</div>
|
||
</body>
|
||
</html>
|