[mod] labels
This commit is contained in:
		
							parent
							
								
									94ef07b4e1
								
							
						
					
					
						commit
						e6832289b6
					
				
					 11 changed files with 726 additions and 287 deletions
				
			
		| 
						 | 
				
			
			@ -8,4 +8,4 @@
 | 
			
		|||
                  Contents
 | 
			
		||||
                </h3><ol class="toc"><li><a href="#summary"><span class="secno">1 </span><span class="content">Summary</span></a></li><li><a href="#annotations"><span class="secno">2 </span><span class="content">Annotations</span></a><ol><li><a href="#http://www.w3.org/2012/xquery"><span class="secno">2.1 </span><span class="content">http://www.w3.org/2012/xquery</span></a></li></ol></li></ol></nav><section id="summary"><h2>Summary</h2><p>This project uses 1 annotation namespaces.</p><details><summary>Related documents</summary><table class="data"><thead><th>View</th><th>Description</th><th>Format</th></thead><tbody><tr><td><a href="index.html" title="Index of sources " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">report</a></td><td>Index of sources</td><td>xhtml</td></tr><tr><td><a href="restxq.html" title="Summary of REST interface " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">restxq</a></td><td>Summary of REST interface</td><td>xhtml</td></tr><tr><td><a href="imports.html" title="Summary of import usage " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports</a></td><td>Summary of import usage</td><td>xhtml</td></tr><tr><td><a href="mermaid.html" title="Project wide module imports as html mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports-diag</a></td><td>Project wide module imports as html mermaid class diagram</td><td>html5</td></tr><tr><td><a href="mermaid.mmd" title="Project wide module imports as a mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">imports-diag.mmd</a></td><td>Project wide module imports as a mermaid class diagram</td><td>text</td></tr><tr><td><a href="xqdoca.xml" title="xqDocA run configuration report (XML) " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoca.xml</a></td><td>xqDocA run configuration report (XML)</td><td>xml</td></tr><tr><td><a href="validation-report.xml" title="validate generated xqdoc files " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoc-validate</a></td><td>validate generated xqdoc files</td><td>xml</td></tr></tbody></table></details></section><section id="annotations"><h2>Annotations</h2><section id="http://www.w3.org/2012/xquery"><h3>2.1 http://www.w3.org/2012/xquery</h3><span style="margin-left:1em"><a href="#{http://www.w3.org/2012/xquery}private">private</a></span><div class="div4"><h4><a id="{http://www.w3.org/2012/xquery}private"></a>{http://www.w3.org/2012/xquery}private<div style="float:right"><span class="badge badge-info">7</span></div></h4><table class="data"><thead><tr><th>Attached to</th><th>Values</th></tr></thead><tbody><tr><td><span><a href="modules/F000001/index.html#{org.expkg_zone58.Pdfbox3}$property-map" title="Pdfbox3.xqm">pdfbox:$property-map</a></span></td><td>()</td></tr><tr><td><span><a href="modules/F000001/index.html#{org.expkg_zone58.Pdfbox3}read-stream#2" title="Pdfbox3.xqm">pdfbox:read-stream#2</a></span></td><td>()</td></tr><tr><td><span><a href="modules/F000001/index.html#{org.expkg_zone58.Pdfbox3}outline_#2" title="Pdfbox3.xqm">pdfbox:outline_#2</a></span></td><td>()</td></tr><tr><td><span><a href="modules/F000001/index.html#{org.expkg_zone58.Pdfbox3}bookmark-xml#1" title="Pdfbox3.xqm">pdfbox:bookmark-xml#1</a></span></td><td>()</td></tr><tr><td><span><a href="modules/F000001/index.html#{org.expkg_zone58.Pdfbox3}bookmark#2" title="Pdfbox3.xqm">pdfbox:bookmark#2</a></span></td><td>()</td></tr><tr><td><span><a href="modules/F000001/index.html#{org.expkg_zone58.Pdfbox3}gregToISO#1" title="Pdfbox3.xqm">pdfbox:gregToISO#1</a></span></td><td>()</td></tr><tr><td><span><a href="modules/F000001/index.html#{org.expkg_zone58.Pdfbox3}do-until#3" title="Pdfbox3.xqm">pdfbox:do-until#3</a></span></td><td>()</td></tr></tbody></table></div></section></section></div></div><div class="footer"><p style="text-align:right">Generated by 
 | 
			
		||||
            <a href="https://github.com/Quodatum/xqdoca" target="_blank">xqDocA <span>0.9.1</span></a>
 | 
			
		||||
               on <span title="2025-06-01T21:16:07.687+01:00">Sunday, 1st June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
               on <span title="2025-06-03T22:34:04.782+01:00">Tuesday, 3rd June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
| 
						 | 
				
			
			@ -6,4 +6,4 @@
 | 
			
		|||
                  Contents
 | 
			
		||||
                </h3><ol class="toc"><li><a href="#summary"><span class="secno">1 </span><span class="content">Summary</span></a></li><li><a href="#imports"><span class="secno">2 </span><span class="content">Imports</span></a><ol></ol></li></ol></nav><section id="summary"><h2>Summary</h2><p>Lists all modules imported.</p><details><summary>Related documents</summary><table class="data"><thead><th>View</th><th>Description</th><th>Format</th></thead><tbody><tr><td><a href="index.html" title="Index of sources " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">report</a></td><td>Index of sources</td><td>xhtml</td></tr><tr><td><a href="restxq.html" title="Summary of REST interface " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">restxq</a></td><td>Summary of REST interface</td><td>xhtml</td></tr><tr><td><a href="mermaid.html" title="Project wide module imports as html mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports-diag</a></td><td>Project wide module imports as html mermaid class diagram</td><td>html5</td></tr><tr><td><a href="mermaid.mmd" title="Project wide module imports as a mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">imports-diag.mmd</a></td><td>Project wide module imports as a mermaid class diagram</td><td>text</td></tr><tr><td><a href="annotations.html" title="Summary of XQuery annotation use " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">annotations</a></td><td>Summary of XQuery annotation use</td><td>xhtml</td></tr><tr><td><a href="xqdoca.xml" title="xqDocA run configuration report (XML) " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoca.xml</a></td><td>xqDocA run configuration report (XML)</td><td>xml</td></tr><tr><td><a href="validation-report.xml" title="validate generated xqdoc files " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoc-validate</a></td><td>validate generated xqdoc files</td><td>xml</td></tr></tbody></table></details></section><section id="imports"><h2>Imports (0)</h2></section></div></div><div class="footer"><p style="text-align:right">Generated by 
 | 
			
		||||
            <a href="https://github.com/Quodatum/xqdoca" target="_blank">xqDocA <span>0.9.1</span></a>
 | 
			
		||||
               on <span title="2025-06-01T21:16:07.687+01:00">Sunday, 1st June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
               on <span title="2025-06-03T22:34:04.782+01:00">Tuesday, 3rd June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
| 
						 | 
				
			
			@ -6,9 +6,9 @@
 | 
			
		|||
    1 XQuery source files, and uses
 | 
			
		||||
 1 annotation namespaces.
 | 
			
		||||
    </p><p>This document was built from source folder <kbd>C:/Users/mrwhe/git/expkg-zone58/pdfbox/src/</kbd> on
 | 
			
		||||
     <span title="2025-06-01T21:16:07.687+01:00">Sunday, 1st June 2025</span>.</p><details><summary>Related documents</summary><table class="data"><thead><th>View</th><th>Description</th><th>Format</th></thead><tbody><tr><td><a href="index.html" title="Index of sources " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">report</a></td><td>Index of sources</td><td>xhtml</td></tr><tr><td><a href="restxq.html" title="Summary of REST interface " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">restxq</a></td><td>Summary of REST interface</td><td>xhtml</td></tr><tr><td><a href="imports.html" title="Summary of import usage " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports</a></td><td>Summary of import usage</td><td>xhtml</td></tr><tr><td><a href="mermaid.html" title="Project wide module imports as html mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports-diag</a></td><td>Project wide module imports as html mermaid class diagram</td><td>html5</td></tr><tr><td><a href="mermaid.mmd" title="Project wide module imports as a mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">imports-diag.mmd</a></td><td>Project wide module imports as a mermaid class diagram</td><td>text</td></tr><tr><td><a href="annotations.html" title="Summary of XQuery annotation use " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">annotations</a></td><td>Summary of XQuery annotation use</td><td>xhtml</td></tr><tr><td><a href="xqdoca.xml" title="xqDocA run configuration report (XML) " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoca.xml</a></td><td>xqDocA run configuration report (XML)</td><td>xml</td></tr><tr><td><a href="validation-report.xml" title="validate generated xqdoc files " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoc-validate</a></td><td>validate generated xqdoc files</td><td>xml</td></tr></tbody></table></details></section><section id="main_mods"><h2> XQuery Main (0)</h2><div><p>None</p></div></section><section id="library_mods"><h2> XQuery Library (1)</h2><div><table class="data"><colgroup><col style="width: 35%;"/><col style="width: 10%;"/><col style="width: 25%;"/><col style="width: 10%;"/><col style="width: 10%;"/><col style="width: 10%;"/></colgroup><thead><tr><th>Uri</th><th>Prefix</th><th>Description</th><th>Use</th><th title="Annotations">A</th><th>Metrics</th></tr></thead><tbody><tr><td style="word-break:break-all;"><span><a href="modules/F000001/index.html" title="A BaseX 10.7+ interface to pdfbox 3.0 https://pdfbox.apache.org/ , requires pdfbox jars on classpath, i.e. in custom or xar tested with pdfbox-app-3.0.5.jar ">org.expkg_zone58.Pdfbox3</a></span></td><td title="prefix">pdfbox</td><td title="A BaseX 10.7+ interface to pdfbox 3.0 https://pdfbox.apache.org/ , requires pdfbox jars on classpath, i.e. in custom or xar tested with pdfbox-app-3.0.5.jar ">
 | 
			
		||||
     <span title="2025-06-03T22:34:04.782+01:00">Tuesday, 3rd June 2025</span>.</p><details><summary>Related documents</summary><table class="data"><thead><th>View</th><th>Description</th><th>Format</th></thead><tbody><tr><td><a href="index.html" title="Index of sources " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">report</a></td><td>Index of sources</td><td>xhtml</td></tr><tr><td><a href="restxq.html" title="Summary of REST interface " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">restxq</a></td><td>Summary of REST interface</td><td>xhtml</td></tr><tr><td><a href="imports.html" title="Summary of import usage " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports</a></td><td>Summary of import usage</td><td>xhtml</td></tr><tr><td><a href="mermaid.html" title="Project wide module imports as html mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports-diag</a></td><td>Project wide module imports as html mermaid class diagram</td><td>html5</td></tr><tr><td><a href="mermaid.mmd" title="Project wide module imports as a mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">imports-diag.mmd</a></td><td>Project wide module imports as a mermaid class diagram</td><td>text</td></tr><tr><td><a href="annotations.html" title="Summary of XQuery annotation use " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">annotations</a></td><td>Summary of XQuery annotation use</td><td>xhtml</td></tr><tr><td><a href="xqdoca.xml" title="xqDocA run configuration report (XML) " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoca.xml</a></td><td>xqDocA run configuration report (XML)</td><td>xml</td></tr><tr><td><a href="validation-report.xml" title="validate generated xqdoc files " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoc-validate</a></td><td>validate generated xqdoc files</td><td>xml</td></tr></tbody></table></details></section><section id="main_mods"><h2> XQuery Main (0)</h2><div><p>None</p></div></section><section id="library_mods"><h2> XQuery Library (1)</h2><div><table class="data"><colgroup><col style="width: 35%;"/><col style="width: 10%;"/><col style="width: 25%;"/><col style="width: 10%;"/><col style="width: 10%;"/><col style="width: 10%;"/></colgroup><thead><tr><th>Uri</th><th>Prefix</th><th>Description</th><th>Use</th><th title="Annotations">A</th><th>Metrics</th></tr></thead><tbody><tr><td style="word-break:break-all;"><span><a href="modules/F000001/index.html" title="A BaseX 10.7+ interface to pdfbox3 https://pdfbox.apache.org/ , requires pdfbox jars on classpath, in lib/custom or xar refer to the same concept. Also label and (page)range are used interchangably ">org.expkg_zone58.Pdfbox3</a></span></td><td title="prefix">pdfbox</td><td title="A BaseX 10.7+ interface to pdfbox3 https://pdfbox.apache.org/ , requires pdfbox jars on classpath, in lib/custom or xar refer to the same concept. Also label and (page)range are used interchangably ">
 | 
			
		||||

 | 
			
		||||
