[add] image save
This commit is contained in:
parent
bd5b7cf006
commit
af2fac39b2
7 changed files with 66 additions and 7 deletions
|
|
@ -40,7 +40,7 @@ declare namespace PDDocumentInformation ="java:org.apache.pdfbox.pdmodel.PDDocum
|
|||
@see https://javadoc.io/static/org.apache.pdfbox/pdfbox/3.0.0/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.html
|
||||
:)
|
||||
declare namespace PDOutlineItem="java:org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem";
|
||||
|
||||
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";
|
||||
|
||||
|
|
@ -220,6 +220,7 @@ as xs:string*
|
|||
=>PDDocumentCatalog:getPageLabels()
|
||||
=>PDPageLabels:getLabelsByPageIndices()
|
||||
};
|
||||
|
||||
(:~ return text on $pageNo :)
|
||||
declare function pdfbox:getText($doc as item(), $pageNo as xs:integer)
|
||||
as xs:string{
|
||||
|
|
@ -231,6 +232,7 @@ as xs:string{
|
|||
return (# db:checkstrings #) {PDFTextStripper:getText($tStripper,$doc)}
|
||||
};
|
||||
|
||||
(:~ summary info as map for $pdfpath :)
|
||||
declare function pdfbox:report($pdfpath as xs:string)
|
||||
as map(*){
|
||||
let $doc:=pdfbox:open($pdfpath)
|
||||
|
|
@ -242,8 +244,17 @@ as map(*){
|
|||
)=>map:merge()
|
||||
};
|
||||
|
||||
(: @TODO :)
|
||||
declare function pdfbox:pageAsImage($doc as item(), $pageNo as xs:integer)
|
||||
(:~ page (ZERO based) as image
|
||||
@param $scale 1=72 dpi :)
|
||||
declare function pdfbox:pageAsImage($doc as item(), $pageNo as xs:integer,$scale as xs:float)
|
||||
as item(){
|
||||
(: BufferedImage image = pdfRenderer.renderImageWithDPI(i, 200, ImageType.RGB) :)
|
||||
PDFRenderer:new($doc)
|
||||
=>PDFRenderer:renderImage($pageNo,$scale)
|
||||
};
|
||||
|
||||
(:~ save bufferedimage to $dest
|
||||
@param $type = "gif","png" etc:)
|
||||
declare function pdfbox:imageSave($bufferedImage as item(),$dest as xs:string,$type as xs:string)
|
||||
as xs:boolean{
|
||||
Q{java:javax.imageio.ImageIO}write($bufferedImage , $type, File:new($dest))
|
||||
};
|
||||
|
|
|
|||
8
src/scratch/abc2.xq
Normal file
8
src/scratch/abc2.xq
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
declare variable $samples:= map{
|
||||
"climate": "data\drop-01d\set\2-6-1\A5579C_1\271989---Book_File-Web_PDF_9798400627484_486728.pdf",
|
||||
"women": "data\drop-01d\set\2-6-1\A6229C_1\257334---Book_File-Web_PDF_9798216172628_486742.pdf",
|
||||
"genocide": "data\drop1-pdf\GR2967-TRD\272791---Book_File-Web_PDF_9798400640216_486366.pdf",
|
||||
"world": "data\drop-01c\gpg-book\2-6\A3506C-TRD\256186---Book_File-Web_PDF_9798216038955_486148.pdf"
|
||||
};
|
||||
declare variable $base:= "C:\Users\mrwhe\git\bloomsbury\content-architecture\xquery\ABC-CLIO\data";
|
||||
42
|
||||
|
|
@ -6,6 +6,10 @@ html {
|
|||
padding: 0;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
}
|
||||
sl-card {
|
||||
display: flex;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.App {
|
||||
width: 800px;
|
||||
|
|
|
|||
32
src/webapp/pdf/static/user.html
Normal file
32
src/webapp/pdf/static/user.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<!doctype html>
|
||||
<script type="module">
|
||||
import { define, store, html } from 'https://esm.sh/hybrids@^8';
|
||||
|
||||
const User = {
|
||||
id: true,
|
||||
res: null,
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
[store.connect]: {
|
||||
get: id => fetch(`http://localhost:8080/pdf/api/sources`)
|
||||
.then(data => data.json())
|
||||
.then(res=> { "43"})
|
||||
},
|
||||
};
|
||||
|
||||
define({
|
||||
tag: "user-details",
|
||||
user: store(User),
|
||||
render: ({ user }) => html`
|
||||
<div>
|
||||
${store.pending(user) && `Loading...`}
|
||||
${store.error(user) && `Something went wrong...`}
|
||||
|
||||
${store.ready(user) && html`
|
||||
<p>${user.id} ${user.lastName}</p>
|
||||
`}
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
</script>
|
||||
<user-details user="2"></user-details>
|
||||
Loading…
Add table
Add a link
Reference in a new issue