[Bug] Stamp annotations imported via importAnnotations are invisible
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start by running the reproduction HTML from the issue: place a stamp, export with exportAnnotations, re-init, then importAnnotations, and check whether the stamp renders. The payload names only the annotation plugin API (importAnnotations, exportAnnotations, the stamp tool) and the stamp's ctx.data ArrayBuffer, not specific files. Done means a stamp imported from exported data renders in the same position as before the viewer was destroyed.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
When exporting a stamp annotation and subsequently importing it back into a freshly initialized viewer via importAnnotations, the stamp becomes completely invisible.
The data exported by exportAnnotations contains a valid ArrayBuffer for the stamp's ctx.data, and importAnnotations accepts it without throwing any errors. However, the stamp fails to render visually. It seems the appearance stream (/AP) is being lost or ignored when the stamp is recreated during the import phase.
Steps to Reproduce
We have created a zero-dependency Minimal Reproducible Example (MRE) using the raw @embedpdf/snippet library to prove this is not related to external frameworks or serialization:
- Save the HTML file below and open it in a browser.
- Click "1. Init & Load PDF".
- Place a Stamp anywhere on the document.
- Click "2. Export & Destroy" (This saves the raw
exportAnnotations()output to an in-memory variable and completely clears the DOM/viewer instance). - Click "3. Re-Init & Import" (This spawns a fresh viewer, loads the PDF, and calls
importAnnotations(savedAnnotations)using the raw memory data).
Expected Behavior
The stamp should be fully visible exactly where it was placed before the viewer was destroyed.
Actual Behavior
The import succeeds silently without errors, but the stamp is completely invisible on the document.
Minimal Reproducible Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>EmbedPDF Stamp MRE</title>
<style>
body, html { margin: 0; padding: 0; height: 100%; font-family: sans-serif; display: flex; flex-direction: column; }
#controls { padding: 15px; background: #f0f0f0; border-bottom: 1px solid #ccc; display: flex; gap: 10px; align-items: center; }
button { padding: 8px 16px; cursor: pointer; }
#status { font-weight: bold; margin-left: 20px; color: #333; }
#viewer-container { flex: 1; position: relative; background: #888; }
#pdf-viewer { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="controls">
<button id="btn-load">1. Init & Load PDF</button>
<button id="btn-export">2. Export & Destroy</button>
<button id="btn-import">3. Re-Init & Import</button>
<span id="status">Ready. Click 'Init & Load PDF'</span>
</div>
<div id="viewer-container">
<div id="pdf-viewer"></div>
</div>
<script type="module">
import EmbedPDF from 'https://cdn.jsdelivr.net/npm/@embedpdf/snippet@2/dist/embedpdf.js';
const pdfUrl = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf';
let savedAnnotations = null;
let viewerInstance = null;
let annotationApi = null;
async function initViewer() {
const targetId = 'pdf-viewer';
document.getElementById('viewer-container').innerHTML = `<div id="${targetId}"></div>`;
viewerInstance = EmbedPDF.init({
type: 'container',
target: document.getElementById(targetId),
documentManager: { maxDocuments: 1 }
});
const registry = await viewerInstance.registry;
const docManager = registry.getPlugin('document-manager').provides();
annotationApi = registry.getPlugin('annotation').provides();
await docManager.openDocumentUrl({
url: pdfUrl,
documentId: 'test-document',
autoActivate: true
});
}
document.getElementById('btn-load').onclick = async () => {
document.getElementById('status').textContent = 'Loading...';
await initViewer();
annotationApi.setActiveTool('stamp');
document.getElementById('status').textContent = 'Loaded! Please place a STAMP, then click step 2.';
};
document.getElementById('btn-export').onclick = async () => {
if (!annotationApi) return;
document.getElementById('status').textContent = 'Exporting...';
savedAnnotations = await new Promise((resolve) => {
annotationApi.exportAnnotations().wait(
items => resolve(items),
err => { console.error(err); resolve([]); }
);
});
document.getElementById('viewer-container').innerHTML = '';
viewerInstance = null;
annotationApi = null;
document.getElementById('status').textContent = 'Destroyed! Annotations saved to variable. Now click step 3.';
};
document.getElementById('btn-import').onclick = async () => {
if (!savedAnnotations) return alert("Please export first!");
document.getElementById('status').textContent = 'Re-initializing...';
await initViewer();
const result = annotationApi.importAnnotations(savedAnnotations);
if (result && typeof result.wait === 'function') {
await new Promise(resolve => result.wait(resolve, resolve));
}
document.getElementById('status').textContent = 'Imported! The stamp is now invisible.';
};
</script>
</body>
</html>
Environment
- EmbedPDF Version:
@embedpdf/snippet@2 - Browser: Firefox 156.01
- OS: Arch Linux
- Ngôn ngữ chính
- TypeScript
- Star
- 4.5k
- Fork
- 317
- Merge trung bình
- 10 giờ 16 phút
- Pull request đã merge (30 ngày)
- 174
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của embedpdf/embed-pdf-viewer
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
embedpdf/embed-pdf-viewer#1098 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
embedpdf/embed-pdf-viewer#921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
embedpdf/embed-pdf-viewer#889 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[v2] TaskQueue: equal-priority tasks can run out of order when a randomUUID id starts with digitsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
embedpdf/embed-pdf-viewer#874 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Free text stays scrolled to the caret after editing endsCó thể đã có người làm @chahore đã nhận 36 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
embedpdf/embed-pdf-viewer#861 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của embedpdf/embed-pdf-viewer
Issue tương tự
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
lingdojo/kana-dojo#34223 · 1 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
mastra-ai/mastra#30587 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:web p2 product:business triage:active type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
cuadrao-ai/argus#2228 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
.Needs Triage .Team/Metabot Priority:P3 Type:Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
metabase/metabase#87252 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
NuGet registry builds every URL from ROOT_URL, ignoring the host the client usedCó thể đã có người làm @gritse đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày