Compare commits

..

15 Commits

Author SHA1 Message Date
168527573c 3.1.8 2024-11-30 20:43:05 +01:00
3d7bb37849 fix(core): Fix candidate handling in PDF generation 2024-11-30 20:43:05 +01:00
12a581ced9 3.1.7 2024-09-27 23:21:31 +02:00
857e1717a5 fix(dependencies): Update dependencies to latest versions 2024-09-27 23:21:30 +02:00
186bfb9d12 update description 2024-05-29 14:15:22 +02:00
c5bc354f65 3.1.6 2024-04-30 17:48:12 +02:00
c48bb0428f fix(core): update 2024-04-30 17:48:11 +02:00
46fbb615a0 3.1.5 2024-04-27 12:07:16 +02:00
3df4e103f9 fix(core): update 2024-04-27 12:07:16 +02:00
addff418c6 3.1.4 2024-04-26 13:39:58 +02:00
14d653e701 fix(core): update 2024-04-26 13:39:57 +02:00
040bac5256 3.1.3 2024-04-26 13:29:32 +02:00
bf44901a0a fix(core): update 2024-04-26 13:29:32 +02:00
b4d0f4e949 3.1.2 2024-04-26 13:28:07 +02:00
b2b47b1f6a fix(core): update 2024-04-26 13:28:07 +02:00
7 changed files with 8042 additions and 3062 deletions

View File

@ -119,6 +119,6 @@ jobs:
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

110
changelog.md Normal file
View 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.

View File

@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartpdf",
"version": "3.1.1",
"version": "3.1.8",
"private": false,
"description": "A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.",
"main": "dist_ts/index.js",
@ -14,28 +14,28 @@
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsdoc": "^1.1.12",
"@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.23",
"@types/node": "^20.12.7"
"@git.zone/tsbuild": "^2.2.0",
"@git.zone/tsdoc": "^1.4.2",
"@git.zone/tsrun": "^1.3.3",
"@git.zone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.5.3",
"@types/node": "^22.10.1"
},
"dependencies": {
"@push.rocks/smartbuffer": "^3.0.4",
"@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/smartpath": "^5.0.18",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartpromise": "^4.0.4",
"@push.rocks/smartpuppeteer": "^2.0.2",
"@push.rocks/smartunique": "^3.0.9",
"@tsclass/tsclass": "^4.0.54",
"@types/express": "^4.17.21",
"express": "^4.19.2",
"@tsclass/tsclass": "^4.1.2",
"@types/express": "^5.0.0",
"express": "^4.21.1",
"pdf-lib": "^1.17.1",
"pdf2json": "^3.0.5",
"pdf2pic": "^3.1.1"
"pdf2json": "3.1.4",
"pdf2pic": "^3.1.3"
},
"files": [
"ts/**/*",
@ -65,5 +65,10 @@
"PDF merging",
"text extraction",
"PDF management"
]
],
"homepage": "https://code.foss.global/push.rocks/smartpdf",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartpdf.git"
}
}

10871
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -55,8 +55,8 @@ tap.test('should merge pdfs', async () => {
tap.test('should create images from an pdf', async () => {
const pdfObject = await testSmartPdf.readFileToPdfObject('.nogit/combined.pdf');
const images = await testSmartPdf.convertPDFToJPGBytes(pdfObject.buffer);
console.log(images);
const images = await testSmartPdf.convertPDFToPngBytes(pdfObject.buffer);
console.log(images.map((val) => val.length));
});
tap.test('should be able to close properly', async () => {

View File

@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartpdf',
version: '3.1.1',
version: '3.1.8',
description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.'
}

View File

@ -41,8 +41,13 @@ export class SmartPdf {
// setup server
const app = plugins.express();
app.get('/:pdfId', (req, res) => {
res.setHeader('PDF-ID', this._candidates[req.params.pdfId].pdfId);
res.send(this._candidates[req.params.pdfId].htmlString);
const wantedCandidate = this._candidates[req.params.pdfId];
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);
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
@ -84,7 +89,6 @@ export class SmartPdf {
const response = await page.goto(`http://localhost:3210/${pdfCandidate.pdfId}`, {
waitUntil: 'networkidle2',
});
// await plugins.smartdelay.delayFor(1000);
const headers = response.headers();
if (headers['pdf-id'] !== pdfCandidate.pdfId) {
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;
}
public async convertPDFToJPGBytes(
public async convertPDFToPngBytes(
pdfBytes: Uint8Array,
options: {
width?: number;
height?: number;
quality?: number;
} = {}
): Promise<Uint8Array[]> {
) {
const { width = 1024, height = 768, quality = 100 } = options;
// Load the PDF document
@ -240,7 +244,7 @@ export class SmartPdf {
const converter = plugins.pdf2pic.fromBuffer(Buffer.from(pdfBytes), {
density: 100, // Image density (DPI)
format: 'jpg', // Image format
format: 'png', // Image format
width, // Output image width
height, // Output image height
quality, // Output image quality
@ -257,6 +261,8 @@ export class SmartPdf {
}
// 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;
}
}