-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,10 @@ Just import the dependencies and this tool. | |
<script src="https://unpkg.com/[email protected]/dist/forge.min.js" type="text/javascript"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/zgapdfsigner/dist/zgapdfsigner.min.js" type="text/javascript"></script> | ||
``` | ||
When using feature of drawing text, importing the fontkit library is necessary. | ||
```html | ||
<script src="https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.min.js" type="text/javascript"></script> | ||
``` | ||
|
||
### [Google Apps Script](https://developers.google.com/apps-script) | ||
Load the dependencies and this tool. | ||
|
@@ -64,6 +68,8 @@ function setTimeout(func, sleep){ | |
var window = globalThis; | ||
// Load pdf-lib | ||
eval(UrlFetchApp.fetch("https://unpkg.com/[email protected]/dist/pdf-lib.min.js").getContentText()); | ||
// It is necessary for drawing text feature. | ||
eval(UrlFetchApp.fetch("https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.min.js").getContentText()); | ||
// Load node-forge | ||
eval(UrlFetchApp.fetch("https://unpkg.com/[email protected]/dist/forge.min.js").getContentText()); | ||
// Load ZgaPdfSigner | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title> Test for ZgaPdfSigner </title> | ||
<script src="https://unpkg.com/[email protected]/dist/pdf-lib.min.js" type="text/javascript"></script> | ||
<script src="https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.min.js" type="text/javascript"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/forge.min.js" type="text/javascript"></script> | ||
<script src="dist/zgapdfsigner.min.js" type="text/javascript"></script> | ||
<script type="text/javascript"> | ||
|
@@ -63,6 +64,10 @@ | |
if(img){ | ||
imgType = getFilExt("img"); | ||
} | ||
/** @type {string} */ | ||
var txt = document.getElementById("txt").value; | ||
/** @type {ArrayBuffer} */ | ||
var font = await readFile("font"); | ||
|
||
/** @type {ArrayBuffer} */ | ||
var pubcert = await readFile("pubcert"); | ||
|
@@ -81,17 +86,30 @@ | |
contact: document.getElementById("tContact").value, | ||
debug: true, | ||
}; | ||
if(img){ | ||
if(img || txt){ | ||
sopt.drawinf = { | ||
area: { | ||
x: 25, // left | ||
y: 150, // top | ||
w: 60, | ||
h: 60, | ||
w: txt ? undefined : 60, | ||
h: txt ? undefined : 100, | ||
}, | ||
// pageidx: 2, | ||
imgData: img, | ||
imgType: imgType, | ||
pageidx: "-", | ||
imgInfo: img ? { | ||
imgData: img, | ||
imgType: imgType, | ||
} : undefined, | ||
textInfo: txt ? { | ||
text: txt, | ||
fontData: font, | ||
color: "f00", | ||
size: 16, | ||
align: 2, | ||
wMax: 80, | ||
yOffset: 10, | ||
xOffset: 20, | ||
noBreaks: "[あいうえおA-Za-z0-9]", | ||
} : undefined, | ||
}; | ||
} | ||
} | ||
|
@@ -145,7 +163,7 @@ | |
}); | ||
} | ||
function clearFiles(){ | ||
["fff","kkk","img","pubcert"].forEach((a_id) => { | ||
["fff","kkk","img","font","pubcert"].forEach((a_id) => { | ||
document.getElementById(a_id).value = ""; | ||
}); | ||
} | ||
|
@@ -187,6 +205,8 @@ | |
<label>certificate </label><input type="file" id="kkk" /><br /> | ||
<label>passphrase </label><input type="password" id="pwd" /><br /> | ||
<label>signature image </label><input type="file" id="img" /><br /> | ||
<label>signature text </label><input type="text" id="txt" /><br /> | ||
<label>text font </label><input type="file" id="font" /><br /> | ||
<label>permission </label> | ||
<select id="sperm" onchange="changeSperm()"> | ||
<option value="0">No DocMDP</option> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters