diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 270c23d..b32a1e0 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,13 +4,11 @@
-
+
-
-
-
+
+
-
@@ -411,22 +409,6 @@
-
-
- 1740665609483
-
-
-
- 1740665609483
-
-
-
- 1740680778110
-
-
-
- 1740680778110
-
1740788899030
@@ -803,7 +785,23 @@
1743644703042
-
+
+
+ 1743644942488
+
+
+
+ 1743644942488
+
+
+
+ 1743645074051
+
+
+
+ 1743645074051
+
+
@@ -850,8 +848,6 @@
-
-
@@ -875,7 +871,9 @@
-
+
+
+
diff --git a/src/lib/ghostscript/background-worker.js b/src/lib/ghostscript/background-worker.js
index 878f587..1bfe7c2 100644
--- a/src/lib/ghostscript/background-worker.js
+++ b/src/lib/ghostscript/background-worker.js
@@ -5,6 +5,23 @@ function loadScript() {
var Module;
function _GSPS2PDF(dataStruct, responseCallback) {
+ const compressionLevel = dataStruct.compressionLevel || 'medium';
+
+ // Set PDF settings based on compression level
+ let pdfSettings;
+ switch (compressionLevel) {
+ case 'low':
+ pdfSettings = '/printer'; // Higher quality, less compression
+ break;
+ case 'medium':
+ pdfSettings = '/ebook'; // Medium quality and compression
+ break;
+ case 'high':
+ pdfSettings = '/screen'; // Lower quality, higher compression
+ break;
+ default:
+ pdfSettings = '/ebook'; // Default to medium
+ }
// first download the ps data
var xhr = new XMLHttpRequest();
xhr.open('GET', dataStruct.psDataURL);
@@ -33,7 +50,7 @@ function _GSPS2PDF(dataStruct, responseCallback) {
arguments: [
'-sDEVICE=pdfwrite',
'-dCompatibilityLevel=1.4',
- '-dPDFSETTINGS=/ebook',
+ `-dPDFSETTINGS=${pdfSettings}`,
'-DNOPAUSE',
'-dQUIET',
'-dBATCH',
diff --git a/src/pages/tools/pdf/compress-pdf/index.tsx b/src/pages/tools/pdf/compress-pdf/index.tsx
index 565fd86..c5a8b2c 100644
--- a/src/pages/tools/pdf/compress-pdf/index.tsx
+++ b/src/pages/tools/pdf/compress-pdf/index.tsx
@@ -152,7 +152,6 @@ export default function CompressPdf({
setInput={setInput}
initialValues={initialValues}
compute={compute}
- exampleCards={exampleCards}
inputComponent={
-
- Compression Level
-
-
- {compressionOptions.map((option) => (
- {
- updateField('compressionLevel', option.value);
- }}
- />
- ))}
+
+
+ Compression Level
+
+ {compressionOptions.map((option) => (
+ {
+ updateField('compressionLevel', option.value);
+ }}
+ />
+ ))}
+
{fileInfo && (
);
}
diff --git a/src/pages/tools/pdf/compress-pdf/service.ts b/src/pages/tools/pdf/compress-pdf/service.ts
index 58f21ca..2aa3c28 100644
--- a/src/pages/tools/pdf/compress-pdf/service.ts
+++ b/src/pages/tools/pdf/compress-pdf/service.ts
@@ -18,7 +18,10 @@ export async function compressPdf(
throw new Error('The provided file is not a PDF');
}
- const dataObject = { psDataURL: URL.createObjectURL(pdfFile) };
+ const dataObject = {
+ psDataURL: URL.createObjectURL(pdfFile),
+ compressionLevel: options.compressionLevel
+ };
const compressedFileUrl: string = await compressWithGhostScript(dataObject);
return await loadPDFData(compressedFileUrl, pdfFile.name);
}