mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
[Annotation] Fix printing/saving for annotations containing some non-ascii chars and with no fonts to handle them (bug 1666824)
- For text fields * when printing, we generate a fake font which contains some widths computed thanks to an OffscreenCanvas and its method measureText. In order to avoid to have to layout the glyphs ourselves, we just render all of them in one call in the showText method in using the system sans-serif/monospace fonts. * when saving, we continue to create the appearance streams if the fonts contain the char but when a char is missing, we just set, in the AcroForm dict, the flag /NeedAppearances to true and remove the appearance stream. This way, we let the different readers handle the rendering of the strings. - For FreeText annotations * when printing, we use the same trick as for text fields. * there is no need to save an appearance since Acrobat is able to infer one from the Content entry.
This commit is contained in:
parent
f7449563ef
commit
3ca03603c2
19 changed files with 1117 additions and 287 deletions
|
@ -42,18 +42,34 @@ class XRef {
|
|||
this._cacheMap = new Map(); // Prepare the XRef cache.
|
||||
this._pendingRefs = new RefSet();
|
||||
this.stats = new DocStats(pdfManager.msgHandler);
|
||||
this._newRefNum = null;
|
||||
this._newPersistentRefNum = null;
|
||||
this._newTemporaryRefNum = null;
|
||||
}
|
||||
|
||||
getNewRef() {
|
||||
if (this._newRefNum === null) {
|
||||
this._newRefNum = this.entries.length || 1;
|
||||
getNewPersistentRef(obj) {
|
||||
// When printing we don't care that much about the ref number by itself, it
|
||||
// can increase for ever and it allows to keep some re-usable refs.
|
||||
if (this._newPersistentRefNum === null) {
|
||||
this._newPersistentRefNum = this.entries.length || 1;
|
||||
}
|
||||
return Ref.get(this._newRefNum++, 0);
|
||||
const num = this._newPersistentRefNum++;
|
||||
this._cacheMap.set(num, obj);
|
||||
return Ref.get(num, 0);
|
||||
}
|
||||
|
||||
resetNewRef() {
|
||||
this._newRefNum = null;
|
||||
getNewTemporaryRef() {
|
||||
// When saving we want to have some minimal numbers.
|
||||
// Those refs are only created in order to be written in the final pdf
|
||||
// stream.
|
||||
if (this._newTemporaryRefNum === null) {
|
||||
this._newTemporaryRefNum = this.entries.length || 1;
|
||||
}
|
||||
return Ref.get(this._newTemporaryRefNum++, 0);
|
||||
}
|
||||
|
||||
resetNewTemporaryRef() {
|
||||
// Called once saving is finished.
|
||||
this._newTemporaryRefNum = null;
|
||||
}
|
||||
|
||||
setStartXRef(startXRef) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue