Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
168527573c | |||
3d7bb37849 | |||
12a581ced9 | |||
857e1717a5 | |||
186bfb9d12 | |||
c5bc354f65 | |||
c48bb0428f | |||
46fbb615a0 | |||
3df4e103f9 | |||
addff418c6 | |||
14d653e701 | |||
040bac5256 | |||
bf44901a0a |
@ -119,6 +119,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npmci node install stable
|
npmci node install stable
|
||||||
npmci npm install
|
npmci npm install
|
||||||
pnpm install -g @gitzone/tsdoc
|
pnpm install -g @git.zone/tsdoc
|
||||||
npmci command tsdoc
|
npmci command tsdoc
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
110
changelog.md
Normal file
110
changelog.md
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-11-30 - 3.1.8 - fix(core)
|
||||||
|
Fix candidate handling in PDF generation
|
||||||
|
|
||||||
|
- Added error handling for missing PDF candidates in server requests.
|
||||||
|
- Updated devDependencies and dependencies to latest versions for better stability and new features.
|
||||||
|
- Patched header retrieval logic during PDF generation for security check.
|
||||||
|
|
||||||
|
## 2024-09-27 - 3.1.7 - fix(dependencies)
|
||||||
|
Update dependencies to latest versions
|
||||||
|
|
||||||
|
- Updated @git.zone/tsbuild to version ^2.1.84
|
||||||
|
- Updated @git.zone/tsdoc to version ^1.3.12
|
||||||
|
- Updated @git.zone/tsrun to version ^1.2.49
|
||||||
|
- Updated @push.rocks/tapbundle to version ^5.3.0
|
||||||
|
- Updated @types/node to version ^22.7.4
|
||||||
|
- Updated @push.rocks/smartfile to version ^11.0.21
|
||||||
|
- Updated @push.rocks/smartpromise to version ^4.0.4
|
||||||
|
- Updated @tsclass/tsclass to version ^4.1.2
|
||||||
|
- Updated express to version ^4.21.0
|
||||||
|
- Updated pdf2pic to version ^3.1.3
|
||||||
|
|
||||||
|
## 2024-05-29 - 3.1.6 - Core
|
||||||
|
Updated description
|
||||||
|
|
||||||
|
- Minor changes to documentation and internal text.
|
||||||
|
|
||||||
|
## 2024-04-25 to 2024-04-30 - 3.1.0 to 3.1.5 - Core
|
||||||
|
Fix updates in core functionality
|
||||||
|
|
||||||
|
- Fixes and updates in core function in versions 3.1.0 to 3.1.5.
|
||||||
|
|
||||||
|
## 2024-04-25 - 3.0.17 - Feature
|
||||||
|
Now supports PDF to JPG conversion
|
||||||
|
|
||||||
|
- Added support for converting PDF files to JPG format.
|
||||||
|
|
||||||
|
## 2024-03-19 to 2024-04-14 - 3.0.17 - Maintenance
|
||||||
|
Various updates to project configuration files
|
||||||
|
|
||||||
|
- Updated `tsconfig`.
|
||||||
|
- Updated `npmextra.json`.
|
||||||
|
|
||||||
|
## 2023-07-11 to 2024-03-19 - 3.0.15 to 3.0.16 - Organization
|
||||||
|
Switch to new organization scheme and core updates
|
||||||
|
|
||||||
|
- Switched to new organization scheme.
|
||||||
|
- Applied core updates and bug fixes.
|
||||||
|
|
||||||
|
## 2022-11-07 to 2023-07-10 - 3.0.13 to 3.0.14 - Core
|
||||||
|
Fixes and updates to core functionality
|
||||||
|
|
||||||
|
- Various minor bug fixes and updates to core components.
|
||||||
|
|
||||||
|
## 2022-09-13 to 2022-11-07 - 3.0.10 to 3.0.12 - Core
|
||||||
|
Ongoing core updates and maintenance
|
||||||
|
|
||||||
|
- Regular fixes and operational improvements in core functionalities.
|
||||||
|
|
||||||
|
## 2022-06-12 to 2022-09-13 - 3.0.7 to 3.0.9 - Core
|
||||||
|
Continued focus on high-priority bug fixes and core functionalities
|
||||||
|
|
||||||
|
- Regular fixes for critical bugs and enhancements.
|
||||||
|
|
||||||
|
## 2022-03-24 to 2022-06-29 - 3.0.3 to 3.0.6 - Core
|
||||||
|
Further optimization and maintenance releases
|
||||||
|
|
||||||
|
- Further improvements and refinements of issues in core functionalities.
|
||||||
|
|
||||||
|
## 2022-01-05 to 2022-03-25 - 3.0.0 to 3.0.2 - Major Version Release
|
||||||
|
Major release for version 3.0.x, including core fixes
|
||||||
|
|
||||||
|
- Increased version from 2.x to 3.0. New significant changes and fixes.
|
||||||
|
|
||||||
|
## 2022-01-05 to 2022-03-24 - 2.0.13 to 2.0.19 - Core
|
||||||
|
Routine core updates and bug fixes
|
||||||
|
|
||||||
|
- Regular bug fixes in core components.
|
||||||
|
|
||||||
|
## 2019-11-19 to 2022-01-06 - 2.0.0 to 2.0.11 - Core
|
||||||
|
Multiple core updates and a few performance improvements
|
||||||
|
|
||||||
|
- Some performance enhancements and multiple bug fixes.
|
||||||
|
|
||||||
|
## 2019-11-16 to 2019-11-19 - 1.0.27 to 1.0.29 - API
|
||||||
|
Breaking change in API
|
||||||
|
|
||||||
|
- Naming PDF results to better represent their content.
|
||||||
|
|
||||||
|
## 2019-05-29 to 2019-11-15 - 1.0.13 to 1.0.26 - Core
|
||||||
|
Core functional updates and some major restructuring
|
||||||
|
|
||||||
|
- Introduced multiple updates to the core, addressing bugs and improving stability.
|
||||||
|
|
||||||
|
## 2019-04-10 to 2019-05-28 - 1.0.4 to 1.0.12 - Core
|
||||||
|
Fixes and updates in the core
|
||||||
|
|
||||||
|
- Implementation of multiple essential fixes for core components.
|
||||||
|
|
||||||
|
## 2018-10-06 - 1.0.1 to 1.0.3 - Core and Typings
|
||||||
|
Initial implementation and core fixes
|
||||||
|
|
||||||
|
- Initial implementation of the project.
|
||||||
|
- Fixed compilation problems in typings.
|
||||||
|
|
||||||
|
## 2016-01-29 - unknown - Initial
|
||||||
|
Initial commit
|
||||||
|
|
||||||
|
- Initial commit for the project setup.
|
35
package.json
35
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartpdf",
|
"name": "@push.rocks/smartpdf",
|
||||||
"version": "3.1.2",
|
"version": "3.1.8",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.",
|
"description": "A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -14,28 +14,28 @@
|
|||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.66",
|
"@git.zone/tsbuild": "^2.2.0",
|
||||||
"@gitzone/tsdoc": "^1.1.12",
|
"@git.zone/tsdoc": "^1.4.2",
|
||||||
"@gitzone/tsrun": "^1.2.44",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@gitzone/tstest": "^1.0.77",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@push.rocks/tapbundle": "^5.0.23",
|
"@push.rocks/tapbundle": "^5.5.3",
|
||||||
"@types/node": "^20.12.7"
|
"@types/node": "^22.10.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartbuffer": "^3.0.4",
|
"@push.rocks/smartbuffer": "^3.0.4",
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartfile": "^11.0.14",
|
"@push.rocks/smartfile": "^11.0.21",
|
||||||
"@push.rocks/smartnetwork": "^3.0.0",
|
"@push.rocks/smartnetwork": "^3.0.0",
|
||||||
"@push.rocks/smartpath": "^5.0.18",
|
"@push.rocks/smartpath": "^5.0.18",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.0.4",
|
||||||
"@push.rocks/smartpuppeteer": "^2.0.2",
|
"@push.rocks/smartpuppeteer": "^2.0.2",
|
||||||
"@push.rocks/smartunique": "^3.0.9",
|
"@push.rocks/smartunique": "^3.0.9",
|
||||||
"@tsclass/tsclass": "^4.0.54",
|
"@tsclass/tsclass": "^4.1.2",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^5.0.0",
|
||||||
"express": "^4.19.2",
|
"express": "^4.21.1",
|
||||||
"pdf-lib": "^1.17.1",
|
"pdf-lib": "^1.17.1",
|
||||||
"pdf2json": "^3.0.5",
|
"pdf2json": "3.1.4",
|
||||||
"pdf2pic": "^3.1.1"
|
"pdf2pic": "^3.1.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@ -65,5 +65,10 @@
|
|||||||
"PDF merging",
|
"PDF merging",
|
||||||
"text extraction",
|
"text extraction",
|
||||||
"PDF management"
|
"PDF management"
|
||||||
]
|
],
|
||||||
|
"homepage": "https://code.foss.global/push.rocks/smartpdf",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.foss.global/push.rocks/smartpdf.git"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
10929
pnpm-lock.yaml
generated
10929
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -55,8 +55,8 @@ tap.test('should merge pdfs', async () => {
|
|||||||
|
|
||||||
tap.test('should create images from an pdf', async () => {
|
tap.test('should create images from an pdf', async () => {
|
||||||
const pdfObject = await testSmartPdf.readFileToPdfObject('.nogit/combined.pdf');
|
const pdfObject = await testSmartPdf.readFileToPdfObject('.nogit/combined.pdf');
|
||||||
const images = await testSmartPdf.convertPDFToJPGBytes(pdfObject.buffer);
|
const images = await testSmartPdf.convertPDFToPngBytes(pdfObject.buffer);
|
||||||
console.log(images);
|
console.log(images.map((val) => val.length));
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should be able to close properly', async () => {
|
tap.test('should be able to close properly', async () => {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartpdf',
|
name: '@push.rocks/smartpdf',
|
||||||
version: '3.1.2',
|
version: '3.1.8',
|
||||||
description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.'
|
description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.'
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,13 @@ export class SmartPdf {
|
|||||||
// setup server
|
// setup server
|
||||||
const app = plugins.express();
|
const app = plugins.express();
|
||||||
app.get('/:pdfId', (req, res) => {
|
app.get('/:pdfId', (req, res) => {
|
||||||
res.setHeader('PDF-ID', this._candidates[req.params.pdfId].pdfId);
|
const wantedCandidate = this._candidates[req.params.pdfId];
|
||||||
res.send(this._candidates[req.params.pdfId].htmlString);
|
if (!wantedCandidate) {
|
||||||
|
console.log(`${req.url} not attached to a candidate`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.setHeader('pdf-id', wantedCandidate.pdfId);
|
||||||
|
res.send(wantedCandidate.htmlString);
|
||||||
});
|
});
|
||||||
this.htmlServerInstance = plugins.http.createServer(app);
|
this.htmlServerInstance = plugins.http.createServer(app);
|
||||||
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
|
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
|
||||||
@ -84,7 +89,6 @@ export class SmartPdf {
|
|||||||
const response = await page.goto(`http://localhost:3210/${pdfCandidate.pdfId}`, {
|
const response = await page.goto(`http://localhost:3210/${pdfCandidate.pdfId}`, {
|
||||||
waitUntil: 'networkidle2',
|
waitUntil: 'networkidle2',
|
||||||
});
|
});
|
||||||
// await plugins.smartdelay.delayFor(1000);
|
|
||||||
const headers = response.headers();
|
const headers = response.headers();
|
||||||
if (headers['pdf-id'] !== pdfCandidate.pdfId) {
|
if (headers['pdf-id'] !== pdfCandidate.pdfId) {
|
||||||
console.log('Error! Headers do not match. For security reasons no pdf is being emitted!');
|
console.log('Error! Headers do not match. For security reasons no pdf is being emitted!');
|
||||||
@ -225,14 +229,14 @@ export class SmartPdf {
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async convertPDFToJPGBytes(
|
public async convertPDFToPngBytes(
|
||||||
pdfBytes: Uint8Array,
|
pdfBytes: Uint8Array,
|
||||||
options: {
|
options: {
|
||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
quality?: number;
|
quality?: number;
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<Uint8Array[]> {
|
) {
|
||||||
const { width = 1024, height = 768, quality = 100 } = options;
|
const { width = 1024, height = 768, quality = 100 } = options;
|
||||||
|
|
||||||
// Load the PDF document
|
// Load the PDF document
|
||||||
@ -240,7 +244,7 @@ export class SmartPdf {
|
|||||||
|
|
||||||
const converter = plugins.pdf2pic.fromBuffer(Buffer.from(pdfBytes), {
|
const converter = plugins.pdf2pic.fromBuffer(Buffer.from(pdfBytes), {
|
||||||
density: 100, // Image density (DPI)
|
density: 100, // Image density (DPI)
|
||||||
format: 'jpg', // Image format
|
format: 'png', // Image format
|
||||||
width, // Output image width
|
width, // Output image width
|
||||||
height, // Output image height
|
height, // Output image height
|
||||||
quality, // Output image quality
|
quality, // Output image quality
|
||||||
@ -257,6 +261,8 @@ export class SmartPdf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve all promises and return the array of buffers
|
// Resolve all promises and return the array of buffers
|
||||||
return Promise.all(imagePromises);
|
const imageBuffers = await Promise.all(imagePromises);
|
||||||
|
const imageUint8Arrays = imageBuffers.map((buffer) => buffer);
|
||||||
|
return imageUint8Arrays;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user