@jrmc/adonis-attachment 3.2.3 → 3.2.4
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.
|
@@ -30,6 +30,10 @@ export default class PdfThumbnailConverter extends Converter {
|
|
|
30
30
|
binPath = this.binPaths.pdftocairoBasePath;
|
|
31
31
|
}
|
|
32
32
|
const poppler = new Poppler(binPath);
|
|
33
|
+
const pdfInfo = await poppler.pdfInfo(input);
|
|
34
|
+
const pagesMatch = pdfInfo.match(/Pages:\s*(\d+)/);
|
|
35
|
+
const pageCount = pagesMatch ? parseInt(pagesMatch[1]) : 1;
|
|
36
|
+
const pageNumberFormat = '0'.repeat(String(pageCount).length - 1);
|
|
33
37
|
const options = {
|
|
34
38
|
// firstPageToConvert: 1,
|
|
35
39
|
lastPageToConvert: 1,
|
|
@@ -37,6 +41,6 @@ export default class PdfThumbnailConverter extends Converter {
|
|
|
37
41
|
};
|
|
38
42
|
const filePath = path.join(os.tmpdir(), cuid());
|
|
39
43
|
await poppler.pdfToCairo(input, filePath, options);
|
|
40
|
-
return filePath
|
|
44
|
+
return `${filePath}-${pageNumberFormat}1.jpg`;
|
|
41
45
|
}
|
|
42
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jrmc/adonis-attachment",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Turn any field on your Lucid model to an attachment data type",
|
|
6
6
|
"engines": {
|
|
@@ -114,8 +114,7 @@
|
|
|
114
114
|
]
|
|
115
115
|
},
|
|
116
116
|
"publishConfig": {
|
|
117
|
-
"access": "public"
|
|
118
|
-
"tag": "latest"
|
|
117
|
+
"access": "public"
|
|
119
118
|
},
|
|
120
119
|
"volta": {
|
|
121
120
|
"node": "20.17.0"
|