[mod] tidy
This commit is contained in:
		
							parent
							
								
									301303b4d6
								
							
						
					
					
						commit
						196ffa7526
					
				
					 6 changed files with 39 additions and 18 deletions
				
			
		
							
								
								
									
										1
									
								
								.vscode/settings.json
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.vscode/settings.json
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    "basexTools.xquery.profile": "basex-10",
 | 
					    "basexTools.xquery.profile": "basex-10",
 | 
				
			||||||
    "basexTools.xquery.showHovers": false,
 | 
					    "basexTools.xquery.showHovers": false,
 | 
				
			||||||
 | 
					    "basexTools.xquery.executionDefault": "basexclient",
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										2
									
								
								.xqdoca
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								.xqdoca
									
										
									
									
									
								
							| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
<xqdoca xmlns="urn:quodatum:xqdoca" version="1.0">
 | 
					<xqdoca xmlns="urn:quodatum:xqdoca" version="1.0">
 | 
				
			||||||
    <source>jars/</source>
 | 
					    <source>src/</source>
 | 
				
			||||||
    <target>docs/xqdoc/</target>
 | 
					    <target>docs/xqdoc/</target>
 | 
				
			||||||
</xqdoca>
 | 
					</xqdoca>
 | 
				
			||||||
							
								
								
									
										1
									
								
								docs/pdf.xqbk
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								docs/pdf.xqbk
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					{"cells":[{"kind":2,"language":"xquery","value":"import module namespace pdfbox=\"org.expkg_zone58.Pdfbox3\";\r\nlet $a:=pdfbox:open(\"C:\\Users\\mrwhe\\git\\expkg-zone58\\pdfbox\\data\\1e\\gpg-book\\2-5-1\\B4541C-TRD\\255894---Book_File-Web_PDF_9798400668005_486272.pdf\")\r\nreturn pdfbox:labels($a)"}]}
 | 
				
			||||||
							
								
								
									
										10
									
								
								package.json
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
										
									
									
									
								
							| 
						 | 
					@ -22,11 +22,11 @@
 | 
				
			||||||
  "expkg_zone58": {
 | 
					  "expkg_zone58": {
 | 
				
			||||||
    "namespace": "org.expkg_zone58.Pdfbox3",
 | 
					    "namespace": "org.expkg_zone58.Pdfbox3",
 | 
				
			||||||
    "main-class": "org.apache.pdfbox.pdmodel.PDDocument",
 | 
					    "main-class": "org.apache.pdfbox.pdmodel.PDDocument",
 | 
				
			||||||
    "maven": [
 | 
					    "maven2": [
 | 
				
			||||||
      "org/apache/pdfbox/pdfbox/3.0.4/pdfbox-3.0.4.jar",
 | 
					      "org.apache.pdfbox:pdfbox:3.0.4",
 | 
				
			||||||
      "org/apache/pdfbox/pdfbox-io/3.0.4/pdfbox-io-3.0.4.jar",
 | 
					      "org.apache.pdfbox:pdfbox-io:3.0.4",
 | 
				
			||||||
      "org/apache/pdfbox/fontbox/3.0.4/fontbox-3.0.4.jar",
 | 
					      "org.apache.pdfbox:fontbox:3.0.4",
 | 
				
			||||||
      "commons-logging/commons-logging/1.3.4/commons-logging-1.3.4.jar"
 | 
					      "commons-logging:commons-logging:1.3.4"
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,7 +94,7 @@ as xs:string{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare function build:xar-create()
 | 
					declare function build:xar-create()
 | 
				
			||||||
as xs:base64Binary{
 | 
					as xs:base64Binary{
 | 
				
			||||||
  let $_:=build:maven-download($build:PKG?expkg_zone58?maven=>array:flatten(),$build:base || "jars/")
 | 
					  let $_:=build:maven-download($build:PKG?expkg_zone58?maven2=>array:flatten(),$build:base || "jars/")
 | 
				
			||||||
  let $entries:=
 | 
					  let $entries:=
 | 
				
			||||||
            build:xar-add(map{},build:jars("content"),build:jars("download")!build:content(.))
 | 
					            build:xar-add(map{},build:jars("content"),build:jars("download")!build:content(.))
 | 
				
			||||||
            =>build:xar-add("content/Pdfbox3.xqm",build:content("src/Pdfbox3.xqm"))
 | 
					            =>build:xar-add("content/Pdfbox3.xqm",build:content("src/Pdfbox3.xqm"))
 | 
				
			||||||
| 
						 | 
					@ -124,27 +124,45 @@ as xs:string{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare function build:jars($style as xs:string)
 | 
					declare function build:jars($style as xs:string)
 | 
				
			||||||
as xs:string*{
 | 
					as xs:string*{
 | 
				
			||||||
let $src:=$build:PKG?expkg_zone58?maven=>array:flatten()
 | 
					let $artifacts:=$build:PKG?expkg_zone58?maven2=>array:flatten()
 | 
				
			||||||
let $names:= $src!replace(.,"^.*/","")
 | 
					let $names:= $artifacts!build:maven-slug(.)!file:name(.)
 | 
				
			||||||
return switch($style)
 | 
					return switch($style)
 | 
				
			||||||
case "name" return $names
 | 
					case "name" return $names
 | 
				
			||||||
case "download" return $names!concat("jars/",.)
 | 
					case "download" return $names!concat("jars/",.)
 | 
				
			||||||
case "content" return $names!concat("content/",.)
 | 
					case "content" return $names!concat("content/",.)
 | 
				
			||||||
default return $src
 | 
					default return $names
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(:~ download $files from $urls to  $destdir:)
 | 
					(:~ download $files from $urls to  $destdir:)
 | 
				
			||||||
declare variable $build:REPO as xs:string external :="https://repo1.maven.org/maven2/";
 | 
					declare variable $build:REPO as xs:string external :="https://repo1.maven.org/maven2/";
 | 
				
			||||||
declare function build:maven-download($urls as xs:string*,$destdir as xs:string)
 | 
					
 | 
				
			||||||
 | 
					declare function build:maven-download($artifacts as xs:string*,$destdir as xs:string)
 | 
				
			||||||
as empty-sequence(){
 | 
					as empty-sequence(){
 | 
				
			||||||
    file:create-dir($destdir),    
 | 
					    file:create-dir($destdir),    
 | 
				
			||||||
    for $f in $urls
 | 
					    for $id in $artifacts
 | 
				
			||||||
    let $dest:=$destdir || replace($f,"^.*/","") 
 | 
					    let $slug:=build:maven-slug($id)
 | 
				
			||||||
 | 
					    let $dest:=$destdir || file:name($slug) 
 | 
				
			||||||
    where not(file:exists($dest))
 | 
					    where not(file:exists($dest))
 | 
				
			||||||
    return build:write-binary($dest, fetch:binary(resolve-uri($f,$build:REPO)
 | 
					    return build:write-binary($dest, fetch:binary(resolve-uri($slug,$build:REPO)
 | 
				
			||||||
           =>trace("Download: ")))
 | 
					           =>trace("Download: ")))
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(:~ non-rooted url for maven artifact :)
 | 
				
			||||||
 | 
					declare function build:maven-slug($artifact as xs:string)
 | 
				
			||||||
 | 
					as xs:string{
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					   let $parts:=if(matches($artifact,'[^:]+:[^:]+:[^:]+'))
 | 
				
			||||||
 | 
					               then tokenize($artifact,":")
 | 
				
			||||||
 | 
					               else error(xs:QName('build:maven-slug'),"invalid format required 'groupId:id:version'")
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					    return (
 | 
				
			||||||
 | 
					            translate($parts[1],".","/"),
 | 
				
			||||||
 | 
					            $parts[2],
 | 
				
			||||||
 | 
					            $parts[3],
 | 
				
			||||||
 | 
					            string-join(($parts[2] , "-" , $parts[3] , ".jar"),"")
 | 
				
			||||||
 | 
					    )=>string-join("/")
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(:~ write-binary, creating dir if required :)
 | 
					(:~ write-binary, creating dir if required :)
 | 
				
			||||||
declare function build:write-binary($dest as xs:string,$contents as xs:base64Binary?)
 | 
					declare function build:write-binary($dest as xs:string,$contents as xs:base64Binary?)
 | 
				
			||||||
as empty-sequence(){
 | 
					as empty-sequence(){
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,7 +98,7 @@ as xs:base64Binary{
 | 
				
			||||||
         =>convert:integers-to-base64()
 | 
					         =>convert:integers-to-base64()
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(: release references to $pdf:)
 | 
					(:~ release references to $pdf:)
 | 
				
			||||||
declare function pdfbox:close($pdf as item())
 | 
					declare function pdfbox:close($pdf as item())
 | 
				
			||||||
as empty-sequence(){
 | 
					as empty-sequence(){
 | 
				
			||||||
  (# db:wrapjava void #) {
 | 
					  (# db:wrapjava void #) {
 | 
				
			||||||
| 
						 | 
					@ -112,7 +112,7 @@ as xs:integer{
 | 
				
			||||||
  PDDocument:getNumberOfPages($pdf)
 | 
					  PDDocument:getNumberOfPages($pdf)
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(:~ render of $pdf page to image
 | 
					(:~ pdf page as image (zero is cover)
 | 
				
			||||||
options.format="bmp jpg png gif" etc, options.scale= 1 is 72 dpi?? :)
 | 
					options.format="bmp jpg png gif" etc, options.scale= 1 is 72 dpi?? :)
 | 
				
			||||||
declare function pdfbox:page-image($pdf as item(),$pageNo as xs:integer,$options as map(*))
 | 
					declare function pdfbox:page-image($pdf as item(),$pageNo as xs:integer,$options as map(*))
 | 
				
			||||||
as xs:base64Binary{
 | 
					as xs:base64Binary{
 | 
				
			||||||
| 
						 | 
					@ -284,6 +284,7 @@ as element(outline)?{
 | 
				
			||||||
         else ()
 | 
					         else ()
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(:~ recursive ouutline map to XML :)
 | 
				
			||||||
declare %private function pdfbox:bookmark-xml($outline as map(*)*)
 | 
					declare %private function pdfbox:bookmark-xml($outline as map(*)*)
 | 
				
			||||||
as element(bookmark)*
 | 
					as element(bookmark)*
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -355,7 +356,7 @@ as xs:string{
 | 
				
			||||||
  return (# db:checkstrings #) {PDFTextStripper:getText($tStripper,$pdf)}
 | 
					  return (# db:checkstrings #) {PDFTextStripper:getText($tStripper,$pdf)}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(:~ return size of $pageNo zero based :)
 | 
					(:~ return size of $pageNo (zero is cover :)
 | 
				
			||||||
declare function pdfbox:page-size($pdf as item(), $pageNo as xs:integer)
 | 
					declare function pdfbox:page-size($pdf as item(), $pageNo as xs:integer)
 | 
				
			||||||
as xs:string{
 | 
					as xs:string{
 | 
				
			||||||
  PDDocument:getPage($pdf, $pageNo)
 | 
					  PDDocument:getPage($pdf, $pageNo)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue