Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdfseal",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"type": "module",
"license": "AGPL-3.0-only",
Expand Down
18 changes: 10 additions & 8 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@
]"
>
<router-view v-slot="{ Component }">
<component
:is="Component"
:share-id="activeShareId"
:key-url-safe="activeShareKey"
@send-to-tool="switchTool"
@exit-receive="switchTool('merge')"
@open-enterprise="isEnterpriseOpen = true"
/>
<KeepAlive :max="5">
<component
:is="Component"
:share-id="activeShareId"
:key-url-safe="activeShareKey"
@send-to-tool="switchTool"
@exit-receive="switchTool('merge')"
@open-enterprise="isEnterpriseOpen = true"
/>
</KeepAlive>
</router-view>
</main>

Expand Down
2 changes: 1 addition & 1 deletion src/config/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const isOfficialMode = ref(checkInitialOfficialMode());

export const siteConfig = reactive({
// Version Identity
version: import.meta.env.VITE_APP_VERSION || '1.1.0',
version: import.meta.env.VITE_APP_VERSION || '1.2.0',

// Brand Identity
brandName: import.meta.env.VITE_BRAND_NAME || 'PDFSeal',
Expand Down
11 changes: 7 additions & 4 deletions src/tools/CompressTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});
const filename = ref('');
const totalPages = ref(0);
const isDragOver = ref(false);
Expand Down Expand Up @@ -779,5 +776,11 @@ function checkIncomingFile() {
}

onMounted(checkIncomingFile);
onActivated(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
});
</script>
3 changes: 3 additions & 0 deletions src/tools/ImageToPdfTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ watch(() => imageList.value.length > 0, (active) => {
}, { immediate: true });

onActivated(() => {
if (lastExportedFile.value) {
clearAll();
}
workspaceState?.setActiveFile(imageList.value.length > 0);
});

Expand Down
12 changes: 7 additions & 5 deletions src/tools/MergeTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@ watch(() => files.value.length > 0, (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(files.value.length > 0);
});

const customOutputBaseName = ref(`${userSettings.defaultExportPrefix || 'PDFSeal'}_Merged_${new Date().toISOString().slice(0, 10)}`);
const autoSaveToVault = ref(userSettings.autoSaveToVault !== false);

Expand Down Expand Up @@ -605,7 +601,13 @@ function checkIncomingFile() {
}

onMounted(checkIncomingFile);
onActivated(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
clearAll();
}
workspaceState?.setActiveFile(files.value.length > 0);
checkIncomingFile();
});

async function handlePasswordSubmit(pwd) {
if (!pendingFileObj) return;
Expand Down
23 changes: 20 additions & 3 deletions src/tools/OrganizeTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});
const filename = ref('');
const pages = ref([]);
const isDragOver = ref(false);
Expand Down Expand Up @@ -1223,6 +1220,17 @@ async function downloadPageAsImage(idx) {
needDestroy = true;
}

if (!targetPdf && docBytes.value) {
const loadingTask = pdfjsLib.getDocument({
data: new Uint8Array(docBytes.value.slice(0)),
cMapUrl: typeof window !== 'undefined' ? (window.location.origin + '/cmaps/') : '/cmaps/',
cMapPacked: true,
standardFontDataUrl: typeof window !== 'undefined' ? (window.location.origin + '/standard_fonts/') : '/standard_fonts/'
});
pdfDoc = await loadingTask.promise;
targetPdf = pdfDoc;
}

if (!targetPdf) return;

const page = await targetPdf.getPage(item.pageIndex + 1);
Expand Down Expand Up @@ -1448,8 +1456,17 @@ onMounted(() => {
});

onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
window.addEventListener('keydown', handleKeydown);
if (gridRef.value && !sortableInstance && pages.value.length > 0) {
nextTick(() => {
initSortable();
});
}
});

onDeactivated(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/PageNumberTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});
const filename = ref('');
const totalPages = ref(0);
const isDragOver = ref(false);
Expand Down Expand Up @@ -1156,6 +1153,9 @@ function checkIncomingFile() {

onMounted(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
if (docBytes.value && !lastExportedFile.value) {
Expand Down
26 changes: 22 additions & 4 deletions src/tools/PdfToImageTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});
const filename = ref('');
const pages = ref([]);
const isDragOver = ref(false);
Expand Down Expand Up @@ -464,6 +461,19 @@ async function destroyPdfDoc() {
}
}

async function ensurePdfDoc() {
if (!pdfDoc && docBytes.value) {
const loadingTask = pdfjsLib.getDocument({
data: new Uint8Array(docBytes.value.slice(0)),
cMapUrl: typeof window !== 'undefined' ? (window.location.origin + '/cmaps/') : '/cmaps/',
cMapPacked: true,
standardFontDataUrl: typeof window !== 'undefined' ? (window.location.origin + '/standard_fonts/') : '/standard_fonts/'
});
pdfDoc = await loadingTask.promise;
}
return pdfDoc;
}

function onFileSelected(e) {
const file = e.target.files[0];
if (file) loadFile(file);
Expand Down Expand Up @@ -598,6 +608,7 @@ function getBaseName() {
* (JPEG has no alpha channel; PNG gets consistent output too).
*/
async function renderPageBlob(pageIndex) {
await ensurePdfDoc();
if (!pdfDoc) throw new Error('No PDF document loaded');
const page = await pdfDoc.getPage(pageIndex + 1);
const viewport = page.getViewport({ scale: outputDpi.value / 72 });
Expand Down Expand Up @@ -643,6 +654,7 @@ async function downloadPage(idx) {
}

async function downloadAllAsZip() {
await ensurePdfDoc();
if (!pdfDoc || pages.value.length === 0 || isZipping.value || isRenderingPage.value !== null) return;
isZipping.value = true;
zipProgress.value = 0;
Expand Down Expand Up @@ -750,7 +762,13 @@ function checkIncomingFile() {
}

onMounted(checkIncomingFile);
onActivated(checkIncomingFile);
onActivated(async () => {
if (lastExportedFile.value) {
await reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
});
onDeactivated(() => {
// Free the pdf.js worker resources when navigating away (KeepAlive safe)
destroyPdfDoc();
Expand Down
3 changes: 3 additions & 0 deletions src/tools/PipelineTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,9 @@ onMounted(() => {
});

onActivated(() => {
if (outputResults.value.length > 0) {
resetBatchAndResults();
}
workspaceState?.setActiveFile(inputFiles.value.length > 0);
checkIncomingFile();
});
Expand Down
11 changes: 7 additions & 4 deletions src/tools/ProtectTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});
const filename = ref('');
const totalPages = ref(0);
const originalSizeFormatted = ref('0 B');
Expand Down Expand Up @@ -1142,5 +1139,11 @@ function checkIncomingFile() {
}

onMounted(checkIncomingFile);
onActivated(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
});
</script>
17 changes: 12 additions & 5 deletions src/tools/RedactTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@
</template>

<script setup>
import { ref, computed, watch, inject, onMounted, onActivated, onUnmounted, nextTick } from 'vue';
import { ref, computed, watch, inject, onMounted, onActivated, onDeactivated, onUnmounted, nextTick } from 'vue';
import {
EyeOff, Plus, Minus, Maximize2, MoveHorizontal, Loader2, FolderLock, RotateCcw, Trash2, Flame, AlertTriangle,
CheckCircle2, ChevronLeft, ChevronRight, Magnet, ListOrdered, BarChart3, ShieldCheck,
Expand Down Expand Up @@ -1139,9 +1139,6 @@ onUnmounted(() => {
watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });
onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});

const isDragOver = ref(false);
const isLoading = ref(false);
Expand Down Expand Up @@ -2113,7 +2110,17 @@ onMounted(() => {
checkIncomingFile();
window.addEventListener('keydown', onKeydown);
});
onActivated(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
window.addEventListener('keydown', onKeydown);
});
onDeactivated(() => {
window.removeEventListener('keydown', onKeydown);
});
onUnmounted(() => {
stageRO?.disconnect();
window.removeEventListener('keydown', onKeydown);
Expand Down
11 changes: 7 additions & 4 deletions src/tools/SanitizeTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});
const filename = ref('');
const totalPages = ref(0);
const rawMetadata = ref({});
Expand Down Expand Up @@ -745,5 +742,11 @@ function checkIncomingFile() {
}

onMounted(checkIncomingFile);
onActivated(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
});
</script>
16 changes: 12 additions & 4 deletions src/tools/SignTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});
const filename = ref('');
const totalPages = ref(0);
const currentPage = ref(1);
Expand Down Expand Up @@ -1769,5 +1766,16 @@ onUnmounted(() => {
window.removeEventListener('resize', handleWindowResize);
reset();
});
onActivated(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
if (docBytes.value && !lastExportedFile.value) {
nextTick(() => {
renderCurrentPage();
});
}
});
</script>
12 changes: 7 additions & 5 deletions src/tools/SplitTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,6 @@ watch(() => Boolean(docBytes.value), (active) => {
workspaceState?.setActiveFile(active);
}, { immediate: true });

onActivated(() => {
workspaceState?.setActiveFile(Boolean(docBytes.value));
});

const filename = ref('');
const pages = ref([]);
const totalPages = ref(0);
Expand Down Expand Up @@ -1399,6 +1395,12 @@ function checkIncomingFile() {
}

onMounted(checkIncomingFile);
onActivated(checkIncomingFile);
onActivated(() => {
if (lastExportedFile.value) {
reset();
}
workspaceState?.setActiveFile(Boolean(docBytes.value));
checkIncomingFile();
});
onUnmounted(destroySplitPdfDoc);
</script>
Loading
Loading