You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have stumbled upon a project which uses pdf version 2.5.207. In this project, three of the core libraries pdf.js, pdf.worker.js and pdf_viewer.js and the CSS file pdf_viewer.css are downloaded from CDN and used locally. pdf.js have been modified slightly to change the CSS of the free text annotation
class FreeTextAnnotationElement extends AnnotationElement {
constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
super(parameters, isRenderable, true);
}
render() {
this.container.className = "freeTextAnnotation";
if (this.data.contents === " SPECIMEN ") {
this.container.style.fontWeight = "bold"
this.container.style.color = "rgba(255,255,255,0.4)"
this.container.style.overflow = "hidden";
this.container.style.textAlign = "center"
} else {
this.container.style.color = "white"
this.container.style.textAlign = "center"
}
this.container.style.fontSize = '9px';
// this.container.style.paddingLeft = '4px'
this.container.innerHTML = this.data.contents
this.container.setAttribute("data-grayed-annot", this.data.isGrayedAnnot);
const color = this.data.color
const colorShadeDifference = 51
if (color) {
const r = color[0] + colorShadeDifference;
const g = color[1] + colorShadeDifference;
const b = color[2] + colorShadeDifference;
this.container.style.backgroundColor = `rgba(${r},${g},${b},${this.data.ca})`;
if (this.data.isGrayedAnnot) {
this.container.style.borderBottom = "2px solid rgba(0,255,0,0.4)";
// If the annotation is modified then change the color to green
if (this.data.modificationDate != undefined) {
this.container.style.backgroundColor = "rgba(0,255,0,0.4)";
}
this.container.ondblclick = () => {
let lightBlueColor = "rgba(0,0,255,0.4)";
this.container.style.backgroundColor = lightBlueColor;
this.container.setAttribute('data-annot-changed', 'true')
annotationHelper.saveChangedAnnotProperties(this.container, {color: lightBlueColor});
pageHelper.findOutPageElement(this.container).pageElement.setAttribute('data-page-changed', 'true');
actionHistory.push(handleSuggestion.reverseSuggestionEvent(this.container));
};
}
} else {
this.container.style.backgroundColor = "rgba(0,255,0,0.4)";
}
return this.container;
}
and this is how pdf is rendered there
loadPDFViewer = () => {
const pdfContainer = document.getElementById('viewerContainer')
const pdfViewer = window.pdfjsViewer.PDFViewer({
container: pdfContainer,
eventBus: window.pdfjsViewer.EventBus()
});
window.pdfViewer = pdfViewer;
}
and then use
window.pdfjsLib.getDocument(url-of-document)
There are various issues on the older version like memory leaks on large pdf render. I cannot see priority rendering, only incremental rendering. In addition, no event seems to be available like on page scroll using the above idea for code. window.pdfjsViewer.PDFViewer is also not available as far as I know.
I tried to update to the latest version by looking into the changelog but there are more than 500 commits and around 1422 file changes so I stopped. How do I upgrade this to the latest version? Do you have any suggestions or approaches to upgrading?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have stumbled upon a project which uses pdf version 2.5.207. In this project, three of the core libraries pdf.js, pdf.worker.js and pdf_viewer.js and the CSS file pdf_viewer.css are downloaded from CDN and used locally. pdf.js have been modified slightly to change the CSS of the free text annotation
and this is how pdf is rendered there
There are various issues on the older version like memory leaks on large pdf render. I cannot see priority rendering, only incremental rendering. In addition, no event seems to be available like on page scroll using the above idea for code. window.pdfjsViewer.PDFViewer is also not available as far as I know.
I tried to update to the latest version by looking into the changelog but there are more than 500 commits and around 1422 file changes so I stopped. How do I upgrade this to the latest version? Do you have any suggestions or approaches to upgrading?
Beta Was this translation helpful? Give feedback.
All reactions