subdocument-splitting-plan
This commit is contained in:
1 parent
f09384d2e6
commit
ca06ca2050
47 files changed
+4097
-136
No files matched your search
+11
-14
@@ -17,6 +17,7 @@
|
||||
import FileDropzone from '$lib/components/FileDropzone.svelte';
|
||||
import * as Card from '$lib/components/ui/card/index';
|
||||
import { queueZipFiles } from '$lib/pending-files';
|
||||
import { isAcceptedWorkspaceFile, WORKSPACE_ACCEPT_TYPES } from '$lib/zip-selection';
|
||||
import { tools } from '$lib/tools';
|
||||
|
||||
const iconMap: Record<string, typeof FileText> = {
|
||||
@@ -32,16 +33,11 @@
|
||||
info: Info
|
||||
};
|
||||
|
||||
const isZipFile = (file: File) =>
|
||||
file.name.toLowerCase().endsWith('.zip') ||
|
||||
file.type === 'application/zip' ||
|
||||
file.type === 'application/x-zip-compressed';
|
||||
|
||||
const openBeaFiles = (files: File[]) => {
|
||||
const zipFiles = files.filter(isZipFile);
|
||||
if (zipFiles.length === 0) return;
|
||||
const workspaceFiles = files.filter(isAcceptedWorkspaceFile);
|
||||
if (workspaceFiles.length === 0) return;
|
||||
|
||||
queueZipFiles(zipFiles);
|
||||
queueZipFiles(workspaceFiles);
|
||||
void goto('/tools/bea');
|
||||
};
|
||||
|
||||
@@ -76,20 +72,21 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- ZIP entry point -->
|
||||
<!-- Workspace entry point -->
|
||||
<div class="mx-auto w-full max-w-2xl">
|
||||
<FileDropzone
|
||||
onFilesSelected={openBeaFiles}
|
||||
accept=".zip,application/zip,application/x-zip-compressed"
|
||||
accept={WORKSPACE_ACCEPT_TYPES}
|
||||
multiple={true}
|
||||
ariaLabel="beA-ZIP öffnen"
|
||||
label="beA-ZIP öffnen"
|
||||
sublabel="ZIP aus dem besonderen elektronischen Anwaltspostfach (beA) hier ablegen oder zum Auswählen klicken"
|
||||
ariaLabel="beA-ZIP oder PDF öffnen"
|
||||
label="beA-ZIP oder PDF öffnen"
|
||||
sublabel="ZIP aus dem besonderen elektronischen Anwaltspostfach (beA) oder eine PDF-Datei hier ablegen oder zum Auswählen klicken"
|
||||
icon={Archive}
|
||||
class="py-10"
|
||||
/>
|
||||
<p class="mt-2 text-center text-[12px] text-primary-600">
|
||||
Tipp: In beA exportierte Archive enden auf .zip und enthalten Ihre Anlagen als PDF.
|
||||
Tipp: In beA exportierte Archive enden auf .zip und enthalten Ihre Anlagen als PDF. PDFs
|
||||
können direkt in Teildokumente aufgeteilt werden.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
import {
|
||||
extractZipArchives,
|
||||
mergeProcessedZipArchive,
|
||||
pdfFileToArchive,
|
||||
type ProcessedZipArchive
|
||||
} from '$lib/zip-processing';
|
||||
import { isAcceptedPdfFile } from '$lib/zip-selection';
|
||||
import { downloadBlob } from '$lib/download';
|
||||
import { takeQueuedZipFiles } from '$lib/pending-files';
|
||||
import * as Card from '$lib/components/ui/card/index';
|
||||
@@ -76,7 +78,9 @@
|
||||
updateZipJob(jobId, { status: 'processing', error: undefined, archiveCount: undefined });
|
||||
|
||||
try {
|
||||
const processedZipArchives = await extractZipArchives(file);
|
||||
const processedZipArchives = isAcceptedPdfFile(file)
|
||||
? [await pdfFileToArchive(file)]
|
||||
: await extractZipArchives(file);
|
||||
|
||||
if (generation !== archiveGeneration || !zipJobs.some((job) => job.id === jobId)) {
|
||||
return;
|
||||
@@ -93,7 +97,9 @@
|
||||
if (generation === archiveGeneration && zipJobs.some((job) => job.id === jobId)) {
|
||||
updateZipJob(jobId, {
|
||||
status: 'error',
|
||||
error: 'Prüfen Sie, ob die Datei ein gültiges beA-ZIP-Archiv ist.'
|
||||
error: isAcceptedPdfFile(file)
|
||||
? 'Prüfen Sie, ob die Datei ein gültiges PDF ist.'
|
||||
: 'Prüfen Sie, ob die Datei ein gültiges beA-ZIP-Archiv ist.'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy } from 'svelte';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
import FileDropzone from '$lib/components/FileDropzone.svelte';
|
||||
import PdfPageGrid from '$lib/components/PdfPageGrid.svelte';
|
||||
import Button from '$lib/components/ui/button.svelte';
|
||||
import { downloadBlob } from '$lib/download';
|
||||
import { copyPagesToNewPdf } from '$lib/pdf-processing';
|
||||
import { loadPdfDocument, type PdfDocumentHandle } from '$lib/pdf-thumbnails';
|
||||
|
||||
let pdfFile: File | null = $state(null);
|
||||
@@ -64,11 +64,9 @@
|
||||
|
||||
try {
|
||||
const bytes = new Uint8Array(await pdfFile.arrayBuffer());
|
||||
const sourcePdf = await PDFDocument.load(bytes);
|
||||
const outputPdf = await PDFDocument.create();
|
||||
|
||||
const pagesToKeep: number[] = [];
|
||||
for (let i = 0; i < sourcePdf.getPageCount(); i++) {
|
||||
for (let i = 0; i < pdfHandle.pageCount; i++) {
|
||||
if (!selectedPages.has(i + 1)) {
|
||||
pagesToKeep.push(i);
|
||||
}
|
||||
@@ -80,10 +78,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const copiedPages = await outputPdf.copyPages(sourcePdf, pagesToKeep);
|
||||
copiedPages.forEach((page) => outputPdf.addPage(page));
|
||||
|
||||
const resultBytes = await outputPdf.save();
|
||||
const resultBytes = await copyPagesToNewPdf(bytes, pagesToKeep);
|
||||
const baseName = pdfFile.name.replace(/\.pdf$/i, '');
|
||||
downloadBlob(resultBytes, `${baseName}_ohne_seiten.pdf`);
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user