mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
[Editor] Support svg images in the stamp annotation
createImageBitmap doesn't work with svg files (see bug 1841972), so we need to workaround this in using an Image. When printing/saving we must rasterize the image, hence we get the biggest bitmap as image reference to avoid duplications or poor quality on rendering.
This commit is contained in:
parent
eb2527e9d7
commit
4fcc2ef23f
7 changed files with 285 additions and 14 deletions
|
@ -154,3 +154,25 @@ function getEditors(page, kind) {
|
|||
}, kind);
|
||||
}
|
||||
exports.getEditors = getEditors;
|
||||
|
||||
function getEditorDimensions(page, id) {
|
||||
return page.evaluate(n => {
|
||||
const element = document.getElementById(`pdfjs_internal_editor_${n}`);
|
||||
const { style } = element;
|
||||
return { width: style.width, height: style.height };
|
||||
}, id);
|
||||
}
|
||||
exports.getEditorDimensions = getEditorDimensions;
|
||||
|
||||
function serializeBitmapDimensions(page) {
|
||||
return page.evaluate(() => {
|
||||
const { map } =
|
||||
window.PDFViewerApplication.pdfDocument.annotationStorage.serializable;
|
||||
return map
|
||||
? Array.from(map.values(), x => {
|
||||
return { width: x.bitmap.width, height: x.bitmap.height };
|
||||
})
|
||||
: [];
|
||||
});
|
||||
}
|
||||
exports.serializeBitmapDimensions = serializeBitmapDimensions;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue