Skip to content

Commit

Permalink
Update pdf.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Sep 8, 2024
1 parent 124eb9e commit 9d741c8
Show file tree
Hide file tree
Showing 12 changed files with 600 additions and 195 deletions.
384 changes: 274 additions & 110 deletions build/pdf.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdf.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/pdf.sandbox.mjs

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions build/pdf.worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37292,10 +37292,26 @@ class StructTreePage {
obj.role = node.role;
obj.children = [];
parent.children.push(obj);
const alt = node.dict.get("Alt");
let alt = node.dict.get("Alt");
if (typeof alt !== "string") {
alt = node.dict.get("ActualText");
}
if (typeof alt === "string") {
obj.alt = stringToPDFString(alt);
}
const a = node.dict.get("A");
if (a instanceof Dict) {
const bbox = lookupNormalRect(a.getArray("BBox"), null);
if (bbox) {
obj.bbox = bbox;
} else {
const width = a.get("Width");
const height = a.get("Height");
if (typeof width === "number" && width > 0 && typeof height === "number" && height > 0) {
obj.bbox = [0, 0, width, height];
}
}
}
const lang = node.dict.get("Lang");
if (typeof lang === "string") {
obj.lang = stringToPDFString(lang);
Expand Down Expand Up @@ -50005,6 +50021,10 @@ class Annotation {
this.data.fieldName = this._constructFieldName(dict);
this.data.pageIndex = params.pageIndex;
}
const it = dict.get("IT");
if (it instanceof Name) {
this.data.it = it.name;
}
this._isOffscreenCanvasSupported = params.evaluatorOptions.isOffscreenCanvasSupported;
this._fallbackFontDict = null;
this._needAppearances = false;
Expand Down Expand Up @@ -50395,6 +50415,7 @@ class Annotation {
class AnnotationBorderStyle {
constructor() {
this.width = 1;
this.rawWidth = 1;
this.style = AnnotationBorderStyleType.SOLID;
this.dashArray = [3];
this.horizontalCornerRadius = 0;
Expand All @@ -50407,6 +50428,7 @@ class AnnotationBorderStyle {
}
if (typeof width === "number") {
if (width > 0) {
this.rawWidth = width;
const maxWidth = (rect[2] - rect[0]) / 2;
const maxHeight = (rect[3] - rect[1]) / 2;
if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) {
Expand Down Expand Up @@ -52403,6 +52425,9 @@ class InkAnnotation extends MarkupAnnotation {
} = params;
this.data.annotationType = AnnotationType.INK;
this.data.inkLists = [];
this.data.isEditable = !this.data.noHTML && this.data.it === "InkHighlight";
this.data.noHTML = false;
this.data.opacity = dict.get("CA") || 1;
const rawInkLists = dict.getArray("InkList");
if (!Array.isArray(rawInkLists)) {
return;
Expand Down Expand Up @@ -52598,6 +52623,9 @@ class HighlightAnnotation extends MarkupAnnotation {
xref
} = params;
this.data.annotationType = AnnotationType.HIGHLIGHT;
this.data.isEditable = !this.data.noHTML;
this.data.noHTML = false;
this.data.opacity = dict.get("CA") || 1;
const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
if (quadPoints) {
const resources = this.appearance?.dict.get("Resources");
Expand All @@ -52624,7 +52652,8 @@ class HighlightAnnotation extends MarkupAnnotation {
}
static createNewDict(annotation, xref, {
apRef,
ap
ap,
oldAnnotation
}) {
const {
color,
Expand All @@ -52634,9 +52663,10 @@ class HighlightAnnotation extends MarkupAnnotation {
user,
quadPoints
} = annotation;
const highlight = new Dict(xref);
const highlight = oldAnnotation || new Dict(xref);
highlight.set("Type", Name.get("Annot"));
highlight.set("Subtype", Name.get("Highlight"));
highlight.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate()}`);
highlight.set("CreationDate", `D:${getModificationDate()}`);
highlight.set("Rect", rect);
highlight.set("F", 4);
Expand Down Expand Up @@ -56393,7 +56423,7 @@ if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" &&
;// CONCATENATED MODULE: ./src/pdf.worker.js

const pdfjsVersion = "4.6.0";
const pdfjsBuild = "ff76217";
const pdfjsBuild = "5d0c82c";

var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };
Expand Down
2 changes: 1 addition & 1 deletion build/pdf.worker.mjs.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions web/locale/nn-NO/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ pdfjs-document-properties-keywords = Stikkord:
pdfjs-document-properties-creation-date = Dato oppretta:
pdfjs-document-properties-modification-date = Dato endra:
# Variables:
# $dateObj (Date) - the creation/modification date and time of the PDF file
pdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
# Variables:
# $date (Date) - the creation/modification date of the PDF file
# $time (Time) - the creation/modification time of the PDF file
pdfjs-document-properties-date-string = { $date }, { $time }
Expand Down Expand Up @@ -275,6 +278,9 @@ pdfjs-annotation-date-string = { $date } { $time }
# Some common types are e.g.: "Check", "Text", "Comment", "Note"
pdfjs-text-annotation-type =
.alt = [{ $type } annotasjon]
# Variables:
# $dateObj (Date) - the modification date and time of the annotation
pdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
## Password

Expand Down Expand Up @@ -437,6 +443,7 @@ pdfjs-image-alt-text-settings-button-label = Alternative tekst-innstillingar for
pdfjs-editor-alt-text-settings-dialog-label = Alternative tekst-innstillingar for bilde
pdfjs-editor-alt-text-settings-automatic-title = Automatisk alternativ tekst
pdfjs-editor-alt-text-settings-create-model-button-label = Opprett alternativ tekt automatisk
pdfjs-editor-alt-text-settings-create-model-description = Foreslår skildringar for å hjelpe folk som ikkje kan sjå bildet eller når bildet ikkje blir lasta inn.
# Variables:
# $totalSize (Number) - the total size (in MB) of the AI model.
pdfjs-editor-alt-text-settings-download-model-label = AI-modell for alternativ tekst ({ $totalSize } MB)
Expand All @@ -446,4 +453,5 @@ pdfjs-editor-alt-text-settings-download-model-button = Last ned
pdfjs-editor-alt-text-settings-downloading-model-button = Lastar ned…
pdfjs-editor-alt-text-settings-editor-title = Alternativ tekst-redigerar
pdfjs-editor-alt-text-settings-show-dialog-button-label = Vis alternativ tekst-redigerar direkte når du legg til eit bilde
pdfjs-editor-alt-text-settings-show-dialog-description = Hjelper deg med å sørgje for at alle bilda dine har alternativ tekst.
pdfjs-editor-alt-text-settings-close-button = Lat att
73 changes: 71 additions & 2 deletions web/locale/rm/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ pdfjs-document-properties-button-label = Caracteristicas dal document…
pdfjs-document-properties-file-name = Num da la datoteca:
pdfjs-document-properties-file-size = Grondezza da la datoteca:
# Variables:
# $kb (Number) - the PDF file size in kilobytes
# $b (Number) - the PDF file size in bytes
pdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)
# Variables:
# $mb (Number) - the PDF file size in megabytes
# $b (Number) - the PDF file size in bytes
pdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)
# Variables:
# $size_kb (Number) - the PDF file size in kilobytes
# $size_b (Number) - the PDF file size in bytes
pdfjs-document-properties-kb = { $size_kb } KB ({ $size_b } bytes)
Expand All @@ -119,6 +127,9 @@ pdfjs-document-properties-keywords = Chavazzins:
pdfjs-document-properties-creation-date = Data da creaziun:
pdfjs-document-properties-modification-date = Data da modificaziun:
# Variables:
# $dateObj (Date) - the creation/modification date and time of the PDF file
pdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
# Variables:
# $date (Date) - the creation/modification date of the PDF file
# $time (Time) - the creation/modification time of the PDF file
pdfjs-document-properties-date-string = { $date } { $time }
Expand Down Expand Up @@ -275,6 +286,9 @@ pdfjs-annotation-date-string = { $date }, { $time }
# Some common types are e.g.: "Check", "Text", "Comment", "Note"
pdfjs-text-annotation-type =
.alt = [Annotaziun da { $type }]
# Variables:
# $dateObj (Date) - the modification date and time of the annotation
pdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
## Password

Expand All @@ -298,8 +312,6 @@ pdfjs-editor-stamp-button-label = Agiuntar u modifitgar maletgs
pdfjs-editor-highlight-button =
.title = Marcar
pdfjs-editor-highlight-button-label = Marcar
pdfjs-highlight-floating-button =
.title = Relevar
pdfjs-highlight-floating-button1 =
.title = Marcar
.aria-label = Marcar
Expand Down Expand Up @@ -394,3 +406,60 @@ pdfjs-editor-colorpicker-red =
pdfjs-editor-highlight-show-all-button-label = Mussar tut
pdfjs-editor-highlight-show-all-button =
.title = Mussar tut
## New alt-text dialog
## Group note for entire feature: Alternative text (alt text) helps when people can't see the image. This feature includes a tool to create alt text automatically using an AI model that works locally on the user's device to preserve privacy.

# Modal header positioned above a text box where users can edit the alt text.
pdfjs-editor-new-alt-text-dialog-edit-label = Modifitgar il text alternativ (descripziun dal maletg)
# Modal header positioned above a text box where users can add the alt text.
pdfjs-editor-new-alt-text-dialog-add-label = Agiuntar in text alternativ (descripziun dal maletg)
pdfjs-editor-new-alt-text-textarea =
.placeholder = Scriva qua tia descripziun…
# This text refers to the alt text box above this description. It offers a definition of alt text.
pdfjs-editor-new-alt-text-description = Curta descripziun per persunas che na vesan betg il maletg u per cass en ils quals il maletg na vegn betg chargià.
# This is a required legal disclaimer that refers to the automatically created text inside the alt text box above this text. It disappears if the text is edited by a human.
pdfjs-editor-new-alt-text-disclaimer1 = Quest text alternativ è vegnì creà automaticamain ed è eventualmain nunprecis.
pdfjs-editor-new-alt-text-disclaimer-learn-more-url = Ulteriuras infurmaziuns
pdfjs-editor-new-alt-text-create-automatically-button-label = Crear automaticamain il text alternativ
pdfjs-editor-new-alt-text-not-now-button = Betg ussa
pdfjs-editor-new-alt-text-error-title = I n’è betg reussì da crear automaticamain il text alternativ
pdfjs-editor-new-alt-text-error-description = Scriva per plaschair tes agen text alternativ u emprova pli tard anc ina giada.
pdfjs-editor-new-alt-text-error-close-button = Serrar
# Variables:
# $totalSize (Number) - the total size (in MB) of the AI model.
# $downloadedSize (Number) - the downloaded size (in MB) of the AI model.
# $percent (Number) - the percentage of the downloaded size.
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Telechargiar il model IA da text alternativ ({ $downloadedSize } da { $totalSize } MB)
.aria-valuetext = Telechargiar il model IA da text alternativ ({ $downloadedSize } da { $totalSize } MB)
# This is a button that users can click to edit the alt text they have already added.
pdfjs-editor-new-alt-text-added-button-label = Text alternativ agiuntà
# This is a button that users can click to open the alt text editor and add alt text when it is not present.
pdfjs-editor-new-alt-text-missing-button-label = Text alternativ manca
# This is a button that opens up the alt text modal where users should review the alt text that was automatically generated.
pdfjs-editor-new-alt-text-to-review-button-label = Repassar il text alternativ
# "Created automatically" is a prefix that will be added to the beginning of any alt text that has been automatically generated. After the colon, the user will see/hear the actual alt text description. If the alt text has been edited by a human, this prefix will not appear.
# Variables:
# $generatedAltText (String) - the generated alt-text.
pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Creà automaticamain: { $generatedAltText }
## Image alt-text settings

pdfjs-image-alt-text-settings-button =
.title = Parameters dal text alternativ da maletgs
pdfjs-image-alt-text-settings-button-label = Parameters dal text alternativ da maletgs
pdfjs-editor-alt-text-settings-dialog-label = Parameters dal text alternativ da maletgs
pdfjs-editor-alt-text-settings-automatic-title = Text alternativ automatic
pdfjs-editor-alt-text-settings-create-model-button-label = Crear automaticamain text alternativ
pdfjs-editor-alt-text-settings-create-model-description = Propona descripziuns per gidar a persunas che na vesan betg il maletg u per cass en ils quals il maletg na vegn betg chargià.
# Variables:
# $totalSize (Number) - the total size (in MB) of the AI model.
pdfjs-editor-alt-text-settings-download-model-label = Model IA da text alternativ ({ $totalSize } MB)
pdfjs-editor-alt-text-settings-ai-model-description = Vegn exequì localmain sin tes apparat per che tias datas restian privatas. Necessari per text alternativ automatic.
pdfjs-editor-alt-text-settings-delete-model-button = Stizzar
pdfjs-editor-alt-text-settings-download-model-button = Telechargiar
pdfjs-editor-alt-text-settings-downloading-model-button = Telechargiar…
pdfjs-editor-alt-text-settings-editor-title = Editur per text alternativ
pdfjs-editor-alt-text-settings-show-dialog-button-label = Mussar l’editur per text alternativ directamain cun agiuntar in maletg
pdfjs-editor-alt-text-settings-show-dialog-description = Ta gida a garantir che tut tes maletgs hajan in text alternativ.
pdfjs-editor-alt-text-settings-close-button = Serrar
16 changes: 14 additions & 2 deletions web/locale/sk/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ pdfjs-document-properties-button-label = Vlastnosti dokumentu…
pdfjs-document-properties-file-name = Názov súboru:
pdfjs-document-properties-file-size = Veľkosť súboru:
# Variables:
# $kb (Number) - the PDF file size in kilobytes
# $b (Number) - the PDF file size in bytes
pdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } kB ({ $b } bajtov)
# Variables:
# $mb (Number) - the PDF file size in megabytes
# $b (Number) - the PDF file size in bytes
pdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bajtov)
# Variables:
# $size_kb (Number) - the PDF file size in kilobytes
# $size_b (Number) - the PDF file size in bytes
pdfjs-document-properties-kb = { $size_kb } kB ({ $size_b } bajtov)
Expand All @@ -119,6 +127,9 @@ pdfjs-document-properties-keywords = Kľúčové slová:
pdfjs-document-properties-creation-date = Dátum vytvorenia:
pdfjs-document-properties-modification-date = Dátum úpravy:
# Variables:
# $dateObj (Date) - the creation/modification date and time of the PDF file
pdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
# Variables:
# $date (Date) - the creation/modification date of the PDF file
# $time (Time) - the creation/modification time of the PDF file
pdfjs-document-properties-date-string = { $date }, { $time }
Expand Down Expand Up @@ -279,6 +290,9 @@ pdfjs-annotation-date-string = { $date }, { $time }
# Some common types are e.g.: "Check", "Text", "Comment", "Note"
pdfjs-text-annotation-type =
.alt = [Anotácia typu { $type }]
# Variables:
# $dateObj (Date) - the modification date and time of the annotation
pdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }
## Password

Expand Down Expand Up @@ -410,8 +424,6 @@ pdfjs-editor-new-alt-text-textarea =
pdfjs-editor-new-alt-text-description = Krátky popis pre ľudí, ktorí nevidia obrázok alebo ak sa obrázok nenačíta.
# This is a required legal disclaimer that refers to the automatically created text inside the alt text box above this text. It disappears if the text is edited by a human.
pdfjs-editor-new-alt-text-disclaimer1 = Tento alternatívny text bol vytvorený automaticky a môže byť nepresný.
# This is a required legal disclaimer that refers to the automatically created text inside the alt text box above this text. It disappears if the text is edited by a human.
pdfjs-editor-new-alt-text-disclaimer = Tento alternatívny text bol vytvorený automaticky.
pdfjs-editor-new-alt-text-disclaimer-learn-more-url = Ďalšie informácie
pdfjs-editor-new-alt-text-create-automatically-button-label = Automaticky vytvoriť alternatívny text
pdfjs-editor-new-alt-text-not-now-button = Teraz nie
Expand Down
5 changes: 5 additions & 0 deletions web/locale/uk/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,8 @@ pdfjs-image-alt-text-settings-button-label = Налаштування альте
pdfjs-editor-alt-text-settings-dialog-label = Налаштування альтернативного тексту зображення
pdfjs-editor-alt-text-settings-automatic-title = Автоматичний альтернативний текст
pdfjs-editor-alt-text-settings-create-model-button-label = Автоматично створювати альтернативний текст
pdfjs-editor-alt-text-settings-delete-model-button = Видалити
pdfjs-editor-alt-text-settings-download-model-button = Завантажити
pdfjs-editor-alt-text-settings-downloading-model-button = Завантаження…
pdfjs-editor-alt-text-settings-editor-title = Редактор альтернативного тексту
pdfjs-editor-alt-text-settings-close-button = Закрити
16 changes: 16 additions & 0 deletions web/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@
height:0;
}

.textLayer span[role="img"]{
-webkit-user-select:none;
-moz-user-select:none;
user-select:none;
cursor:default;
}

.textLayer .highlight{
--highlight-bg-color:rgb(180 0 170 / 0.25);
--highlight-selected-bg-color:rgb(0 100 0 / 0.25);
Expand Down Expand Up @@ -1635,6 +1642,10 @@
cursor:var(--editorHighlight-editing-cursor);
}

[role="img"]:is(.textLayer.highlighting:not(.free) span){
cursor:var(--editorFreeHighlight-editing-cursor);
}

.textLayer.highlighting.free span{
cursor:var(--editorFreeHighlight-editing-cursor);
}
Expand Down Expand Up @@ -3071,6 +3082,8 @@
:is(.pdfViewer .canvasWrapper) canvas{
margin:0;
display:block;
width:100%;
height:100%;
}

[hidden]:is(:is(.pdfViewer .canvasWrapper) canvas){
Expand All @@ -3087,6 +3100,9 @@
}

.pdfViewer .page{
--scale-round-x:1px;
--scale-round-y:1px;

direction:ltr;
width:816px;
height:1056px;
Expand Down
Loading

0 comments on commit 9d741c8

Please sign in to comment.