Unterschriftenservice: PDF-Vorschau als Blob-URL (Chrome zeigt data:PDF im iframe nicht) + Neuer-Tab-Rueckfall

This commit is contained in:
Lucas Orth
2026-08-27 09:57:45 +02:00
parent cc3f4fb758
commit aef08dbbff

View File

@@ -617,10 +617,16 @@ const NeuAuftrag = defineComponent({
async function sigVorschau() {
if (!sig.docId) { sig.err = 'Bitte ein Dokument wählen/hochladen.'; return; }
if (!sigAktive().length) { sig.err = 'Mindestens eine Unterschrift aktivieren.'; return; }
sig.err = ''; sig.msg = 'Vorschau wird erzeugt …'; sig.pdf = '';
sig.err = ''; sig.msg = 'Vorschau wird erzeugt …';
if (sig.pdf && sig.pdf.startsWith('blob:')) { try { URL.revokeObjectURL(sig.pdf); } catch { /* egal */ } }
sig.pdf = '';
try {
const res = await api.post('/skrift-orders/signature-preview', sigPayload());
sig.pdf = 'data:application/pdf;base64,' + res.data.pdf_base64;
// Chrome rendert data:application/pdf in iframes NICHT → als Blob-URL zeigen.
const bin = atob(res.data.pdf_base64 || '');
const bytes = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; i += 1) bytes[i] = bin.charCodeAt(i);
sig.pdf = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
sig.msg = '';
} catch (e) { sig.err = e?.response?.data?.detail || e?.response?.data?.error || e?.message || 'Vorschau fehlgeschlagen.'; sig.msg = ''; }
}
@@ -712,7 +718,10 @@ const NeuAuftrag = defineComponent({
]);
const links = h('div', { style: 'flex:1;min-width:0;display:flex;flex-direction:column;gap:16px;' }, [b1, b2, meldung]);
const rechts = h('div', { style: BEREICH + 'flex:0 0 420px;position:sticky;top:20px;align-self:flex-start;min-height:200px;' }, [
bereichKopf('👁 Vorschau'),
h('div', { style: 'display:flex;justify-content:space-between;align-items:center;gap:8px;' }, [
bereichKopf('👁 Vorschau'),
sig.pdf ? h('a', { href: sig.pdf, target: '_blank', rel: 'noopener', style: `font-size:12px;color:${ACCENT};text-decoration:none;white-space:nowrap;` }, '↗ Neuer Tab') : null,
]),
sig.pdf
? h('iframe', { src: sig.pdf, style: 'width:100%;height:70vh;border:none;border-radius:8px;background:#fff;' })
: subdued('Noch keine Vorschau. Auftrag laden, Signatur wählen, „Vorschau" klicken.'),