@fto-consult/expo-ui 7.4.43 → 7.4.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
6
6
|
|
7
|
-
<title>PDF Viewer</title>
|
7
|
+
<title id="document-title">PDF Viewer</title>
|
8
8
|
|
9
9
|
<link rel="stylesheet" type="text/css" href="./viewer.css">
|
10
10
|
|
@@ -16,10 +16,16 @@
|
|
16
16
|
<script type="text/javascript">
|
17
17
|
const url = new URL(window.location.href);
|
18
18
|
const container = `#pdf-container`;
|
19
|
+
const title = document.querySelector(`document-title`)
|
19
20
|
// Get a URLSearchParams object from the URL object
|
20
21
|
const params = Object.assign({},url.searchParams);
|
21
22
|
params.width = params.width ||"100%";
|
22
23
|
params.height = params.height || "100%";
|
24
|
+
if(params.fileName && title){
|
25
|
+
title.innerHTML = `${params.fileName}`
|
26
|
+
} else if(params.title && title){
|
27
|
+
title.innerHTML = `${params.title}`
|
28
|
+
}
|
23
29
|
if(params.file){
|
24
30
|
PDFObject.embed(params.file,container,params);
|
25
31
|
} else if(params.dataURL){
|
package/electron/preload.js
CHANGED
@@ -12,6 +12,7 @@ const pathsStr = ipcRenderer.sendSync("get-paths.json");
|
|
12
12
|
const paths = typeof pathsStr ==='string' && pathsStr ? JSON.parse(pathsStr) : {};
|
13
13
|
const appName = ipcRenderer.sendSync("get-app-name");
|
14
14
|
const sanitize = require("sanitize-filename");
|
15
|
+
const uniqid = require("./utils/uniqid");
|
15
16
|
if(!appName || typeof appName !=='string'){
|
16
17
|
throw {message : "Nom de l'application invalide!! Veuillez spécifier un nom valide d'application"}
|
17
18
|
}
|
@@ -108,7 +109,7 @@ const createPDFFile = (options)=>{
|
|
108
109
|
return new Promise((resolve,reject)=>{
|
109
110
|
const dir = getPath("temp");
|
110
111
|
options = Object.assign({},options);
|
111
|
-
let {content,filename,fileName,charset,
|
112
|
+
let {content,filename,fileName,charset,fileExtension,extension} = options;
|
112
113
|
filename = defaultStr(filename,fileName)
|
113
114
|
if(isDataURL(content)){
|
114
115
|
content = isDataURL.toBase64(content);
|
@@ -383,7 +384,7 @@ const ELECTRON = {
|
|
383
384
|
return createPDFFile(options).then(({path,filePathUrl})=>{
|
384
385
|
const urlPath = path.resolve(__dirname,"pdf-viewer","viewer.html");
|
385
386
|
if(fs.existsSync(path)){
|
386
|
-
opts.loadURL = `file://${urlPath}?file=${decodeURIComponent(filePathUrl)}&locale=fr`;
|
387
|
+
opts.loadURL = `file://${urlPath}?file=${decodeURIComponent(filePathUrl)}&locale=fr&fileName=${fileName}`;
|
387
388
|
opts.showOnLoad = true;
|
388
389
|
console.log("will print url ",options.loadURL,options);
|
389
390
|
return this.createPDFWindow(opts)
|
package/electron/utils/index.js
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
// Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style
|
3
|
+
// license that can be found in the LICENSE file.
|
4
|
+
|
5
|
+
/***
|
6
|
+
* generate uid : uid(16) generate uid with 16 max characters
|
7
|
+
* uid("prefix",16) generate uid with max 16 chars and having prefix like prefix
|
8
|
+
*
|
9
|
+
* @param {type} prefix
|
10
|
+
* @param {type} idStrLen
|
11
|
+
* @param {type} separator
|
12
|
+
* @returns {String|Number|uid.idStr}
|
13
|
+
*/
|
14
|
+
module.exports = function uniqid (prefix,idStrLen,separator) {
|
15
|
+
if(typeof prefix == "number" & typeof idStrLen == "undefined"){
|
16
|
+
idStrLen = prefix
|
17
|
+
prefix = ""
|
18
|
+
}
|
19
|
+
separator = typeof separator =="string" && separator ? separator : "";
|
20
|
+
prefix = typeof prefix =="string" && prefix ? prefix : "";
|
21
|
+
if(typeof idStrLen !=='number') idStrLen = idStrLen-prefix.length;
|
22
|
+
if(idStrLen <= 0) idStrLen = 16;
|
23
|
+
idStrLen = Math.floor(idStrLen);
|
24
|
+
// always start with a letter -- base 36 makes for a nice shortcut
|
25
|
+
var idStr = prefix+(Math.floor((Math.random() * 25)) + 10).toString(36) + separator;
|
26
|
+
// add a timestamp in milliseconds (base 36 again) as the base
|
27
|
+
idStr += (new Date()).getTime().toString(36) + separator;
|
28
|
+
// similar to above, complete the Id using random, alphanumeric characters
|
29
|
+
do {
|
30
|
+
idStr += (Math.floor((Math.random() * 35))).toString(36);
|
31
|
+
} while (idStr.length < idStrLen);
|
32
|
+
return (idStr);
|
33
|
+
}
|
package/package.json
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
import {isElectron} from "$cplatform";
|
2
|
+
export default function print(pdfMakeInstance,options){
|
3
|
+
if(isElectron() && window?.ELECTRON && typeof window?.ELECTRON?.printPDF =='function'){
|
4
|
+
return pdfMakeInstance.getBase64((content)=>{
|
5
|
+
ELECTRON.printPDF({
|
6
|
+
...Object.assign({},options),
|
7
|
+
content,
|
8
|
+
})
|
9
|
+
})
|
10
|
+
}
|
11
|
+
return pdfMakeInstance.print();
|
4
12
|
}
|
package/src/pdf/print.web.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import {isElectron} from "$cplatform";
|
2
|
+
import electronPrint from "./print.electron";
|
2
3
|
export default function print(pdfMakeInstance,options,...rest){
|
3
|
-
if(isElectron()
|
4
|
-
return
|
4
|
+
if(isElectron()){
|
5
|
+
return electronPrint(pdfMakeInstance,options,...rest);
|
5
6
|
}
|
6
7
|
return pdfMakeInstance.print(options,...rest);
|
7
8
|
}
|