This commit is contained in:
parent
87c0a1611e
commit
a861c7e90c
5 changed files with 25 additions and 15 deletions
|
|
@ -28,10 +28,12 @@ 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";
|
||||
|
||||
(:~ version of Apacke Pdfbox in use :)
|
||||
(:~ version of this package
|
||||
with build metadata for Apacke Pdfbox in use e.g. "0.1.0+pdfbox3.0.4"
|
||||
:)
|
||||
declare function pdfbox:version()
|
||||
as xs:string{
|
||||
Q{java:org.apache.pdfbox.util.Version}getVersion()
|
||||
"0.1.0+pdfbox" || Q{java:org.apache.pdfbox.util.Version}getVersion()
|
||||
};
|
||||
|
||||
(:~ open pdf, returns pdf object :)
|
||||
|
|
@ -49,7 +51,7 @@ returned as string to avoid float rounding issues
|
|||
:)
|
||||
declare function pdfbox:specification($pdf as item())
|
||||
as xs:string{
|
||||
PDDocument:getVersion($pdf)=>xs:decimal()=>round(4)
|
||||
PDDocument:getVersion($pdf)=>xs:decimal()=>round(4)=>string()
|
||||
};
|
||||
|
||||
(:~ save pdf $pdf to $savepath , returns $savepath :)
|
||||
|
|
|
|||
|
|
@ -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,"3.0.4")
|
||||
return unit:assert-equals($v,"0.1.0+pdfbox3.0.4")
|
||||
};
|
||||
|
||||
declare %unit:test
|
||||
|
|
@ -49,11 +49,12 @@ function test:outline-xml(){
|
|||
};
|
||||
|
||||
declare %unit:test
|
||||
function test:pagelabels(){
|
||||
function test:labels(){
|
||||
let $pdf:=test:pdf("samples.pdf/BaseX100.pdf")
|
||||
|
||||
let $labels:=pdfbox:labels($pdf)
|
||||
let $labels:=pdfbox:labels($pdf)
|
||||
return (
|
||||
unit:assert-equals(count($labels),pdfbox:page-count($pdf)),
|
||||
unit:assert($labels[1]="i") ,
|
||||
unit:assert($labels[27]="1")
|
||||
)
|
||||
|
|
@ -74,6 +75,13 @@ let $pdf:=test:pdf("samples.pdf/BaseX100.pdf")
|
|||
return unit:assert(starts-with($text,"BaseX Documentation"))
|
||||
};
|
||||
|
||||
declare %unit:test
|
||||
function test:page-image(){
|
||||
let $pdf:=test:pdf("samples.pdf/BaseX100.pdf")
|
||||
let $image:=pdfbox:page-image($pdf,0,map{})
|
||||
return unit:assert(true())
|
||||
};
|
||||
|
||||
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