html-to-pdf-headless 2.0.0 → 2.0.2
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.
- package/index.js +10 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,7 +9,16 @@ createpdfdependency.vfs = pdfFonts.pdfMake.vfs;
|
|
|
9
9
|
|
|
10
10
|
// Load standard PDF font AFM data into the virtual file system.
|
|
11
11
|
// This enables Times (serif), Courier (monospace), and Helvetica (sans-serif).
|
|
12
|
-
|
|
12
|
+
// Use require.resolve to find pdfkit regardless of where npm hoists it.
|
|
13
|
+
var pdfkitEntry = require.resolve("pdfkit");
|
|
14
|
+
var afmDir = path.join(path.dirname(pdfkitEntry), "data");
|
|
15
|
+
// Fallback: if the resolved path doesn't contain the data dir, try standard layout
|
|
16
|
+
if (!fs.existsSync(afmDir)) {
|
|
17
|
+
afmDir = path.join(path.dirname(pdfkitEntry), "..", "data");
|
|
18
|
+
}
|
|
19
|
+
if (!fs.existsSync(afmDir)) {
|
|
20
|
+
afmDir = path.join(__dirname, "node_modules", "pdfkit", "js", "data");
|
|
21
|
+
}
|
|
13
22
|
var afmFiles = [
|
|
14
23
|
"Courier.afm", "Courier-Bold.afm", "Courier-Oblique.afm", "Courier-BoldOblique.afm",
|
|
15
24
|
"Helvetica.afm", "Helvetica-Bold.afm", "Helvetica-Oblique.afm", "Helvetica-BoldOblique.afm",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-to-pdf-headless",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Generate PDF and DOCX files from HTML strings without headless browsers. Uses JSDOM, html-to-pdfmake, pdfmake, and docx under the hood.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Abhinay Sharma <panchalabhinay@gmail.com>",
|