feat(pdf-tools): add attachments feature to embed files in PDFs
Implement new functionality to allow embedding attachments into PDF documents. The feature includes: - UI for selecting PDF and files to attach - Logic to embed files while preserving metadata - Display of attached files with size information - Download of modified PDF with embedded files
This commit is contained in:
26
src/js/ui.ts
26
src/js/ui.ts
@@ -1847,11 +1847,35 @@ export const toolTemplates = {
|
||||
</div>
|
||||
`,
|
||||
|
||||
linearize: () => `
|
||||
linearize: () => `
|
||||
<h2 class="text-2xl font-bold text-white mb-4">Linearize PDFs (Fast Web View)</h2>
|
||||
<p class="mb-6 text-gray-400">Optimize multiple PDFs for faster loading over the web. Files will be downloaded in a ZIP archive.</p>
|
||||
${createFileInputHTML({ multiple: true, accept: 'application/pdf', showControls: true })}
|
||||
<div id="file-display-area" class="mt-4 space-y-2"></div>
|
||||
<button id="process-btn" class="hidden btn-gradient w-full mt-6" disabled>Linearize PDFs & Download ZIP</button>
|
||||
`,
|
||||
'add-attachments': () => `
|
||||
<h2 class="text-2xl font-bold text-white mb-4">Add Attachments to PDF</h2>
|
||||
<p class="mb-6 text-gray-400">First, upload the PDF document you want to add files to.</p>
|
||||
${createFileInputHTML({ accept: 'application/pdf' })}
|
||||
<div id="file-display-area" class="mt-4 space-y-2"></div>
|
||||
|
||||
<div id="attachment-options" class="hidden mt-8">
|
||||
<h3 class="text-lg font-semibold text-white mb-3">Upload Files to Attach</h3>
|
||||
<p class="mb-4 text-gray-400">Select one or more files to embed within the PDF. You can attach any file type (images, documents, spreadsheets, etc.).</p>
|
||||
|
||||
<label for="attachment-files-input" class="w-full flex justify-center items-center px-6 py-10 bg-gray-900 text-gray-400 rounded-lg border-2 border-dashed border-gray-600 hover:bg-gray-800 hover:border-gray-500 cursor-pointer transition-colors">
|
||||
<div class="text-center">
|
||||
<svg class="mx-auto h-12 w-12" stroke="currentColor" fill="none" viewBox="0 0 48 48" aria-hidden="true"><path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
|
||||
<span class="mt-2 block text-sm font-medium">Click to upload files</span>
|
||||
<span class="mt-1 block text-xs">Any file type, multiple files allowed</span>
|
||||
</div>
|
||||
<input id="attachment-files-input" name="attachment-files" type="file" class="sr-only" multiple>
|
||||
</label>
|
||||
|
||||
<div id="attachment-file-list" class="mt-4 space-y-2"></div>
|
||||
|
||||
<button id="process-btn" class="hidden btn-gradient w-full mt-6" disabled>Embed Files & Download</button>
|
||||
</div>
|
||||
`,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user