[mod] auto build
This commit is contained in:
parent
9da83b5e27
commit
fe687dd723
13 changed files with 124 additions and 96 deletions
|
|
@ -28,14 +28,13 @@ declare namespace PDFRenderer="java:org.apache.pdfbox.rendering.PDFRenderer";
|
|||
declare namespace RandomAccessReadBufferedFile = "java:org.apache.pdfbox.io.RandomAccessReadBufferedFile";
|
||||
declare namespace File ="java:java.io.File";
|
||||
|
||||
declare variable $pdfbox:package-version:="0.1.1";
|
||||
declare variable $pdfbox:package-version:="0.1.2";
|
||||
|
||||
(:~ SemVer version of this package
|
||||
with build metadata for Apache Pdfbox in use e.g. "0.1.0+pdfbox3.0.4"
|
||||
(:~ version of Apache Pdfbox in use e.g. "3.0.4"
|
||||
:)
|
||||
declare function pdfbox:version()
|
||||
as xs:string{
|
||||
$pdfbox:package-version ||"+pdfbox" || Q{java:org.apache.pdfbox.util.Version}getVersion()
|
||||
Q{java:org.apache.pdfbox.util.Version}getVersion()
|
||||
};
|
||||
|
||||
(:~ with-document pattern: open pdf,apply function, close pdf
|
||||
|
|
@ -49,7 +48,7 @@ as item()*{
|
|||
return try{
|
||||
$fn($pdf),pdfbox:close($pdf)
|
||||
} catch *{
|
||||
pdfbox:close($pdf),error()
|
||||
pdfbox:close($pdf),fn:error($err:code,$src || " " || $err:description)
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -189,14 +188,16 @@ as map(*){
|
|||
};
|
||||
|
||||
(:~ outline as xml :)
|
||||
declare function pdfbox:outline-xml($outline as map(*)*)
|
||||
as element(outline){
|
||||
declare function pdfbox:outline-xml($pdf as item())
|
||||
as element(outline)?{
|
||||
element outline {
|
||||
$outline!pdfbox:bookmark-xml(.)
|
||||
let $outline:=pdfbox:outline($pdf)
|
||||
return if(exists($outline))
|
||||
then <outline>{$outline!pdfbox:bookmark-xml(.)}</outline>
|
||||
}
|
||||
};
|
||||
|
||||
declare function pdfbox:bookmark-xml($outline as map(*)*)
|
||||
declare %private function pdfbox:bookmark-xml($outline as map(*)*)
|
||||
as element(bookmark)*
|
||||
{
|
||||
$outline!
|
||||
|
|
@ -208,11 +209,11 @@ as element(bookmark)*
|
|||
(:~ return bookmark info for children of $outlineItem
|
||||
@return map like{index:,title:,hasChildren:}
|
||||
:)
|
||||
declare function pdfbox:bookmark($bookmark as item(),$pdf as item())
|
||||
declare %private function pdfbox:bookmark($bookmark as item(),$pdf as item())
|
||||
as map(*)
|
||||
{
|
||||
map{
|
||||
"index": PDOutlineItem:findDestinationPage($bookmark,$pdf)=>pdfbox:page-index($pdf),
|
||||
"index": PDOutlineItem:findDestinationPage($bookmark,$pdf)=>pdfbox:find-page($pdf),
|
||||
"title": (# db:checkstrings #) {PDOutlineItem:getTitle($bookmark)}
|
||||
(:=>translate("<22>",""), :),
|
||||
"hasChildren": PDOutlineItem:hasChildren($bookmark)
|
||||
|
|
@ -221,7 +222,7 @@ as map(*)
|
|||
|
||||
|
||||
(:~ pageIndex of $page in $pdf :)
|
||||
declare function pdfbox:page-index(
|
||||
declare function pdfbox:find-page(
|
||||
$page as item()? (: as java:org.apache.pdfbox.pdmodel.PDPage :),
|
||||
$pdf as item())
|
||||
as item()?
|
||||
|
|
@ -268,8 +269,6 @@ as xs:string{
|
|||
return (# db:checkstrings #) {PDFTextStripper:getText($tStripper,$doc)}
|
||||
};
|
||||
|
||||
|
||||
|
||||
(:~ convert date :)
|
||||
declare %private
|
||||
function pdfbox:gregToISO($item as item())
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
<package xmlns="http://www.basex.org/modules/pkg">
|
||||
<jar>pdfbox-3.0.4.jar</jar>
|
||||
<jar>pdfbox-io-3.0.4.jar</jar>
|
||||
<jar>fontbox-3.0.4.jar</jar>
|
||||
<jar>commons-logging-1.3.4.jar</jar>
|
||||
<class>org.apache.pdfbox.pdmodel.PDDocument</class>
|
||||
</package>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<package xmlns="http://expath.org/ns/pkg"
|
||||
name="org.expkg_zone58.Pdfbox3"
|
||||
abbrev="pdfbox"
|
||||
version="0.1.1"
|
||||
spec="1.0">
|
||||
|
||||
<title>BaseX interface to Pdfbox (https://pdfbox.apache.org/) version 3</title>
|
||||
<dependency processor="basex" name="value"/>
|
||||
<xquery>
|
||||
<namespace>org.expkg_zone58.Pdfbox3</namespace>
|
||||
<file>Pdfbox3.xqm</file>
|
||||
</xquery>
|
||||
</package>
|
||||
|
|
@ -10,7 +10,7 @@ declare variable $test:base:=file:base-dir()=>file:parent()=>file:parent();
|
|||
declare %unit:test
|
||||
function test:pdfbox-version(){
|
||||
let $v:= pdfbox:version()=>trace("VER: ")
|
||||
return unit:assert-equals($v,"0.1.0+pdfbox3.0.4")
|
||||
return unit:assert-equals($v,"3.0.4")
|
||||
};
|
||||
|
||||
declare %unit:test
|
||||
|
|
@ -44,7 +44,7 @@ function test:outline-present(){
|
|||
declare %unit:test
|
||||
function test:outline-xml(){
|
||||
let $pdf:=test:pdf("samples.pdf/icelandic-dictionary.pdf")
|
||||
let $outline:=pdfbox:outline($pdf)=>pdfbox:outline-xml()
|
||||
let $outline:=pdfbox:outline-xml($pdf)
|
||||
return unit:assert-equals(count($outline/bookmark),31)
|
||||
};
|
||||
|
||||
|
|
@ -82,6 +82,13 @@ function test:page-image(){
|
|||
return unit:assert(true())
|
||||
};
|
||||
|
||||
declare %unit:test
|
||||
function test:pdf-with(){
|
||||
let $path:=test:pdf("samples.pdf/BaseX100.pdf")
|
||||
let $txt:=pdfbox:with-pdf($path,pdfbox:page-text(?,101))
|
||||
return unit:assert-equals($txt,"Options")
|
||||
};
|
||||
|
||||
declare function test:pdf($file as xs:string)
|
||||
as item(){
|
||||
file:resolve-path($file,$test:base)=>pdfbox:open()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue