nwjs and pdf-lib #1019
Lex-talionis
started this conversation in
General
Replies: 1 comment
-
Sorry, waste of text figured it out must of been a late night. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Guys,
I've mainly been using this library in node js to manipulate pdf without ever needing to render them. I'm expanding into an app now using NWJS and although i have followed the examples in the web directory i'm coming across the following error.
keywords
must be of typeArray
, but was actually of typeundefined
This to me looks like the syntax as im using the browser code in the js files im using in the view.
for example this is my view
<title>Test 18</title> <script type="text/javascript" src="https://unpkg.com/@pdf-lib/fontkit/dist/fontkit.umd.js" ></script>and this is my js file
`const PDFLib = require ("pdf-lib");
const fetchBinaryAsset = (asset) =>
fetch(
/assets/${asset}
).then((res) => res.arrayBuffer());const fetchStringAsset = (asset) =>
fetch(
/assets/${asset}
).then((res) => res.text());const renderInIframe = (pdfBytes) => {
const blob = new Blob([pdfBytes], { type: 'application/pdf' });
const blobUrl = URL.createObjectURL(blob);
document.getElementById('iframe').src = blobUrl;
};
const ipsumLines = [
'Eligendi est pariatur quidem in non excepturi et.',
'Consectetur non tenetur magnam est corporis tempor.',
'Labore nisi officiis quia ipsum qui voluptatem omnis.',
];
// This test creates a new PDF document and inserts pages to it.
// Each page is testing different features of pdf-lib.
async function test() {
const {
clip,
clipEvenOdd,
closePath,
cmyk,
degrees,
drawRectangle,
endPath,
grayscale,
LineCapStyle,
setLineJoin,
LineJoinStyle,
typedArrayFor,
lineTo,
moveTo,
PDFDocument,
popGraphicsState,
pushGraphicsState,
rgb,
StandardFonts,
AFRelationship,
} = PDFLib;
}`
im sure it something silly but would appriecate a nudge in the right directions.
Beta Was this translation helpful? Give feedback.
All reactions