feat(docker): add docker configuration files and update styles

refactor: convert script tags to link tags for stylesheets in HTML files
fix: update PDF download to use Uint8Array for blob creation
style: reformat CSS file for better readability and organization
This commit is contained in:
abdullahalam123
2025-10-12 18:23:13 +05:30
parent 5e72d7ca2d
commit 3f90e5ed8d
38 changed files with 269 additions and 129 deletions

View File

@@ -40,7 +40,8 @@ export async function addBlankPage() {
}
const newPdfBytes = await newPdf.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'page-added.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'page-added.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not add a blank page.');

View File

@@ -45,7 +45,7 @@ export async function bmpToPdf() {
page.drawImage(pngImage, { x: 0, y: 0, width: pngImage.width, height: pngImage.height });
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from_bmps.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from_bmps.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to convert BMP to PDF. One of the files may be invalid.');

View File

@@ -43,7 +43,7 @@ export async function changeBackgroundColor() {
}
const newPdfBytes = await newPdfDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'background-changed.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'background-changed.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not change the background color.');

View File

@@ -134,7 +134,7 @@ export async function changeTextColor() {
}
const newPdfBytes = await newPdfDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'text-color-changed.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'text-color-changed.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not change text color.');

View File

@@ -66,7 +66,7 @@ export async function combineToSinglePage() {
}
const newPdfBytes = await newDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'combined-page.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'combined-page.pdf');
} catch (e) {
console.error(e);

View File

@@ -88,7 +88,7 @@ async function performSmartCompression(arrayBuffer: any, settings: any) {
canvas.height = Math.floor(newHeight);
const img = new Image();
const imageUrl = URL.createObjectURL(new Blob([imageBytes]));
const imageUrl = URL.createObjectURL(new Blob([new Uint8Array(imageBytes)]));
await new Promise((resolve, reject) => {
img.onload = resolve;

View File

@@ -47,7 +47,7 @@ export async function deletePages() {
copiedPages.forEach((page: any) => newPdf.addPage(page));
const newPdfBytes = await newPdf.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'deleted-pages.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'deleted-pages.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not delete pages.');

View File

@@ -154,7 +154,7 @@ export async function processAndSave() {
copiedPages.forEach((page: any) => newPdfDoc.addPage(page));
const newPdfBytes = await newPdfDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'organized.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'organized.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to save the new PDF.');

View File

@@ -77,7 +77,7 @@ export async function fixDimensions() {
}
const newPdfBytes = await newDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'standardized.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'standardized.pdf');
} catch (e) {
console.error(e);

View File

@@ -26,7 +26,7 @@ export async function heicToPdf() {
page.drawImage(pngImage, { x: 0, y: 0, width: pngImage.width, height: pngImage.height });
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from_heic.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from_heic.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to convert HEIC to PDF. One of the files may be invalid or unsupported.');

View File

@@ -123,7 +123,7 @@ export async function imageToPdf() {
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from-images.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from-images.pdf');
} catch (e) {
console.error(e);
showAlert('Error', e.message || 'Failed to create PDF from images.');

View File

@@ -42,7 +42,7 @@ export async function invertColors() {
newPage.drawImage(image, { x: 0, y: 0, width: image.width, height: image.height });
}
const newPdfBytes = await newPdfDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'inverted.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'inverted.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not invert PDF colors.');

View File

@@ -83,7 +83,7 @@ export async function jpgToPdf() {
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from_jpgs.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from_jpgs.pdf');
} catch (e) {
console.error(e);
showAlert('Conversion Error', e.message);

View File

@@ -244,7 +244,7 @@ export async function merge() {
}
const mergedPdfBytes = await newPdfDoc.save();
downloadFile(new Blob([mergedPdfBytes], { type: 'application/pdf' }), 'merged.pdf');
downloadFile(new Blob([new Uint8Array(mergedPdfBytes)], { type: 'application/pdf' }), 'merged.pdf');
showAlert('Success', 'PDFs merged successfully!');
} catch (e) {

View File

@@ -101,7 +101,7 @@ export async function nUpTool() {
}
const newPdfBytes = await newDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), `n-up_${n}.pdf`);
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), `n-up_${n}.pdf`);
} catch (e) {
console.error(e);
showAlert('Error', 'An error occurred while creating the N-Up PDF.');

View File

@@ -17,7 +17,7 @@ export async function organize() {
copiedPages.forEach((page: any) => newPdf.addPage(page));
const newPdfBytes = await newPdf.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'organized.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'organized.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not save the changes.');

View File

@@ -48,7 +48,7 @@ export async function pdfToGreyscale() {
newPage.drawImage(image, { x: 0, y: 0, width: image.width, height: image.height });
}
const newPdfBytes = await newPdfDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'greyscale.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'greyscale.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not convert to greyscale.');

View File

@@ -25,7 +25,7 @@ export async function pngToPdf() {
});
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from_pngs.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from_pngs.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to create PDF from PNG images. Ensure all files are valid PNGs.');

View File

@@ -16,7 +16,7 @@ export async function reversePages() {
copiedPages.forEach((page: any) => newPdf.addPage(page));
const newPdfBytes = await newPdf.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'reversed.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'reversed.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not reverse the PDF pages.');

View File

@@ -42,7 +42,7 @@ export async function splitInHalf() {
}
const newPdfBytes = await newPdfDoc.save();
downloadFile(new Blob([newPdfBytes], { type: 'application/pdf' }), 'split-half.pdf');
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'split-half.pdf');
} catch (e) {
console.error(e);

View File

@@ -198,7 +198,7 @@ export async function split() {
const copiedPages = await newPdf.copyPages(state.pdfDoc, uniqueIndices as number[]);
copiedPages.forEach((page: any) => newPdf.addPage(page));
const pdfBytes = await newPdf.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'split-document.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'split-document.pdf');
}
if (splitMode === 'visual') {

View File

@@ -45,7 +45,7 @@ export async function svgToPdf() {
page.drawImage(pngImage, { x: 0, y: 0, width: pngImage.width, height: pngImage.height });
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from_svgs.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from_svgs.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to convert SVG to PDF. One of the files may be invalid.');

View File

@@ -72,7 +72,7 @@ export async function tiffToPdf() {
}
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from_tiff.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from_tiff.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to convert TIFF to PDF. One of the files may be invalid or corrupted.');

View File

@@ -64,7 +64,7 @@ export async function txtToPdf() {
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'text-document.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'text-document.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to create PDF from text.');

View File

@@ -38,7 +38,7 @@ export async function webpToPdf() {
});
}
const pdfBytes = await pdfDoc.save();
downloadFile(new Blob([pdfBytes], { type: 'application/pdf' }), 'from_webp.pdf');
downloadFile(new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' }), 'from_webp.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Failed to convert WebP to PDF. Ensure all files are valid WebP images.');

View File

@@ -110,4 +110,5 @@ export function parsePageRanges(rangeString: any, totalPages: any) {
// @ts-expect-error TS(2362) FIXME: The left-hand side of an arithmetic operation must... Remove this comment to see the full error message
return Array.from(indices).sort((a, b) => a - b);
}
}