A BaseX 10.7+ interface to pdfbox 3.0 https...</td><td><div><div title="imported by">0<span>↖</span></div><div title="Library module" class="badge badge-info">Library</div><div title="imports" style="float:right">↖0</div></div></td><td title="http://www.w3.org/2012/xquery"><span class="badge badge-dark" title="Private">P</span></td><td style="text-align: right"><div>V#1</div><div>F#31</div></td></tr></tbody></table></div></section><section id="file"><h2>File view (1)</h2><ul class="tree"><li><a href="modules/F000001/index.html">Pdfbox3.xqm</a></li></ul></section><section id="annotation"><h2>Annotation namespaces (1)</h2><p> A total of 7 annotations are defined. 
 | 
			
		||||
A BaseX 10.7+ interface to pdfbox3 https://...</td><td><div><div title="imported by">0<span>↖</span></div><div title="Library module" class="badge badge-info">Library</div><div title="imports" style="float:right">↖0</div></div></td><td title="http://www.w3.org/2012/xquery"><span class="badge badge-dark" title="Private">P</span></td><td style="text-align: right"><div>V#1</div><div>F#37</div></td></tr></tbody></table></div></section><section id="file"><h2>File view (1)</h2><ul class="tree"><li><a href="modules/F000001/index.html">Pdfbox3.xqm</a></li></ul></section><section id="annotation"><h2>Annotation namespaces (1)</h2><p> A total of 7 annotations are defined. 
 | 
			
		||||
              </p><section id="http://www.w3.org/2012/xquery"><h3>http://www.w3.org/2012/xquery</h3><div><span style="margin-right:1em;"><a href="annotations.html#{http://www.w3.org/2012/xquery}private">private</a><span class="badge badge-info">7</span></span></div></section></section></div><div class="footer"><p style="text-align:right">Generated by 
 | 
			
		||||
            <a href="https://github.com/Quodatum/xqdoca" target="_blank">xqDocA <span>0.9.1</span></a>
 | 
			
		||||
               on <span title="2025-06-01T21:16:07.687+01:00">Sunday, 1st June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
               on <span title="2025-06-03T22:34:04.782+01:00">Tuesday, 3rd June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -1,13 +1,15 @@
 | 
			
		|||
<xqdoc:xqdoc xmlns:xqdoc="http://www.xqdoc.org/1.0"><xqdoc:control><xqdoc:date>2025-06-01T21:16:07.687+01:00</xqdoc:date><xqdoc:version>1.1</xqdoc:version></xqdoc:control><xqdoc:module type="library"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>pdfbox</xqdoc:name><xqdoc:comment><xqdoc:description>
 | 
			
		||||
<xqdoc:xqdoc xmlns:xqdoc="http://www.xqdoc.org/1.0"><xqdoc:control><xqdoc:date>2025-06-03T22:34:04.782+01:00</xqdoc:date><xqdoc:version>1.1</xqdoc:version></xqdoc:control><xqdoc:module type="library"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>pdfbox</xqdoc:name><xqdoc:comment><xqdoc:description>
 | 
			
		||||

 | 
			
		||||
A BaseX 10.7+ interface to pdfbox 3.0 https://pdfbox.apache.org/ ,
 | 
			
		||||
requires pdfbox jars on classpath, i.e. in custom or xar
 | 
			
		||||
tested with pdfbox-app-3.0.5.jar
 | 
			
		||||
</xqdoc:description><xqdoc:author>Andy Bunce 2025</xqdoc:author><xqdoc:see>https://pdfbox.apache.org/download.cgi</xqdoc:see><xqdoc:custom tag="javadoc">https://javadoc.io/static/org.apache.pdfbox/pdfbox/3.0.5/</xqdoc:custom></xqdoc:comment><xqdoc:body>xquery version '3.1';
 | 
			
		||||
A BaseX 10.7+ interface to pdfbox3 https://pdfbox.apache.org/ ,
 | 
			
		||||
requires pdfbox jars on classpath, in lib/custom or xar
 | 
			
		||||
refer to the same concept. Also label and (page)range are used interchangably
 | 
			
		||||
</xqdoc:description><xqdoc:author>Andy Bunce 2025</xqdoc:author><xqdoc:see>https://pdfbox.apache.org/download.cgi</xqdoc:see><xqdoc:custom tag="note">following the java source the terms outline and bookmark</xqdoc:custom><xqdoc:custom tag="note">tested with pdfbox-app-3.0.5.jar</xqdoc:custom><xqdoc:custom tag="javadoc">https://javadoc.io/static/org.apache.pdfbox/pdfbox/3.0.5/</xqdoc:custom></xqdoc:comment><xqdoc:body>xquery version '3.1';
 | 
			
		||||
(:~ 
 | 
			
		||||
A BaseX 10.7+ interface to pdfbox 3.0 https://pdfbox.apache.org/ , 
 | 
			
		||||
requires pdfbox jars on classpath, i.e. in custom or xar
 | 
			
		||||
tested with pdfbox-app-3.0.5.jar
 | 
			
		||||
A BaseX 10.7+ interface to pdfbox3 https://pdfbox.apache.org/ , 
 | 
			
		||||
requires pdfbox jars on classpath, in lib/custom or xar
 | 
			
		||||
@note following the java source the terms outline and bookmark
 | 
			
		||||
refer to the same concept. Also label and (page)range are used interchangably
 | 
			
		||||
@note tested with pdfbox-app-3.0.5.jar
 | 
			
		||||
@see https://pdfbox.apache.org/download.cgi
 | 
			
		||||
@javadoc https://javadoc.io/static/org.apache.pdfbox/pdfbox/3.0.5/
 | 
			
		||||
@author Andy Bunce 2025
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +22,8 @@ declare namespace PDFTextStripper = "java:org.apache.pdfbox.text.PDFTextStripper
 | 
			
		|||
declare namespace PDDocument ="java:org.apache.pdfbox.pdmodel.PDDocument";
 | 
			
		||||
declare namespace PDDocumentCatalog ="java:org.apache.pdfbox.pdmodel.PDDocumentCatalog";
 | 
			
		||||
declare namespace PDPageLabels ="java:org.apache.pdfbox.pdmodel.common.PDPageLabels";
 | 
			
		||||
declare namespace PDPageLabelRange="java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange";
 | 
			
		||||

 | 
			
		||||
declare namespace PageExtractor ="java:org.apache.pdfbox.multipdf.PageExtractor";
 | 
			
		||||
declare namespace PDPage ="java:org.apache.pdfbox.pdmodel.PDPage";
 | 
			
		||||
declare namespace PDPageTree ="java:org.apache.pdfbox.pdmodel.PDPageTree";
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +34,7 @@ declare namespace PDFRenderer="java:org.apache.pdfbox.rendering.PDFRenderer";&#x
 | 
			
		|||
declare namespace PDMetadata="java:org.apache.pdfbox.pdmodel.common.PDMetadata";
 | 
			
		||||
declare namespace COSInputStream="java:org.apache.pdfbox.cos.COSInputStream";
 | 
			
		||||

 | 
			
		||||

 | 
			
		||||
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
 | 
			
		||||

 | 
			
		||||

 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +46,7 @@ declare namespace File ="java:java.io.File";
 | 
			
		|||

 | 
			
		||||

 | 
			
		||||

 | 
			
		||||
(:~ with-document pattern: open pdf,apply function, close pdf
 | 
			
		||||
(:~ "With-document" pattern: open pdf,apply $fn function, close pdf
 | 
			
		||||
 creates a local pdfobject and ensures it is closed after use
 | 
			
		||||
e.g pdfbox:with-pdf("path...",pdfbox:page-text(?,5))
 | 
			
		||||
:)
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +71,8 @@ pdfbox:open($pdfsrc, map{})
 | 
			
		|||

 | 
			
		||||
(:~ open pdf from file/url/binary, opts may have password , returns pdf object 
 | 
			
		||||
@param $pdfsrc a fetchable url or filepath, or xs:base64Binary item
 | 
			
		||||
@param $opts options otionally with map {"password":} 
 | 
			
		||||
@param $opts options options include map {"password":}
 | 
			
		||||
@note fetch:binary for https will use a lot of memory here
 | 
			
		||||
:)
 | 
			
		||||
declare function pdfbox:open($pdfsrc as item(), $opts as map(*))
 | 
			
		||||
as item(){
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +101,7 @@ as xs:string{
 | 
			
		|||
};
 | 
			
		||||

 | 
			
		||||
(:~ Save pdf $pdf to filesystem at $savepath , returns $savepath :)
 | 
			
		||||
declare function pdfbox:save($pdf as item(),$savepath as xs:string)
 | 
			
		||||
declare function pdfbox:pdf-save($pdf as item(),$savepath as xs:string)
 | 
			
		||||
as xs:string{
 | 
			
		||||
   PDDocument:save($pdf, File:new($savepath)),$savepath
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -127,10 +133,11 @@ as xs:integer{
 | 
			
		|||
options.format="bmp jpg png gif" etc, options.scale= 1 is 72 dpi?? :)
 | 
			
		||||
declare function pdfbox:page-render($pdf as item(),$pageNo as xs:integer,$options as map(*))
 | 
			
		||||
as xs:base64Binary{
 | 
			
		||||
  let $options:=map:merge(($options,map{"format":"jpg","scale":1}))
 | 
			
		||||
  let $bufferedImage:=PDFRenderer:new($pdf)=>PDFRenderer:renderImage($pageNo,$options?scale)
 | 
			
		||||
  let $bytes:=Q{java:java.io.ByteArrayOutputStream}new()
 | 
			
		||||
  let $_:=Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format,  $bytes)
 | 
			
		||||
  let $options := map:merge(($options,map{"format":"jpg","scale":1}))
 | 
			
		||||
  let $bufferedImage := PDFRenderer:new($pdf)
 | 
			
		||||
                      =>PDFRenderer:renderImage($pageNo,$options?scale)
 | 
			
		||||
  let $bytes := Q{java:java.io.ByteArrayOutputStream}new()
 | 
			
		||||
  let $_ := Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format,  $bytes)
 | 
			
		||||
  return Q{java:java.io.ByteArrayOutputStream}toByteArray($bytes)
 | 
			
		||||
         =>convert:integers-to-base64()
 | 
			
		||||
 
 | 
			
		||||
| 
						 | 
				
			
			@ -142,11 +149,11 @@ as xs:base64Binary{
 | 
			
		|||
   values are sequences of functions to get property from $pdf object
 | 
			
		||||
:)
 | 
			
		||||
declare %private variable $pdfbox:property-map:=map{
 | 
			
		||||
  "pageCount": pdfbox:number-of-pages#1,
 | 
			
		||||
  "#pages": pdfbox:number-of-pages#1,
 | 
			
		||||

 | 
			
		||||
  "hasOutline": pdfbox:hasOutline#1,
 | 
			
		||||
  "#bookmarks": pdfbox:number-of-bookmarks#1,
 | 
			
		||||

 | 
			
		||||
  "hasLabels": pdfbox:hasLabels#1,
 | 
			
		||||
  "#labels": pdfbox:number-of-labels#1,
 | 
			
		||||

 | 
			
		||||
  "specification":pdfbox:specification#1,
 | 
			
		||||

 | 
			
		||||
| 
						 | 
				
			
			@ -174,7 +181,8 @@ declare %private variable $pdfbox:property-map:=map{
 | 
			
		|||

 | 
			
		||||
  "modificationDate":  (PDDocument:getDocumentInformation#1,
 | 
			
		||||
                        PDDocumentInformation:getModificationDate#1,
 | 
			
		||||
                        pdfbox:gregToISO#1)
 | 
			
		||||
                        pdfbox:gregToISO#1),
 | 
			
		||||
   "labels":      pdfbox:labels-as-strings#1                     
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ known property names sorted :)
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +198,7 @@ as item()*{
 | 
			
		|||
  return if(exists($fns))
 | 
			
		||||
         then fold-left($fns, 
 | 
			
		||||
                        $pdf, 
 | 
			
		||||
                        function($result,$this as function(*)){$this($result)})
 | 
			
		||||
                        function($result,$this as function(*)){$result!$this(.)})
 | 
			
		||||
         else error(xs:QName('pdfbox:property'),concat("Property '",$property,"' not defined."))
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +206,7 @@ as item()*{
 | 
			
		|||
:)
 | 
			
		||||
declare function pdfbox:report($pdfpaths as xs:string*)
 | 
			
		||||
as map(*){
 | 
			
		||||
 pdfbox:report($pdfpaths,map:keys($pdfbox:property-map))
 | 
			
		||||
 pdfbox:report($pdfpaths,pdfbox:property-names())
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ summary CSV style info for named properties for $pdfpaths 
 | 
			
		||||
| 
						 | 
				
			
			@ -229,20 +237,18 @@ as map(*){
 | 
			
		|||
  }
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ true if $pdf has an outline :)
 | 
			
		||||
declare function pdfbox:hasOutline($pdf as item())
 | 
			
		||||
as xs:boolean{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getDocumentOutline()
 | 
			
		||||
  =>exists()
 | 
			
		||||
(:~ convenience function to save report() data to file :)
 | 
			
		||||
declare function pdfbox:report-save($data as map(*),$dest as xs:string)
 | 
			
		||||
as empty-sequence(){
 | 
			
		||||
  let $opts := map {  "format":"xquery", "header":"yes", "separator" : "," }
 | 
			
		||||
  return file:write-text($dest,csv:serialize($data,$opts))
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ true if $pdf has Labels :)
 | 
			
		||||
declare function pdfbox:hasLabels($pdf as item())
 | 
			
		||||
as xs:boolean{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  =>exists()
 | 
			
		||||
(:~ number of outline items :)
 | 
			
		||||
declare function pdfbox:number-of-bookmarks($pdf as item())
 | 
			
		||||
as xs:integer{
 | 
			
		||||
  let $xml:=pdfbox:outline-xml($pdf)
 | 
			
		||||
  return count($xml//bookmark)
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ XMP metadata as "RDF" document
 | 
			
		||||
| 
						 | 
				
			
			@ -327,7 +333,7 @@ as element(outline)?{
 | 
			
		|||
         else ()
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ recursive ouutline map to XML :)
 | 
			
		||||
(:~ Convert outline map to XML :)
 | 
			
		||||
declare %private function pdfbox:bookmark-xml($outline as map(*)*)
 | 
			
		||||
as element(bookmark)*
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -337,7 +343,7 @@ as element(bookmark)*
 | 
			
		|||
  </bookmark>
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ return bookmark info for $bookmark
 | 
			
		||||
(:~ Return bookmark info for $bookmark
 | 
			
		||||
@return map{index:..,title:..,hasChildren:..}
 | 
			
		||||
:)
 | 
			
		||||
declare %private function pdfbox:bookmark($bookmark as item(),$pdf as item())
 | 
			
		||||
| 
						 | 
				
			
			@ -376,21 +382,92 @@ as xs:base64Binary
 | 
			
		|||
    return (pdfbox:binary($a),pdfbox:close($a)) 
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ The number of labels defined in PDF  :)
 | 
			
		||||
declare function pdfbox:number-of-labels($pdf as item())
 | 
			
		||||
as xs:integer
 | 
			
		||||
{
 | 
			
		||||
  let $labels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
               =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return if(exists($labels)) 
 | 
			
		||||
         then PDPageLabels:getPageRangeCount($labels)
 | 
			
		||||
         else 0
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~   pageLabel for every page or empty if none
 | 
			
		||||
(:~   pageLabel for every page from derived from page-ranges
 | 
			
		||||
The returned sequence will contain at MOST as much entries as the document has pages.
 | 
			
		||||
@see https://www.w3.org/TR/WCAG20-TECHS/PDF17.html#PDF17-examples
 | 
			
		||||
@see https://codereview.stackexchange.com/questions/286078/java-code-showing-page-labels-from-pdf-files
 | 
			
		||||
:)
 | 
			
		||||
declare function pdfbox:labels($pdf as item())
 | 
			
		||||
declare function pdfbox:labels-by-page($pdf as item())
 | 
			
		||||
as xs:string*
 | 
			
		||||
{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  =>PDPageLabels:getLabelsByPageIndices()
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ sequence of label ranges defined in PDF as formatted strings :)
 | 
			
		||||
declare function pdfbox:labels-as-strings($pdf as item())
 | 
			
		||||
as xs:string{
 | 
			
		||||
  let $pagelabels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
                   =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return if(exists($pagelabels))
 | 
			
		||||
         then PDPageLabels:getLabelsByPageIndices($pagelabels)
 | 
			
		||||
         else ()
 | 
			
		||||
  return $pagelabels
 | 
			
		||||
         !(0 to pdfbox:number-of-pages($pdf)-1)
 | 
			
		||||
         !pdfbox:label-as-string($pagelabels,.)=>string-join(",")
 | 
			
		||||
            
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ get pagelabels exist :)
 | 
			
		||||
declare function pdfbox:page-labels($pdf)
 | 
			
		||||
{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ label for $page formated as string :)
 | 
			
		||||
declare function pdfbox:label-as-string($pagelabels,$page as  xs:integer)
 | 
			
		||||
as xs:string?{
 | 
			
		||||
  let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page)
 | 
			
		||||
  return  if(empty($label))
 | 
			
		||||
          then ()
 | 
			
		||||
          else
 | 
			
		||||
            let $start:=  PDPageLabelRange:getStart($label)
 | 
			
		||||
            let $style := PDPageLabelRange:getStyle($label)
 | 
			
		||||
            let $prefix:= PDPageLabelRange:getPrefix($label) 
 | 
			
		||||
            return string-join(($page, 
 | 
			
		||||
                                if(empty($style)) then "-" else $style,
 | 
			
		||||
                                if(($start eq 1)) then "" else $start,
 | 
			
		||||
                                if(exists($prefix)) then '*' || $prefix  (:TODO double " :)
 | 
			
		||||
                    ))
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ sequence of maps for each label in :)
 | 
			
		||||
declare function pdfbox:labels-as-map($pdf as item())
 | 
			
		||||
as map(*)*{
 | 
			
		||||
  let $pagelabels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
                   =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return  $pagelabels
 | 
			
		||||
          !(0 to pdfbox:number-of-pages($pdf)-1)
 | 
			
		||||
          !pdfbox:label-as-map($pagelabels,.)
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ express label/page-range for $page as map :)
 | 
			
		||||
declare function pdfbox:label-as-map($pagelabels,$page as  xs:integer)
 | 
			
		||||
as map(*)
 | 
			
		||||
{
 | 
			
		||||
  let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page)
 | 
			
		||||
  return if(empty($label))
 | 
			
		||||
  then ()
 | 
			
		||||
  else map{
 | 
			
		||||
      "index": $page,
 | 
			
		||||
      "prefix": PDPageLabelRange:getPrefix($label),
 | 
			
		||||
      "start":  PDPageLabelRange:getStart($label),
 | 
			
		||||
      "style":  PDPageLabelRange:getStyle($label)
 | 
			
		||||
      }
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||

 | 
			
		||||

 | 
			
		||||
(:~ return text on $pageNo :)
 | 
			
		||||
declare function pdfbox:page-text($pdf as item(), $pageNo as xs:integer)
 | 
			
		||||
as xs:string{
 | 
			
		||||
| 
						 | 
				
			
			@ -402,7 +479,7 @@ as xs:string{
 | 
			
		|||
  return (# db:checkstrings #) {PDFTextStripper:getText($tStripper,$pdf)}
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ return size of $pageNo (zero based)
 | 
			
		||||
(:~ Return size of $pageNo (zero based)
 | 
			
		||||
@result e.g. [0.0,0.0,168.0,239.52]
 | 
			
		||||
 :)
 | 
			
		||||
declare function pdfbox:page-media-box($pdf as item(), $pageNo as xs:integer)
 | 
			
		||||
| 
						 | 
				
			
			@ -412,13 +489,13 @@ as xs:string{
 | 
			
		|||
  =>PDRectangle:toString()
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~  version of Apache Pdfbox in use  e.g. "3.0.4" :)
 | 
			
		||||
(:~  Version of Apache Pdfbox in use  e.g. "3.0.4" :)
 | 
			
		||||
declare function pdfbox:version()
 | 
			
		||||
as xs:string{
 | 
			
		||||
  Q{java:org.apache.pdfbox.util.Version}getVersion()
 | 
			
		||||
};
 | 
			
		||||

 | 
			
		||||
(:~ convert date :)
 | 
			
		||||
(:~ Convert date :)
 | 
			
		||||
declare %private
 | 
			
		||||
function pdfbox:gregToISO($item as item()?)
 | 
			
		||||
as xs:string?{
 | 
			
		||||
| 
						 | 
				
			
			@ -445,16 +522,16 @@ declare %private function pdfbox:do-until(
 | 
			
		|||
                      else error(xs:QName('pdfbox:do-until'),"No implementation do-until found")
 | 
			
		||||

 | 
			
		||||
};
 | 
			
		||||
</xqdoc:body></xqdoc:module><xqdoc:namespaces><xqdoc:namespace prefix="pdfbox" uri="org.expkg_zone58.Pdfbox3"/><xqdoc:namespace prefix="Loader" uri="java:org.apache.pdfbox.Loader"/><xqdoc:namespace prefix="PDFTextStripper" uri="java:org.apache.pdfbox.text.PDFTextStripper"/><xqdoc:namespace prefix="PDDocument" uri="java:org.apache.pdfbox.pdmodel.PDDocument"/><xqdoc:namespace prefix="PDDocumentCatalog" uri="java:org.apache.pdfbox.pdmodel.PDDocumentCatalog"/><xqdoc:namespace prefix="PDPageLabels" uri="java:org.apache.pdfbox.pdmodel.common.PDPageLabels"/><xqdoc:namespace prefix="PageExtractor" uri="java:org.apache.pdfbox.multipdf.PageExtractor"/><xqdoc:namespace prefix="PDPage" uri="java:org.apache.pdfbox.pdmodel.PDPage"/><xqdoc:namespace prefix="PDPageTree" uri="java:org.apache.pdfbox.pdmodel.PDPageTree"/><xqdoc:namespace prefix="PDDocumentOutline" uri="java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline"/><xqdoc:namespace prefix="PDDocumentInformation" uri="java:org.apache.pdfbox.pdmodel.PDDocumentInformation"/><xqdoc:namespace prefix="PDOutlineItem" uri="java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem"/><xqdoc:namespace prefix="PDFRenderer" uri="java:org.apache.pdfbox.rendering.PDFRenderer"/><xqdoc:namespace prefix="PDMetadata" uri="java:org.apache.pdfbox.pdmodel.common.PDMetadata"/><xqdoc:namespace prefix="COSInputStream" uri="java:org.apache.pdfbox.cos.COSInputStream"/><xqdoc:namespace prefix="rdf" uri="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/><xqdoc:namespace prefix="RandomAccessReadBuffer" uri="java:org.apache.pdfbox.io.RandomAccessReadBuffer"/><xqdoc:namespace prefix="RandomAccessReadBufferedFile" uri="java:org.apache.pdfbox.io.RandomAccessReadBufferedFile"/><xqdoc:namespace prefix="PDRectangle" uri="org.apache.pdfbox.pdmodel.common.PDRectangle"/><xqdoc:namespace prefix="File" uri="java:java.io.File"/><xqdoc:namespace prefix="xs" uri="http://www.w3.org/2001/XMLSchema"/><xqdoc:namespace prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/><xqdoc:namespace prefix="err" uri="http://www.w3.org/2005/xqt-errors"/><xqdoc:namespace prefix="fetch" uri="http://basex.org/modules/fetch"/><xqdoc:namespace prefix="convert" uri="http://basex.org/modules/convert"/><xqdoc:namespace prefix="db" uri="http://basex.org/modules/db"/><xqdoc:namespace prefix="map" uri="http://www.w3.org/2005/xpath-functions/map"/><xqdoc:namespace prefix="array" uri="http://www.w3.org/2005/xpath-functions/array"/></xqdoc:namespaces><xqdoc:variables><xqdoc:variable><xqdoc:name>pdfbox:property-map</xqdoc:name><xqdoc:comment><xqdoc:description>
 | 
			
		||||
</xqdoc:body></xqdoc:module><xqdoc:namespaces><xqdoc:namespace prefix="pdfbox" uri="org.expkg_zone58.Pdfbox3"/><xqdoc:namespace prefix="Loader" uri="java:org.apache.pdfbox.Loader"/><xqdoc:namespace prefix="PDFTextStripper" uri="java:org.apache.pdfbox.text.PDFTextStripper"/><xqdoc:namespace prefix="PDDocument" uri="java:org.apache.pdfbox.pdmodel.PDDocument"/><xqdoc:namespace prefix="PDDocumentCatalog" uri="java:org.apache.pdfbox.pdmodel.PDDocumentCatalog"/><xqdoc:namespace prefix="PDPageLabels" uri="java:org.apache.pdfbox.pdmodel.common.PDPageLabels"/><xqdoc:namespace prefix="PDPageLabelRange" uri="java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange"/><xqdoc:namespace prefix="PageExtractor" uri="java:org.apache.pdfbox.multipdf.PageExtractor"/><xqdoc:namespace prefix="PDPage" uri="java:org.apache.pdfbox.pdmodel.PDPage"/><xqdoc:namespace prefix="PDPageTree" uri="java:org.apache.pdfbox.pdmodel.PDPageTree"/><xqdoc:namespace prefix="PDDocumentOutline" uri="java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline"/><xqdoc:namespace prefix="PDDocumentInformation" uri="java:org.apache.pdfbox.pdmodel.PDDocumentInformation"/><xqdoc:namespace prefix="PDOutlineItem" uri="java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem"/><xqdoc:namespace prefix="PDFRenderer" uri="java:org.apache.pdfbox.rendering.PDFRenderer"/><xqdoc:namespace prefix="PDMetadata" uri="java:org.apache.pdfbox.pdmodel.common.PDMetadata"/><xqdoc:namespace prefix="COSInputStream" uri="java:org.apache.pdfbox.cos.COSInputStream"/><xqdoc:namespace prefix="rdf" uri="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/><xqdoc:namespace prefix="RandomAccessReadBuffer" uri="java:org.apache.pdfbox.io.RandomAccessReadBuffer"/><xqdoc:namespace prefix="RandomAccessReadBufferedFile" uri="java:org.apache.pdfbox.io.RandomAccessReadBufferedFile"/><xqdoc:namespace prefix="PDRectangle" uri="org.apache.pdfbox.pdmodel.common.PDRectangle"/><xqdoc:namespace prefix="File" uri="java:java.io.File"/><xqdoc:namespace prefix="xs" uri="http://www.w3.org/2001/XMLSchema"/><xqdoc:namespace prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/><xqdoc:namespace prefix="err" uri="http://www.w3.org/2005/xqt-errors"/><xqdoc:namespace prefix="fetch" uri="http://basex.org/modules/fetch"/><xqdoc:namespace prefix="convert" uri="http://basex.org/modules/convert"/><xqdoc:namespace prefix="db" uri="http://basex.org/modules/db"/><xqdoc:namespace prefix="map" uri="http://www.w3.org/2005/xpath-functions/map"/><xqdoc:namespace prefix="array" uri="http://www.w3.org/2005/xpath-functions/array"/><xqdoc:namespace prefix="file" uri="http://expath.org/ns/file"/><xqdoc:namespace prefix="csv" uri="http://basex.org/modules/csv"/></xqdoc:namespaces><xqdoc:variables><xqdoc:variable><xqdoc:name>pdfbox:property-map</xqdoc:name><xqdoc:comment><xqdoc:description>
 | 
			
		||||
property access map
 | 
			
		||||
keys are property names,
 | 
			
		||||
values are sequences of functions to get property from $pdf object
 | 
			
		||||
</xqdoc:description></xqdoc:comment><xqdoc:annotations><xqdoc:annotation name="private"/></xqdoc:annotations><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>number-of-pages</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>hasOutline</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>hasLabels</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>specification</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getTitle</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getAuthor</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getCreator</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getProducer</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getSubject</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getKeywords</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getCreationDate</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>gregToISO</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getModificationDate</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>gregToISO</xqdoc:name></xqdoc:invoked><xqdoc:body>variable $pdfbox:property-map:=map{
 | 
			
		||||
  "pageCount": pdfbox:number-of-pages#1,
 | 
			
		||||
</xqdoc:description></xqdoc:comment><xqdoc:annotations><xqdoc:annotation name="private"/></xqdoc:annotations><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>number-of-pages</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>number-of-bookmarks</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>number-of-labels</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>specification</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getTitle</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getAuthor</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getCreator</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getProducer</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getSubject</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getKeywords</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getCreationDate</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>gregToISO</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentInformation</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocumentInformation</xqdoc:uri><xqdoc:name>getModificationDate</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>gregToISO</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>labels-as-strings</xqdoc:name></xqdoc:invoked><xqdoc:body>variable $pdfbox:property-map:=map{
 | 
			
		||||
  "#pages": pdfbox:number-of-pages#1,
 | 
			
		||||

 | 
			
		||||
  "hasOutline": pdfbox:hasOutline#1,
 | 
			
		||||
  "#bookmarks": pdfbox:number-of-bookmarks#1,
 | 
			
		||||

 | 
			
		||||
  "hasLabels": pdfbox:hasLabels#1,
 | 
			
		||||
  "#labels": pdfbox:number-of-labels#1,
 | 
			
		||||

 | 
			
		||||
  "specification":pdfbox:specification#1,
 | 
			
		||||

 | 
			
		||||
| 
						 | 
				
			
			@ -482,9 +559,10 @@ values are sequences of functions to get property from $pdf object
 | 
			
		|||

 | 
			
		||||
  "modificationDate":  (PDDocument:getDocumentInformation#1,
 | 
			
		||||
                        PDDocumentInformation:getModificationDate#1,
 | 
			
		||||
                        pdfbox:gregToISO#1)
 | 
			
		||||
                        pdfbox:gregToISO#1),
 | 
			
		||||
   "labels":      pdfbox:labels-as-strings#1                     
 | 
			
		||||
}</xqdoc:body></xqdoc:variable></xqdoc:variables><xqdoc:functions><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
with-document pattern: open pdf,apply function, close pdf
 | 
			
		||||
"With-document" pattern: open pdf,apply $fn function, close pdf
 | 
			
		||||
creates a local pdfobject and ensures it is closed after use
 | 
			
		||||
e.g pdfbox:with-pdf("path...",pdfbox:page-text(?,5))
 | 
			
		||||
</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:with-pdf</xqdoc:name><xqdoc:signature>function pdfbox:with-pdf ( $src as xs:string, $fn as function(item())as item()* ) as item()* { let $pdf:=pdfbox:open($src) return try{ $fn($pdf),pdfbox:close($pdf) } catch *{ pdfbox:close($pdf),fn:error($err:code,$src || " " || $err:description) } }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>src</xqdoc:name><xqdoc:type>xs:string</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>fn</xqdoc:name><xqdoc:type>function(item())as item()*</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">item()</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>open</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>close</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>close</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>error</xqdoc:name></xqdoc:invoked><xqdoc:ref-variable><xqdoc:uri>http://www.w3.org/2005/xqt-errors</xqdoc:uri><xqdoc:name>code</xqdoc:name></xqdoc:ref-variable><xqdoc:ref-variable><xqdoc:uri>http://www.w3.org/2005/xqt-errors</xqdoc:uri><xqdoc:name>description</xqdoc:name></xqdoc:ref-variable><xqdoc:body>function pdfbox:with-pdf($src as xs:string,
 | 
			
		||||
| 
						 | 
				
			
			@ -503,7 +581,7 @@ as item(){
 | 
			
		|||
pdfbox:open($pdfsrc, map{})
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
open pdf from file/url/binary, opts may have password , returns pdf object
 | 
			
		||||
</xqdoc:description><xqdoc:param>$pdfsrc a fetchable url or filepath, or xs:base64Binary item</xqdoc:param><xqdoc:param>$opts options otionally with map {"password":}</xqdoc:param></xqdoc:comment><xqdoc:name>pdfbox:open</xqdoc:name><xqdoc:signature>function pdfbox:open ( $pdfsrc as item(), $opts as map(*) ) as item() { try{ if($pdfsrc instance of xs:base64Binary) then Loader:loadPDF( $pdfsrc,string($opts?password)) else if(starts-with($pdfsrc,"http")) then Loader:loadPDF( fetch:binary($pdfsrc),string($opts?password)) else Loader:loadPDF(RandomAccessReadBufferedFile:new($pdfsrc),string($opts?password)) } catch *{ let $loc:=if($pdfsrc instance of xs:base64Binary) then "xs:base64Binary" else $pdfsrc return error(xs:QName("pdfbox:open"),"Failed PDF load " || $loc || " " || $err:description) } }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdfsrc</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>opts</xqdoc:name><xqdoc:type>map(*)</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>item()</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.Loader</xqdoc:uri><xqdoc:name>loadPDF</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>starts-with</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.Loader</xqdoc:uri><xqdoc:name>loadPDF</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://basex.org/modules/fetch</xqdoc:uri><xqdoc:name>binary</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.Loader</xqdoc:uri><xqdoc:name>loadPDF</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.io.RandomAccessReadBufferedFile</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>error</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2001/XMLSchema</xqdoc:uri><xqdoc:name>QName</xqdoc:name></xqdoc:invoked><xqdoc:ref-variable><xqdoc:uri>http://www.w3.org/2005/xqt-errors</xqdoc:uri><xqdoc:name>description</xqdoc:name></xqdoc:ref-variable><xqdoc:body>function pdfbox:open($pdfsrc as item(), $opts as map(*))
 | 
			
		||||
</xqdoc:description><xqdoc:param>$pdfsrc a fetchable url or filepath, or xs:base64Binary item</xqdoc:param><xqdoc:param>$opts options options include map {"password":}</xqdoc:param><xqdoc:custom tag="note">fetch:binary for https will use a lot of memory here</xqdoc:custom></xqdoc:comment><xqdoc:name>pdfbox:open</xqdoc:name><xqdoc:signature>function pdfbox:open ( $pdfsrc as item(), $opts as map(*) ) as item() { try{ if($pdfsrc instance of xs:base64Binary) then Loader:loadPDF( $pdfsrc,string($opts?password)) else if(starts-with($pdfsrc,"http")) then Loader:loadPDF( fetch:binary($pdfsrc),string($opts?password)) else Loader:loadPDF(RandomAccessReadBufferedFile:new($pdfsrc),string($opts?password)) } catch *{ let $loc:=if($pdfsrc instance of xs:base64Binary) then "xs:base64Binary" else $pdfsrc return error(xs:QName("pdfbox:open"),"Failed PDF load " || $loc || " " || $err:description) } }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdfsrc</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>opts</xqdoc:name><xqdoc:type>map(*)</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>item()</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.Loader</xqdoc:uri><xqdoc:name>loadPDF</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>starts-with</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.Loader</xqdoc:uri><xqdoc:name>loadPDF</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://basex.org/modules/fetch</xqdoc:uri><xqdoc:name>binary</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.Loader</xqdoc:uri><xqdoc:name>loadPDF</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.io.RandomAccessReadBufferedFile</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>error</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2001/XMLSchema</xqdoc:uri><xqdoc:name>QName</xqdoc:name></xqdoc:invoked><xqdoc:ref-variable><xqdoc:uri>http://www.w3.org/2005/xqt-errors</xqdoc:uri><xqdoc:name>description</xqdoc:name></xqdoc:ref-variable><xqdoc:body>function pdfbox:open($pdfsrc as item(), $opts as map(*))
 | 
			
		||||
as item(){
 | 
			
		||||
  try{
 | 
			
		||||

 | 
			
		||||
| 
						 | 
				
			
			@ -526,7 +604,7 @@ returned as string to avoid float rounding issues
 | 
			
		|||
as xs:string{
 | 
			
		||||
 PDDocument:getVersion($pdf)=>xs:decimal()=>round(4)=>string()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
Save pdf $pdf to filesystem at $savepath , returns $savepath</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:save</xqdoc:name><xqdoc:signature>function pdfbox:save ( $pdf as item(),$savepath as xs:string ) as xs:string { PDDocument:save($pdf, File:new($savepath)),$savepath }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>savepath</xqdoc:name><xqdoc:type>xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>save</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:java.io.File</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:save($pdf as item(),$savepath as xs:string)
 | 
			
		||||
Save pdf $pdf to filesystem at $savepath , returns $savepath</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:pdf-save</xqdoc:name><xqdoc:signature>function pdfbox:pdf-save ( $pdf as item(),$savepath as xs:string ) as xs:string { PDDocument:save($pdf, File:new($savepath)),$savepath }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>savepath</xqdoc:name><xqdoc:type>xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>save</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:java.io.File</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:pdf-save($pdf as item(),$savepath as xs:string)
 | 
			
		||||
as xs:string{
 | 
			
		||||
   PDDocument:save($pdf, File:new($savepath)),$savepath
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
| 
						 | 
				
			
			@ -548,12 +626,13 @@ as xs:integer{
 | 
			
		|||
  PDDocument:getNumberOfPages($pdf)
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="3"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
Pdf page as image (zero is cover)
 | 
			
		||||
options.format="bmp jpg png gif" etc, options.scale= 1 is 72 dpi??</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:page-render</xqdoc:name><xqdoc:signature>function pdfbox:page-render ( $pdf as item(),$pageNo as xs:integer,$options as map(*) ) as xs:base64Binary { let $options:=map:merge(($options,map{"format":"jpg","scale":1})) let $bufferedImage:=PDFRenderer:new($pdf)=>PDFRenderer:renderImage($pageNo,$options?scale) let $bytes:=Q{java:java.io.ByteArrayOutputStream}new() let $_:=Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format, $bytes) return Q{java:java.io.ByteArrayOutputStream}toByteArray($bytes) =>convert:integers-to-base64() }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>pageNo</xqdoc:name><xqdoc:type>xs:integer</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>options</xqdoc:name><xqdoc:type>map(*)</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:base64Binary</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions/map</xqdoc:uri><xqdoc:name>merge</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.rendering.PDFRenderer</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="0"><xqdoc:uri>java:java.io.ByteArrayOutputStream</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>java:javax.imageio.ImageIO</xqdoc:uri><xqdoc:name>write</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:java.io.ByteArrayOutputStream</xqdoc:uri><xqdoc:name>toByteArray</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:page-render($pdf as item(),$pageNo as xs:integer,$options as map(*))
 | 
			
		||||
options.format="bmp jpg png gif" etc, options.scale= 1 is 72 dpi??</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:page-render</xqdoc:name><xqdoc:signature>function pdfbox:page-render ( $pdf as item(),$pageNo as xs:integer,$options as map(*) ) as xs:base64Binary { let $options := map:merge(($options,map{"format":"jpg","scale":1})) let $bufferedImage := PDFRenderer:new($pdf) =>PDFRenderer:renderImage($pageNo,$options?scale) let $bytes := Q{java:java.io.ByteArrayOutputStream}new() let $_ := Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format, $bytes) return Q{java:java.io.ByteArrayOutputStream}toByteArray($bytes) =>convert:integers-to-base64() }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>pageNo</xqdoc:name><xqdoc:type>xs:integer</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>options</xqdoc:name><xqdoc:type>map(*)</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:base64Binary</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions/map</xqdoc:uri><xqdoc:name>merge</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.rendering.PDFRenderer</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="0"><xqdoc:uri>java:java.io.ByteArrayOutputStream</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>java:javax.imageio.ImageIO</xqdoc:uri><xqdoc:name>write</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:java.io.ByteArrayOutputStream</xqdoc:uri><xqdoc:name>toByteArray</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:page-render($pdf as item(),$pageNo as xs:integer,$options as map(*))
 | 
			
		||||
as xs:base64Binary{
 | 
			
		||||
  let $options:=map:merge(($options,map{"format":"jpg","scale":1}))
 | 
			
		||||
  let $bufferedImage:=PDFRenderer:new($pdf)=>PDFRenderer:renderImage($pageNo,$options?scale)
 | 
			
		||||
  let $bytes:=Q{java:java.io.ByteArrayOutputStream}new()
 | 
			
		||||
  let $_:=Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format,  $bytes)
 | 
			
		||||
  let $options := map:merge(($options,map{"format":"jpg","scale":1}))
 | 
			
		||||
  let $bufferedImage := PDFRenderer:new($pdf)
 | 
			
		||||
                      =>PDFRenderer:renderImage($pageNo,$options?scale)
 | 
			
		||||
  let $bytes := Q{java:java.io.ByteArrayOutputStream}new()
 | 
			
		||||
  let $_ := Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format,  $bytes)
 | 
			
		||||
  return Q{java:java.io.ByteArrayOutputStream}toByteArray($bytes)
 | 
			
		||||
         =>convert:integers-to-base64()
 | 
			
		||||
 
 | 
			
		||||
| 
						 | 
				
			
			@ -562,19 +641,19 @@ known property names sorted</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbo
 | 
			
		|||
as xs:string*{
 | 
			
		||||
  $pdfbox:property-map=>map:keys()=>sort()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
return value of $property for $pdf</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:property</xqdoc:name><xqdoc:signature>function pdfbox:property ( $pdf as item(),$property as xs:string ) as item()* { let $fns:= $pdfbox:property-map($property) return if(exists($fns)) then fold-left($fns, $pdf, function($result,$this as function(*)){$this($result)}) else error(xs:QName('pdfbox:property'),concat("Property '",$property,"' not defined.")) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>property</xqdoc:name><xqdoc:type>xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">item()</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>fold-left</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>error</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2001/XMLSchema</xqdoc:uri><xqdoc:name>QName</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>concat</xqdoc:name></xqdoc:invoked><xqdoc:ref-variable><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>property-map</xqdoc:name></xqdoc:ref-variable><xqdoc:body>function pdfbox:property($pdf as item(),$property as xs:string)
 | 
			
		||||
return value of $property for $pdf</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:property</xqdoc:name><xqdoc:signature>function pdfbox:property ( $pdf as item(),$property as xs:string ) as item()* { let $fns:= $pdfbox:property-map($property) return if(exists($fns)) then fold-left($fns, $pdf, function($result,$this as function(*)){$result!$this(.)}) else error(xs:QName('pdfbox:property'),concat("Property '",$property,"' not defined.")) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>property</xqdoc:name><xqdoc:type>xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">item()</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>fold-left</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>error</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2001/XMLSchema</xqdoc:uri><xqdoc:name>QName</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>concat</xqdoc:name></xqdoc:invoked><xqdoc:ref-variable><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>property-map</xqdoc:name></xqdoc:ref-variable><xqdoc:body>function pdfbox:property($pdf as item(),$property as xs:string)
 | 
			
		||||
as item()*{
 | 
			
		||||
  let $fns:= $pdfbox:property-map($property)
 | 
			
		||||
  return if(exists($fns))
 | 
			
		||||
         then fold-left($fns, 
 | 
			
		||||
                        $pdf, 
 | 
			
		||||
                        function($result,$this as function(*)){$this($result)})
 | 
			
		||||
                        function($result,$this as function(*)){$result!$this(.)})
 | 
			
		||||
         else error(xs:QName('pdfbox:property'),concat("Property '",$property,"' not defined."))
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
summary CSV style info for all properties for $pdfpaths
 | 
			
		||||
</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:report</xqdoc:name><xqdoc:signature>function pdfbox:report ( $pdfpaths as xs:string* ) as map(*) { pdfbox:report($pdfpaths,map:keys($pdfbox:property-map)) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdfpaths</xqdoc:name><xqdoc:type occurrence="*">xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>map(*)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>report</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions/map</xqdoc:uri><xqdoc:name>keys</xqdoc:name></xqdoc:invoked><xqdoc:ref-variable><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>property-map</xqdoc:name></xqdoc:ref-variable><xqdoc:body>function pdfbox:report($pdfpaths as xs:string*)
 | 
			
		||||
</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:report</xqdoc:name><xqdoc:signature>function pdfbox:report ( $pdfpaths as xs:string* ) as map(*) { pdfbox:report($pdfpaths,pdfbox:property-names()) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdfpaths</xqdoc:name><xqdoc:type occurrence="*">xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>map(*)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>report</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="0"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>property-names</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:report($pdfpaths as xs:string*)
 | 
			
		||||
as map(*){
 | 
			
		||||
 pdfbox:report($pdfpaths,map:keys($pdfbox:property-map))
 | 
			
		||||
 pdfbox:report($pdfpaths,pdfbox:property-names())
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
summary CSV style info for named properties for $pdfpaths
 | 
			
		||||
</xqdoc:description><xqdoc:see>https://docs.basex.org/main/CSV_Functions#xquery</xqdoc:see></xqdoc:comment><xqdoc:name>pdfbox:report</xqdoc:name><xqdoc:signature>function pdfbox:report ( $pdfpaths as item()*, $properties as xs:string* ) as map(*) { map{"names": array{"path",$properties}, "records": for $path in $pdfpaths let $name:=if($path instance of xs:base64Binary) then "binary" else $path return try{ let $pdf:=pdfbox:open($path) return (fold-left($properties, array{$name}, function($result as array(*),$prop as xs:string){ array:append($result, string(pdfbox:property($pdf, $prop)))} ), pdfbox:close($pdf) ) } catch *{ fold-left($properties, array{$name}, function($result as array(*),$prop as xs:string){ array:append($result, "#ERROR")} ) } } }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdfpaths</xqdoc:name><xqdoc:type occurrence="*">item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>properties</xqdoc:name><xqdoc:type occurrence="*">xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>map(*)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>open</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>fold-left</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions/array</xqdoc:uri><xqdoc:name>append</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>property</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>close</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>fold-left</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://www.w3.org/2005/xpath-functions/array</xqdoc:uri><xqdoc:name>append</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:report($pdfpaths as item()*, $properties as xs:string*)
 | 
			
		||||
| 
						 | 
				
			
			@ -600,18 +679,16 @@ as map(*){
 | 
			
		|||
                 }
 | 
			
		||||
               
 | 
			
		||||
  }
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
convenience function to save report() data to file</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:report-save</xqdoc:name><xqdoc:signature>function pdfbox:report-save ( $data as map(*),$dest as xs:string ) as empty-sequence() { let $opts := map { "format":"xquery", "header":"yes", "separator" : "," } return file:write-text($dest,csv:serialize($data,$opts)) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>data</xqdoc:name><xqdoc:type>map(*)</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>dest</xqdoc:name><xqdoc:type>xs:string</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>empty-sequence</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>http://expath.org/ns/file</xqdoc:uri><xqdoc:name>write-text</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>http://basex.org/modules/csv</xqdoc:uri><xqdoc:name>serialize</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:report-save($data as map(*),$dest as xs:string)
 | 
			
		||||
as empty-sequence(){
 | 
			
		||||
  let $opts := map {  "format":"xquery", "header":"yes", "separator" : "," }
 | 
			
		||||
  return file:write-text($dest,csv:serialize($data,$opts))
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
true if $pdf has an outline</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:hasOutline</xqdoc:name><xqdoc:signature>function pdfbox:hasOutline ( $pdf as item() ) as xs:boolean { PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getDocumentOutline() =>exists() }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:boolean</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:hasOutline($pdf as item())
 | 
			
		||||
as xs:boolean{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getDocumentOutline()
 | 
			
		||||
  =>exists()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
true if $pdf has Labels</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:hasLabels</xqdoc:name><xqdoc:signature>function pdfbox:hasLabels ( $pdf as item() ) as xs:boolean { PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPageLabels() =>exists() }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:boolean</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:hasLabels($pdf as item())
 | 
			
		||||
as xs:boolean{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  =>exists()
 | 
			
		||||
number of outline items</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:number-of-bookmarks</xqdoc:name><xqdoc:signature>function pdfbox:number-of-bookmarks ( $pdf as item() ) as xs:integer { let $xml:=pdfbox:outline-xml($pdf) return count($xml//bookmark) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:integer</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>outline-xml</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>count</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:number-of-bookmarks($pdf as item())
 | 
			
		||||
as xs:integer{
 | 
			
		||||
  let $xml:=pdfbox:outline-xml($pdf)
 | 
			
		||||
  return count($xml//bookmark)
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
XMP metadata as "RDF" document
 | 
			
		||||
</xqdoc:description><xqdoc:custom tag="note">usually rdf:RDF root, but sometimes x:xmpmeta</xqdoc:custom></xqdoc:comment><xqdoc:name>pdfbox:metadata</xqdoc:name><xqdoc:signature>function pdfbox:metadata ( $pdf as item() ) as document-node(element(*))? { let $m:=PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getMetadata() return if(exists($m)) then let $is:=PDMetadata:exportXMPMetadata($m) return pdfbox:do-until( map{"n":0,"data":""}, function($input,$pos ) { pdfbox:read-stream($is,$input?data)}, function($output,$pos) { $output?n eq -1 } )?data=>parse-xml() else () }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="?">document-node(element(*))</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDMetadata</xqdoc:uri><xqdoc:name>exportXMPMetadata</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="3"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>do-until</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>read-stream</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:metadata($pdf as item())
 | 
			
		||||
| 
						 | 
				
			
			@ -682,7 +759,7 @@ as element(outline)?{
 | 
			
		|||
         then <outline>{$outline!pdfbox:bookmark-xml(.)}</outline>
 | 
			
		||||
         else ()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
recursive ouutline map to XML</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:bookmark-xml</xqdoc:name><xqdoc:annotations><xqdoc:annotation name="private"/></xqdoc:annotations><xqdoc:signature>function pdfbox:bookmark-xml ( $outline as map(*)* ) as element(bookmark)* { $outline! <bookmark title="{?title}" index="{?index}"> {?children!pdfbox:bookmark-xml(.)} </bookmark> }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>outline</xqdoc:name><xqdoc:type occurrence="*">map(*)</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">element(bookmark)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>bookmark-xml</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:bookmark-xml($outline as map(*)*)
 | 
			
		||||
Convert outline map to XML</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:bookmark-xml</xqdoc:name><xqdoc:annotations><xqdoc:annotation name="private"/></xqdoc:annotations><xqdoc:signature>function pdfbox:bookmark-xml ( $outline as map(*)* ) as element(bookmark)* { $outline! <bookmark title="{?title}" index="{?index}"> {?children!pdfbox:bookmark-xml(.)} </bookmark> }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>outline</xqdoc:name><xqdoc:type occurrence="*">map(*)</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">element(bookmark)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>bookmark-xml</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:bookmark-xml($outline as map(*)*)
 | 
			
		||||
as element(bookmark)*
 | 
			
		||||
{
 | 
			
		||||
  $outline!
 | 
			
		||||
| 
						 | 
				
			
			@ -690,7 +767,7 @@ as element(bookmark)*
 | 
			
		|||
    {?children!pdfbox:bookmark-xml(.)}
 | 
			
		||||
  </bookmark>
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
return bookmark info for $bookmark
 | 
			
		||||
Return bookmark info for $bookmark
 | 
			
		||||
</xqdoc:description><xqdoc:return>map{index:..,title:..,hasChildren:..}</xqdoc:return></xqdoc:comment><xqdoc:name>pdfbox:bookmark</xqdoc:name><xqdoc:annotations><xqdoc:annotation name="private"/></xqdoc:annotations><xqdoc:signature>function pdfbox:bookmark ( $bookmark as item(),$pdf as item() ) as map(*) { map{ "index": PDOutlineItem:findDestinationPage($bookmark,$pdf)=>pdfbox:find-page($pdf), "title": (# db:checkstrings #) {PDOutlineItem:getTitle($bookmark)} (:=>translate("<22>",""), :), "hasChildren": PDOutlineItem:hasChildren($bookmark) } }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>bookmark</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>map(*)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem</xqdoc:uri><xqdoc:name>findDestinationPage</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem</xqdoc:uri><xqdoc:name>getTitle</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem</xqdoc:uri><xqdoc:name>hasChildren</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:bookmark($bookmark as item(),$pdf as item())
 | 
			
		||||
as map(*)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -719,15 +796,73 @@ as xs:base64Binary
 | 
			
		|||
    let $a:=PageExtractor:new($pdf, $start, $end) =>PageExtractor:extract()
 | 
			
		||||
    return (pdfbox:binary($a),pdfbox:close($a)) 
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
pageLabel for every page or empty if none
 | 
			
		||||
</xqdoc:description><xqdoc:see>https://www.w3.org/TR/WCAG20-TECHS/PDF17.html#PDF17-examples</xqdoc:see><xqdoc:see>https://codereview.stackexchange.com/questions/286078/java-code-showing-page-labels-from-pdf-files</xqdoc:see></xqdoc:comment><xqdoc:name>pdfbox:labels</xqdoc:name><xqdoc:signature>function pdfbox:labels ( $pdf as item() ) as xs:string* { let $pagelabels:=PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPageLabels() return if(exists($pagelabels)) then PDPageLabels:getLabelsByPageIndices($pagelabels) else () }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabels</xqdoc:uri><xqdoc:name>getLabelsByPageIndices</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:labels($pdf as item())
 | 
			
		||||
The number of labels defined in PDF</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:number-of-labels</xqdoc:name><xqdoc:signature>function pdfbox:number-of-labels ( $pdf as item() ) as xs:integer { let $labels:=PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPageLabels() return if(exists($labels)) then PDPageLabels:getPageRangeCount($labels) else 0 }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:integer</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabels</xqdoc:uri><xqdoc:name>getPageRangeCount</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:number-of-labels($pdf as item())
 | 
			
		||||
as xs:integer
 | 
			
		||||
{
 | 
			
		||||
  let $labels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
               =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return if(exists($labels)) 
 | 
			
		||||
         then PDPageLabels:getPageRangeCount($labels)
 | 
			
		||||
         else 0
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
pageLabel for every page from derived from page-ranges
 | 
			
		||||
The returned sequence will contain at MOST as much entries as the document has pages.
 | 
			
		||||
</xqdoc:description><xqdoc:see>https://www.w3.org/TR/WCAG20-TECHS/PDF17.html#PDF17-examples</xqdoc:see><xqdoc:see>https://codereview.stackexchange.com/questions/286078/java-code-showing-page-labels-from-pdf-files</xqdoc:see></xqdoc:comment><xqdoc:name>pdfbox:labels-by-page</xqdoc:name><xqdoc:signature>function pdfbox:labels-by-page ( $pdf as item() ) as xs:string* { PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPageLabels() =>PDPageLabels:getLabelsByPageIndices() }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:labels-by-page($pdf as item())
 | 
			
		||||
as xs:string*
 | 
			
		||||
{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  =>PDPageLabels:getLabelsByPageIndices()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
sequence of label ranges defined in PDF as formatted strings</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:labels-as-strings</xqdoc:name><xqdoc:signature>function pdfbox:labels-as-strings ( $pdf as item() ) as xs:string { let $pagelabels:=PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPageLabels() return $pagelabels !(0 to pdfbox:number-of-pages($pdf)-1) !pdfbox:label-as-string($pagelabels,.)=>string-join(",") }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>number-of-pages</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>label-as-string</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:labels-as-strings($pdf as item())
 | 
			
		||||
as xs:string{
 | 
			
		||||
  let $pagelabels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
                   =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return if(exists($pagelabels))
 | 
			
		||||
         then PDPageLabels:getLabelsByPageIndices($pagelabels)
 | 
			
		||||
         else ()
 | 
			
		||||
  return $pagelabels
 | 
			
		||||
         !(0 to pdfbox:number-of-pages($pdf)-1)
 | 
			
		||||
         !pdfbox:label-as-string($pagelabels,.)=>string-join(",")
 | 
			
		||||
            
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
get pagelabels exist</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:page-labels</xqdoc:name><xqdoc:signature>function pdfbox:page-labels ( $pdf ) { PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPageLabels() }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name></xqdoc:parameter></xqdoc:parameters><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:page-labels($pdf)
 | 
			
		||||
{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
label for $page formated as string</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:label-as-string</xqdoc:name><xqdoc:signature>function pdfbox:label-as-string ( $pagelabels,$page as xs:integer ) as xs:string? { let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page) return if(empty($label)) then () else let $start:= PDPageLabelRange:getStart($label) let $style := PDPageLabelRange:getStyle($label) let $prefix:= PDPageLabelRange:getPrefix($label) return string-join(($page, if(empty($style)) then "-" else $style, if(($start eq 1)) then "" else $start, if(exists($prefix)) then '*' || $prefix (:TODO double " :) )) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pagelabels</xqdoc:name></xqdoc:parameter><xqdoc:parameter><xqdoc:name>page</xqdoc:name><xqdoc:type>xs:integer</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="?">xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabels</xqdoc:uri><xqdoc:name>getPageLabelRange</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>empty</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange</xqdoc:uri><xqdoc:name>getStart</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange</xqdoc:uri><xqdoc:name>getStyle</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange</xqdoc:uri><xqdoc:name>getPrefix</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>string-join</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>empty</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:label-as-string($pagelabels,$page as  xs:integer)
 | 
			
		||||
as xs:string?{
 | 
			
		||||
  let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page)
 | 
			
		||||
  return  if(empty($label))
 | 
			
		||||
          then ()
 | 
			
		||||
          else
 | 
			
		||||
            let $start:=  PDPageLabelRange:getStart($label)
 | 
			
		||||
            let $style := PDPageLabelRange:getStyle($label)
 | 
			
		||||
            let $prefix:= PDPageLabelRange:getPrefix($label) 
 | 
			
		||||
            return string-join(($page, 
 | 
			
		||||
                                if(empty($style)) then "-" else $style,
 | 
			
		||||
                                if(($start eq 1)) then "" else $start,
 | 
			
		||||
                                if(exists($prefix)) then '*' || $prefix  (:TODO double " :)
 | 
			
		||||
                    ))
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
sequence of maps for each label in</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:labels-as-map</xqdoc:name><xqdoc:signature>function pdfbox:labels-as-map ( $pdf as item() ) as map(*)* { let $pagelabels:=PDDocument:getDocumentCatalog($pdf) =>PDDocumentCatalog:getPageLabels() return $pagelabels !(0 to pdfbox:number-of-pages($pdf)-1) !pdfbox:label-as-map($pagelabels,.) }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="*">map(*)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getDocumentCatalog</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>number-of-pages</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>org.expkg_zone58.Pdfbox3</xqdoc:uri><xqdoc:name>label-as-map</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:labels-as-map($pdf as item())
 | 
			
		||||
as map(*)*{
 | 
			
		||||
  let $pagelabels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
                   =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return  $pagelabels
 | 
			
		||||
          !(0 to pdfbox:number-of-pages($pdf)-1)
 | 
			
		||||
          !pdfbox:label-as-map($pagelabels,.)
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
express label/page-range for $page as map</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:label-as-map</xqdoc:name><xqdoc:signature>function pdfbox:label-as-map ( $pagelabels,$page as xs:integer ) as map(*) { let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page) return if(empty($label)) then () else map{ "index": $page, "prefix": PDPageLabelRange:getPrefix($label), "start": PDPageLabelRange:getStart($label), "style": PDPageLabelRange:getStyle($label) } }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pagelabels</xqdoc:name></xqdoc:parameter><xqdoc:parameter><xqdoc:name>page</xqdoc:name><xqdoc:type>xs:integer</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>map(*)</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabels</xqdoc:uri><xqdoc:name>getPageLabelRange</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>empty</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange</xqdoc:uri><xqdoc:name>getPrefix</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange</xqdoc:uri><xqdoc:name>getStart</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange</xqdoc:uri><xqdoc:name>getStyle</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:label-as-map($pagelabels,$page as  xs:integer)
 | 
			
		||||
as map(*)
 | 
			
		||||
{
 | 
			
		||||
  let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page)
 | 
			
		||||
  return if(empty($label))
 | 
			
		||||
  then ()
 | 
			
		||||
  else map{
 | 
			
		||||
      "index": $page,
 | 
			
		||||
      "prefix": PDPageLabelRange:getPrefix($label),
 | 
			
		||||
      "start":  PDPageLabelRange:getStart($label),
 | 
			
		||||
      "style":  PDPageLabelRange:getStyle($label)
 | 
			
		||||
      }
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
return text on $pageNo</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:page-text</xqdoc:name><xqdoc:signature>function pdfbox:page-text ( $pdf as item(), $pageNo as xs:integer ) as xs:string { let $tStripper := (# db:wrapjava instance #) { PDFTextStripper:new() => PDFTextStripper:setStartPage($pageNo) => PDFTextStripper:setEndPage($pageNo) } return (# db:checkstrings #) {PDFTextStripper:getText($tStripper,$pdf)} }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>pageNo</xqdoc:name><xqdoc:type>xs:integer</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="0"><xqdoc:uri>java:org.apache.pdfbox.text.PDFTextStripper</xqdoc:uri><xqdoc:name>new</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.text.PDFTextStripper</xqdoc:uri><xqdoc:name>getText</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:page-text($pdf as item(), $pageNo as xs:integer)
 | 
			
		||||
as xs:string{
 | 
			
		||||
| 
						 | 
				
			
			@ -738,18 +873,18 @@ as xs:string{
 | 
			
		|||
       }
 | 
			
		||||
  return (# db:checkstrings #) {PDFTextStripper:getText($tStripper,$pdf)}
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="2"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
return size of $pageNo (zero based)
 | 
			
		||||
Return size of $pageNo (zero based)
 | 
			
		||||
</xqdoc:description><xqdoc:custom tag="result">e.g. [0.0,0.0,168.0,239.52]</xqdoc:custom></xqdoc:comment><xqdoc:name>pdfbox:page-media-box</xqdoc:name><xqdoc:signature>function pdfbox:page-media-box ( $pdf as item(), $pageNo as xs:integer ) as xs:string { PDDocument:getPage($pdf, $pageNo) =>PDPage:getMediaBox() =>PDRectangle:toString() }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>pdf</xqdoc:name><xqdoc:type>item()</xqdoc:type></xqdoc:parameter><xqdoc:parameter><xqdoc:name>pageNo</xqdoc:name><xqdoc:type>xs:integer</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type>xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="2"><xqdoc:uri>java:org.apache.pdfbox.pdmodel.PDDocument</xqdoc:uri><xqdoc:name>getPage</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:page-media-box($pdf as item(), $pageNo as xs:integer)
 | 
			
		||||
as xs:string{
 | 
			
		||||
  PDDocument:getPage($pdf, $pageNo)
 | 
			
		||||
  =>PDPage:getMediaBox()
 | 
			
		||||
  =>PDRectangle:toString()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="0"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
version of Apache Pdfbox in use  e.g. "3.0.4"</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:version</xqdoc:name><xqdoc:signature>function pdfbox:version ( ) as xs:string { Q{java:org.apache.pdfbox.util.Version}getVersion() }</xqdoc:signature><xqdoc:return><xqdoc:type>xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="0"><xqdoc:uri>java:org.apache.pdfbox.util.Version</xqdoc:uri><xqdoc:name>getVersion</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:version()
 | 
			
		||||
Version of Apache Pdfbox in use  e.g. "3.0.4"</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:version</xqdoc:name><xqdoc:signature>function pdfbox:version ( ) as xs:string { Q{java:org.apache.pdfbox.util.Version}getVersion() }</xqdoc:signature><xqdoc:return><xqdoc:type>xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="0"><xqdoc:uri>java:org.apache.pdfbox.util.Version</xqdoc:uri><xqdoc:name>getVersion</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:version()
 | 
			
		||||
as xs:string{
 | 
			
		||||
  Q{java:org.apache.pdfbox.util.Version}getVersion()
 | 
			
		||||
}</xqdoc:body></xqdoc:function><xqdoc:function arity="1"><xqdoc:comment><xqdoc:description>
 | 
			
		||||
convert date</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:gregToISO</xqdoc:name><xqdoc:annotations><xqdoc:annotation name="private"/></xqdoc:annotations><xqdoc:signature>function pdfbox:gregToISO ( $item as item()? ) as xs:string? { if(exists($item)) then Q{java:java.util.GregorianCalendar}toZonedDateTime($item)=>string() else () }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>item</xqdoc:name><xqdoc:type occurrence="?">item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="?">xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:java.util.GregorianCalendar</xqdoc:uri><xqdoc:name>toZonedDateTime</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:gregToISO($item as item()?)
 | 
			
		||||
Convert date</xqdoc:description></xqdoc:comment><xqdoc:name>pdfbox:gregToISO</xqdoc:name><xqdoc:annotations><xqdoc:annotation name="private"/></xqdoc:annotations><xqdoc:signature>function pdfbox:gregToISO ( $item as item()? ) as xs:string? { if(exists($item)) then Q{java:java.util.GregorianCalendar}toZonedDateTime($item)=>string() else () }</xqdoc:signature><xqdoc:parameters><xqdoc:parameter><xqdoc:name>item</xqdoc:name><xqdoc:type occurrence="?">item()</xqdoc:type></xqdoc:parameter></xqdoc:parameters><xqdoc:return><xqdoc:type occurrence="?">xs:string</xqdoc:type></xqdoc:return><xqdoc:invoked arity="1"><xqdoc:uri>http://www.w3.org/2005/xpath-functions</xqdoc:uri><xqdoc:name>exists</xqdoc:name></xqdoc:invoked><xqdoc:invoked arity="1"><xqdoc:uri>java:java.util.GregorianCalendar</xqdoc:uri><xqdoc:name>toZonedDateTime</xqdoc:name></xqdoc:invoked><xqdoc:body>function pdfbox:gregToISO($item as item()?)
 | 
			
		||||
as xs:string?{
 | 
			
		||||
 if(exists($item))
 | 
			
		||||
 then Q{java:java.util.GregorianCalendar}toZonedDateTime($item)=>string()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -7,4 +7,4 @@
 | 
			
		|||
               Contents
 | 
			
		||||
            </h3><ol class="toc"><li><a href="#summary"><span class="secno">1 </span><span class="content">Summary</span></a></li><li><a href="#rest"><span class="secno">2 </span><span class="content">Rest Paths</span></a></li></ol></nav><section id="summary"><h2>Summary</h2><p>No RESTXQ usage</p><details><summary>Related documents</summary><table class="data"><thead><th>View</th><th>Description</th><th>Format</th></thead><tbody><tr><td><a href="index.html" title="Index of sources " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">report</a></td><td>Index of sources</td><td>xhtml</td></tr><tr><td><a href="imports.html" title="Summary of import usage " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports</a></td><td>Summary of import usage</td><td>xhtml</td></tr><tr><td><a href="mermaid.html" title="Project wide module imports as html mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">imports-diag</a></td><td>Project wide module imports as html mermaid class diagram</td><td>html5</td></tr><tr><td><a href="mermaid.mmd" title="Project wide module imports as a mermaid class diagram " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">imports-diag.mmd</a></td><td>Project wide module imports as a mermaid class diagram</td><td>text</td></tr><tr><td><a href="annotations.html" title="Summary of XQuery annotation use " class="badge badge-pill badge-light" style="margin-left:1em" target="_self">annotations</a></td><td>Summary of XQuery annotation use</td><td>xhtml</td></tr><tr><td><a href="xqdoca.xml" title="xqDocA run configuration report (XML) " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoca.xml</a></td><td>xqDocA run configuration report (XML)</td><td>xml</td></tr><tr><td><a href="validation-report.xml" title="validate generated xqdoc files " class="badge badge-pill badge-light" style="margin-left:1em" target="_blank">xqdoc-validate</a></td><td>validate generated xqdoc files</td><td>xml</td></tr></tbody></table></details></section><section id="rest"><h2>Rest interface paths</h2></section></div></div><div class="footer"><p style="text-align:right">Generated by 
 | 
			
		||||
            <a href="https://github.com/Quodatum/xqdoca" target="_blank">xqDocA <span>0.9.1</span></a>
 | 
			
		||||
               on <span title="2025-06-01T21:16:07.687+01:00">Sunday, 1st June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
               on <span title="2025-06-03T22:34:04.782+01:00">Tuesday, 3rd June 2025</span></p></div><script src="resources/prism/1.29.0/prism.js" type="text/javascript"></script><script src="resources/xqdoca.js" type="text/javascript"></script></body></html>
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +1 @@
 | 
			
		|||
<errors created="2025-06-01T21:16:07.687+01:00" schema="file:///C:/Users/mrwhe/git/quodatum/xqdoca/src/main/etc/models/xqdoc-1.1.xsd" errors="0"><report source="Pdfbox3.xqm" xqdoc="modules/F000001/"><status>valid</status></report></errors>
 | 
			
		||||
<errors created="2025-06-03T22:34:04.782+01:00" schema="file:///C:/Users/mrwhe/git/quodatum/xqdoca/src/main/etc/models/xqdoc-1.1.xsd" errors="0"><report source="Pdfbox3.xqm" xqdoc="modules/F000001/"><status>valid</status></report></errors>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
<xqdoca created="2025-06-01T21:16:07.687+01:00"><xqdoca>0.9.1</xqdoca><target>docs/xqdoc/</target><outputs><global>
 | 
			
		||||
<xqdoca created="2025-06-03T22:34:04.782+01:00"><xqdoca>0.9.1</xqdoca><target>docs/xqdoc/</target><outputs><global>
 | 
			
		||||
            report
 | 
			
		||||
            restxq
 | 
			
		||||
            imports
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
{
 | 
			
		||||
  "name": "pdfbox",
 | 
			
		||||
  "version": "0.3.6",
 | 
			
		||||
  "version": "0.3.8",
 | 
			
		||||
  "description": "A BaseX interface to Apache Pdfbox version 3",
 | 
			
		||||
  "main": "src/Pdfbox3.xqm",
 | 
			
		||||
  "homepage": "https://github.com/expkg-zone58/pdfbox#readme",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										143
									
								
								src/Pdfbox3.xqm
									
										
									
									
									
								
							
							
						
						
									
										143
									
								
								src/Pdfbox3.xqm
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,8 +1,10 @@
 | 
			
		|||
xquery version '3.1';
 | 
			
		||||
(:~ 
 | 
			
		||||
A BaseX 10.7+ interface to pdfbox 3.0 https://pdfbox.apache.org/ , 
 | 
			
		||||
requires pdfbox jars on classpath, i.e. in custom or xar
 | 
			
		||||
tested with pdfbox-app-3.0.5.jar
 | 
			
		||||
A BaseX 10.7+ interface to pdfbox3 https://pdfbox.apache.org/ , 
 | 
			
		||||
requires pdfbox jars on classpath, in lib/custom or xar
 | 
			
		||||
@note following the java source the terms outline and bookmark
 | 
			
		||||
refer to the same concept. Also label and (page)range are used interchangably
 | 
			
		||||
@note tested with pdfbox-app-3.0.5.jar
 | 
			
		||||
@see https://pdfbox.apache.org/download.cgi
 | 
			
		||||
@javadoc https://javadoc.io/static/org.apache.pdfbox/pdfbox/3.0.5/
 | 
			
		||||
@author Andy Bunce 2025
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +17,8 @@ declare namespace PDFTextStripper = "java:org.apache.pdfbox.text.PDFTextStripper
 | 
			
		|||
declare namespace PDDocument ="java:org.apache.pdfbox.pdmodel.PDDocument";
 | 
			
		||||
declare namespace PDDocumentCatalog ="java:org.apache.pdfbox.pdmodel.PDDocumentCatalog";
 | 
			
		||||
declare namespace PDPageLabels ="java:org.apache.pdfbox.pdmodel.common.PDPageLabels";
 | 
			
		||||
declare namespace PDPageLabelRange="java:org.apache.pdfbox.pdmodel.common.PDPageLabelRange";
 | 
			
		||||
 | 
			
		||||
declare namespace PageExtractor ="java:org.apache.pdfbox.multipdf.PageExtractor";
 | 
			
		||||
declare namespace PDPage ="java:org.apache.pdfbox.pdmodel.PDPage";
 | 
			
		||||
declare namespace PDPageTree ="java:org.apache.pdfbox.pdmodel.PDPageTree";
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +29,7 @@ declare namespace PDFRenderer="java:org.apache.pdfbox.rendering.PDFRenderer";
 | 
			
		|||
declare namespace PDMetadata="java:org.apache.pdfbox.pdmodel.common.PDMetadata";
 | 
			
		||||
declare namespace COSInputStream="java:org.apache.pdfbox.cos.COSInputStream";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +41,7 @@ declare namespace File ="java:java.io.File";
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
(:~ "With-document" pattern: open pdf,apply function, close pdf
 | 
			
		||||
(:~ "With-document" pattern: open pdf,apply $fn function, close pdf
 | 
			
		||||
 creates a local pdfobject and ensures it is closed after use
 | 
			
		||||
e.g pdfbox:with-pdf("path...",pdfbox:page-text(?,5))
 | 
			
		||||
:)
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +66,8 @@ pdfbox:open($pdfsrc, map{})
 | 
			
		|||
 | 
			
		||||
(:~ open pdf from file/url/binary, opts may have password , returns pdf object 
 | 
			
		||||
@param $pdfsrc a fetchable url or filepath, or xs:base64Binary item
 | 
			
		||||
@param $opts options otionally with map {"password":} 
 | 
			
		||||
@param $opts options options include map {"password":}
 | 
			
		||||
@note fetch:binary for https will use a lot of memory here
 | 
			
		||||
:)
 | 
			
		||||
declare function pdfbox:open($pdfsrc as item(), $opts as map(*))
 | 
			
		||||
as item(){
 | 
			
		||||
| 
						 | 
				
			
			@ -90,7 +96,7 @@ as xs:string{
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
(:~ Save pdf $pdf to filesystem at $savepath , returns $savepath :)
 | 
			
		||||
declare function pdfbox:save($pdf as item(),$savepath as xs:string)
 | 
			
		||||
declare function pdfbox:pdf-save($pdf as item(),$savepath as xs:string)
 | 
			
		||||
as xs:string{
 | 
			
		||||
   PDDocument:save($pdf, File:new($savepath)),$savepath
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -122,10 +128,11 @@ as xs:integer{
 | 
			
		|||
options.format="bmp jpg png gif" etc, options.scale= 1 is 72 dpi?? :)
 | 
			
		||||
declare function pdfbox:page-render($pdf as item(),$pageNo as xs:integer,$options as map(*))
 | 
			
		||||
as xs:base64Binary{
 | 
			
		||||
  let $options:=map:merge(($options,map{"format":"jpg","scale":1}))
 | 
			
		||||
  let $bufferedImage:=PDFRenderer:new($pdf)=>PDFRenderer:renderImage($pageNo,$options?scale)
 | 
			
		||||
  let $bytes:=Q{java:java.io.ByteArrayOutputStream}new()
 | 
			
		||||
  let $_:=Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format,  $bytes)
 | 
			
		||||
  let $options := map:merge(($options,map{"format":"jpg","scale":1}))
 | 
			
		||||
  let $bufferedImage := PDFRenderer:new($pdf)
 | 
			
		||||
                      =>PDFRenderer:renderImage($pageNo,$options?scale)
 | 
			
		||||
  let $bytes := Q{java:java.io.ByteArrayOutputStream}new()
 | 
			
		||||
  let $_ := Q{java:javax.imageio.ImageIO}write($bufferedImage ,$options?format,  $bytes)
 | 
			
		||||
  return Q{java:java.io.ByteArrayOutputStream}toByteArray($bytes)
 | 
			
		||||
         =>convert:integers-to-base64()
 | 
			
		||||
 
 | 
			
		||||
| 
						 | 
				
			
			@ -137,11 +144,11 @@ as xs:base64Binary{
 | 
			
		|||
   values are sequences of functions to get property from $pdf object
 | 
			
		||||
:)
 | 
			
		||||
declare %private variable $pdfbox:property-map:=map{
 | 
			
		||||
  "pageCount": pdfbox:number-of-pages#1,
 | 
			
		||||
  "#pages": pdfbox:number-of-pages#1,
 | 
			
		||||
 | 
			
		||||
  "hasOutline": pdfbox:hasOutline#1,
 | 
			
		||||
  "#bookmarks": pdfbox:number-of-bookmarks#1,
 | 
			
		||||
 | 
			
		||||
  "hasLabels": pdfbox:hasLabels#1,
 | 
			
		||||
  "#labels": pdfbox:number-of-labels#1,
 | 
			
		||||
 | 
			
		||||
  "specification":pdfbox:specification#1,
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +176,8 @@ declare %private variable $pdfbox:property-map:=map{
 | 
			
		|||
 | 
			
		||||
  "modificationDate":  (PDDocument:getDocumentInformation#1,
 | 
			
		||||
                        PDDocumentInformation:getModificationDate#1,
 | 
			
		||||
                        pdfbox:gregToISO#1)
 | 
			
		||||
                        pdfbox:gregToISO#1),
 | 
			
		||||
   "labels":      pdfbox:labels-as-strings#1                     
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ known property names sorted :)
 | 
			
		||||
| 
						 | 
				
			
			@ -185,7 +193,7 @@ as item()*{
 | 
			
		|||
  return if(exists($fns))
 | 
			
		||||
         then fold-left($fns, 
 | 
			
		||||
                        $pdf, 
 | 
			
		||||
                        function($result,$this as function(*)){$this($result)})
 | 
			
		||||
                        function($result,$this as function(*)){$result!$this(.)})
 | 
			
		||||
         else error(xs:QName('pdfbox:property'),concat("Property '",$property,"' not defined."))
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -193,7 +201,7 @@ as item()*{
 | 
			
		|||
:)
 | 
			
		||||
declare function pdfbox:report($pdfpaths as xs:string*)
 | 
			
		||||
as map(*){
 | 
			
		||||
 pdfbox:report($pdfpaths,map:keys($pdfbox:property-map))
 | 
			
		||||
 pdfbox:report($pdfpaths,pdfbox:property-names())
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ summary CSV style info for named properties for $pdfpaths 
 | 
			
		||||
| 
						 | 
				
			
			@ -224,20 +232,18 @@ as map(*){
 | 
			
		|||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ true if $pdf has an outline :)
 | 
			
		||||
declare function pdfbox:hasOutline($pdf as item())
 | 
			
		||||
as xs:boolean{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getDocumentOutline()
 | 
			
		||||
  =>exists()
 | 
			
		||||
(:~ convenience function to save report() data to file :)
 | 
			
		||||
declare function pdfbox:report-save($data as map(*),$dest as xs:string)
 | 
			
		||||
as empty-sequence(){
 | 
			
		||||
  let $opts := map {  "format":"xquery", "header":"yes", "separator" : "," }
 | 
			
		||||
  return file:write-text($dest,csv:serialize($data,$opts))
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ true if $pdf has Labels :)
 | 
			
		||||
declare function pdfbox:hasLabels($pdf as item())
 | 
			
		||||
as xs:boolean{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  =>exists()
 | 
			
		||||
(:~ number of outline items :)
 | 
			
		||||
declare function pdfbox:number-of-bookmarks($pdf as item())
 | 
			
		||||
as xs:integer{
 | 
			
		||||
  let $xml:=pdfbox:outline-xml($pdf)
 | 
			
		||||
  return count($xml//bookmark)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ XMP metadata as "RDF" document
 | 
			
		||||
| 
						 | 
				
			
			@ -371,21 +377,92 @@ as xs:base64Binary
 | 
			
		|||
    return (pdfbox:binary($a),pdfbox:close($a)) 
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ The number of labels defined in PDF  :)
 | 
			
		||||
declare function pdfbox:number-of-labels($pdf as item())
 | 
			
		||||
as xs:integer
 | 
			
		||||
{
 | 
			
		||||
  let $labels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
               =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return if(exists($labels)) 
 | 
			
		||||
         then PDPageLabels:getPageRangeCount($labels)
 | 
			
		||||
         else 0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~   pageLabel for every page or empty if none
 | 
			
		||||
(:~   pageLabel for every page from derived from page-ranges
 | 
			
		||||
The returned sequence will contain at MOST as much entries as the document has pages.
 | 
			
		||||
@see https://www.w3.org/TR/WCAG20-TECHS/PDF17.html#PDF17-examples
 | 
			
		||||
@see https://codereview.stackexchange.com/questions/286078/java-code-showing-page-labels-from-pdf-files
 | 
			
		||||
:)
 | 
			
		||||
declare function pdfbox:labels($pdf as item())
 | 
			
		||||
declare function pdfbox:labels-by-page($pdf as item())
 | 
			
		||||
as xs:string*
 | 
			
		||||
{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  =>PDPageLabels:getLabelsByPageIndices()
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ sequence of label ranges defined in PDF as formatted strings :)
 | 
			
		||||
declare function pdfbox:labels-as-strings($pdf as item())
 | 
			
		||||
as xs:string{
 | 
			
		||||
  let $pagelabels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
                   =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return if(exists($pagelabels))
 | 
			
		||||
         then PDPageLabels:getLabelsByPageIndices($pagelabels)
 | 
			
		||||
         else ()
 | 
			
		||||
  return $pagelabels
 | 
			
		||||
         !(0 to pdfbox:number-of-pages($pdf)-1)
 | 
			
		||||
         !pdfbox:label-as-string($pagelabels,.)=>string-join(",")
 | 
			
		||||
            
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ get pagelabels exist :)
 | 
			
		||||
declare function pdfbox:page-labels($pdf)
 | 
			
		||||
{
 | 
			
		||||
  PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
  =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ label for $page formated as string :)
 | 
			
		||||
declare function pdfbox:label-as-string($pagelabels,$page as  xs:integer)
 | 
			
		||||
as xs:string?{
 | 
			
		||||
  let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page)
 | 
			
		||||
  return  if(empty($label))
 | 
			
		||||
          then ()
 | 
			
		||||
          else
 | 
			
		||||
            let $start:=  PDPageLabelRange:getStart($label)
 | 
			
		||||
            let $style := PDPageLabelRange:getStyle($label)
 | 
			
		||||
            let $prefix:= PDPageLabelRange:getPrefix($label) 
 | 
			
		||||
            return string-join(($page, 
 | 
			
		||||
                                if(empty($style)) then "-" else $style,
 | 
			
		||||
                                if(($start eq 1)) then "" else $start,
 | 
			
		||||
                                if(exists($prefix)) then '*' || $prefix  (:TODO double " :)
 | 
			
		||||
                    ))
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ sequence of maps for each label in :)
 | 
			
		||||
declare function pdfbox:labels-as-map($pdf as item())
 | 
			
		||||
as map(*)*{
 | 
			
		||||
  let $pagelabels:=PDDocument:getDocumentCatalog($pdf)
 | 
			
		||||
                   =>PDDocumentCatalog:getPageLabels()
 | 
			
		||||
  return  $pagelabels
 | 
			
		||||
          !(0 to pdfbox:number-of-pages($pdf)-1)
 | 
			
		||||
          !pdfbox:label-as-map($pagelabels,.)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
(:~ express label/page-range for $page as map :)
 | 
			
		||||
declare function pdfbox:label-as-map($pagelabels,$page as  xs:integer)
 | 
			
		||||
as map(*)
 | 
			
		||||
{
 | 
			
		||||
  let $label:=PDPageLabels:getPageLabelRange($pagelabels,$page)
 | 
			
		||||
  return if(empty($label))
 | 
			
		||||
  then ()
 | 
			
		||||
  else map{
 | 
			
		||||
      "index": $page,
 | 
			
		||||
      "prefix": PDPageLabelRange:getPrefix($label),
 | 
			
		||||
      "start":  PDPageLabelRange:getStart($label),
 | 
			
		||||
      "style":  PDPageLabelRange:getStyle($label)
 | 
			
		||||
      }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
(:~ return text on $pageNo :)
 | 
			
		||||
declare function pdfbox:page-text($pdf as item(), $pageNo as xs:integer)
 | 
			
		||||
as xs:string{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue