@progress/kendo-pdfviewer-common 0.3.4-dev.202410240751 → 0.3.4-dev.202501060756
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/annotations/annotation-editor-layer-builder.js +1 -1
- package/dist/es/annotations/annotation-layer-builder.js +2 -1
- package/dist/es/annotations/annotation-layer.js +1 -1
- package/dist/es/annotations/editors/highlight-editor.js +5 -5
- package/dist/es/widget/page.js +7 -13
- package/dist/es/widget/pdfviewer.js +14 -7
- package/dist/es2015/annotations/annotation-editor-layer-builder.js +1 -1
- package/dist/es2015/annotations/annotation-layer-builder.js +2 -1
- package/dist/es2015/annotations/annotation-layer.js +1 -1
- package/dist/es2015/annotations/editors/highlight-editor.js +5 -5
- package/dist/es2015/widget/page.js +7 -13
- package/dist/es2015/widget/pdfviewer.js +14 -7
- package/dist/npm/annotations/annotation-editor-layer-builder.js +1 -1
- package/dist/npm/annotations/annotation-layer-builder.js +2 -1
- package/dist/npm/annotations/annotation-layer.js +1 -1
- package/dist/npm/annotations/editors/highlight-editor.js +5 -5
- package/dist/npm/widget/page.js +7 -13
- package/dist/npm/widget/pdfviewer.d.ts +3 -1
- package/dist/npm/widget/pdfviewer.js +14 -7
- package/package.json +1 -1
|
@@ -90,7 +90,7 @@ class AnnotationEditorLayerBuilder {
|
|
|
90
90
|
}
|
|
91
91
|
// Create an AnnotationEditor layer div
|
|
92
92
|
const div = (this.div = document.createElement("div"));
|
|
93
|
-
div.className = "k-annotation-editor-layer
|
|
93
|
+
div.className = "k-annotation-editor-layer";
|
|
94
94
|
div.hidden = true;
|
|
95
95
|
div.dir = __classPrivateFieldGet(this, _AnnotationEditorLayerBuilder_uiManager, "f").direction;
|
|
96
96
|
(_a = __classPrivateFieldGet(this, _AnnotationEditorLayerBuilder_onAppend, "f")) === null || _a === void 0 ? void 0 : _a.call(this, div);
|
|
@@ -136,7 +136,8 @@ class AnnotationLayerBuilder {
|
|
|
136
136
|
const pageWidthAnnotationLayer = (pageView[2] || 0) + "px";
|
|
137
137
|
const pageHeightAnnotationLayer = (pageView[3] || 0) + "px";
|
|
138
138
|
const div = convertToHtml(`
|
|
139
|
-
<div class="k-annotation-layer
|
|
139
|
+
<div class="k-annotation-layer"
|
|
140
|
+
data-main-rotation="0"
|
|
140
141
|
style="width: round(var(--scale-factor) * ${pageWidthAnnotationLayer}, 1px);
|
|
141
142
|
height: round(var(--scale-factor) * ${pageHeightAnnotationLayer}, 1px);">
|
|
142
143
|
</div>
|
|
@@ -692,7 +692,7 @@ class LinkAnnotationElement extends AnnotationElement {
|
|
|
692
692
|
}
|
|
693
693
|
// todo: do not render the class as the rendering is yet to be determined
|
|
694
694
|
// this.container.classList.add("linkAnnotation");
|
|
695
|
-
|
|
695
|
+
this.container.classList.add("k-link-annotation");
|
|
696
696
|
if (isBound) {
|
|
697
697
|
this.container.append(link);
|
|
698
698
|
}
|
|
@@ -43,7 +43,7 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
43
43
|
// );
|
|
44
44
|
// }
|
|
45
45
|
constructor(params) {
|
|
46
|
-
super(Object.assign(Object.assign({}, params), { name: "k-highlight-editor
|
|
46
|
+
super(Object.assign(Object.assign({}, params), { name: "k-highlight-editor" }));
|
|
47
47
|
_HighlightEditor_instances.add(this);
|
|
48
48
|
// todo: props
|
|
49
49
|
this.color = "";
|
|
@@ -195,14 +195,14 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
195
195
|
/** @inheritdoc */
|
|
196
196
|
disableEditing() {
|
|
197
197
|
super.disableEditing();
|
|
198
|
-
this.div.classList.toggle("disabled", true);
|
|
199
|
-
|
|
198
|
+
// this.div.classList.toggle("disabled", true);
|
|
199
|
+
this.div.classList.toggle("k-highlight-editor-disabled", true);
|
|
200
200
|
}
|
|
201
201
|
/** @inheritdoc */
|
|
202
202
|
enableEditing() {
|
|
203
203
|
super.enableEditing();
|
|
204
|
-
this.div.classList.toggle("disabled", false);
|
|
205
|
-
|
|
204
|
+
// this.div.classList.toggle("disabled", false);
|
|
205
|
+
this.div.classList.toggle("k-highlight-editor-disabled", false);
|
|
206
206
|
}
|
|
207
207
|
/** @inheritdoc */
|
|
208
208
|
fixAndSetPosition() {
|
package/dist/es/widget/page.js
CHANGED
|
@@ -137,11 +137,10 @@ export class Page extends Component {
|
|
|
137
137
|
const canvas = this.canvasForPrint;
|
|
138
138
|
const printContentLoadPromise = this.createPromise();
|
|
139
139
|
const printContent = new Image();
|
|
140
|
+
const printUnits = this.pdfViewer.getPrintUnits();
|
|
140
141
|
const viewportRawDimensions = this.viewport.rawDims;
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
// const pageWidth = this.viewport.width;
|
|
144
|
-
// const pageHeight = this.viewport.height;
|
|
142
|
+
const pageHeight = Math.floor(viewportRawDimensions.pageHeight * printUnits);
|
|
143
|
+
const pageWidth = Math.floor(viewportRawDimensions.pageWidth * printUnits);
|
|
145
144
|
printContent.src = canvas.toDataURL();
|
|
146
145
|
printContent.width = pageWidth;
|
|
147
146
|
printContent.height = pageHeight;
|
|
@@ -186,14 +185,11 @@ export class Page extends Component {
|
|
|
186
185
|
}
|
|
187
186
|
renderForPrintAsync() {
|
|
188
187
|
var _a, _b;
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
// viewport,
|
|
192
|
-
// pageElement,
|
|
193
|
-
// _styles
|
|
194
|
-
} = this.pdfViewer.createPageElements({
|
|
188
|
+
const printUnits = this.pdfViewer.getPrintUnits();
|
|
189
|
+
const { canvasContext, canvas } = this.pdfViewer.createPageElements({
|
|
195
190
|
pdfPage: this.pdfPage,
|
|
196
|
-
zoom:
|
|
191
|
+
zoom: 1,
|
|
192
|
+
printUnits
|
|
197
193
|
});
|
|
198
194
|
this.canvasForPrint = canvas;
|
|
199
195
|
// canvasWrapper.appendChild(canvas);
|
|
@@ -201,14 +197,12 @@ export class Page extends Component {
|
|
|
201
197
|
this.setState({
|
|
202
198
|
isPrintingInProgress: true
|
|
203
199
|
});
|
|
204
|
-
const printUnits = this.pdfViewer.options.printResolution / PixelsPerInch.PDF;
|
|
205
200
|
const optionalContentConfigPromise = this.pdfViewer.state.pdfDocument.getOptionalContentConfig({
|
|
206
201
|
intent: "print",
|
|
207
202
|
});
|
|
208
203
|
const renderContext = {
|
|
209
204
|
canvasContext: canvasContext,
|
|
210
205
|
transform: [printUnits, 0, 0, printUnits, 0, 0],
|
|
211
|
-
// viewport: this.pdfPage.getViewport({ scale: 1, rotation: size.rotation }),
|
|
212
206
|
viewport: this.pdfPage.getViewport({ scale: 1, rotation: this.viewport.rotation }),
|
|
213
207
|
intent: "print",
|
|
214
208
|
annotationMode: AnnotationMode.ENABLE_STORAGE,
|
|
@@ -59,7 +59,7 @@ export class PdfViewer extends Component {
|
|
|
59
59
|
// values higher than 200ms can result in browser zoom
|
|
60
60
|
pageWheelThrottleDelay: 200,
|
|
61
61
|
// ported from pdf.js
|
|
62
|
-
printResolution:
|
|
62
|
+
printResolution: 100,
|
|
63
63
|
loadOnDemand: false,
|
|
64
64
|
loadOnDemandPageSize: 2,
|
|
65
65
|
messages: {
|
|
@@ -325,6 +325,9 @@ export class PdfViewer extends Component {
|
|
|
325
325
|
}
|
|
326
326
|
updater();
|
|
327
327
|
}
|
|
328
|
+
getPrintUnits() {
|
|
329
|
+
return this.options.printResolution / PixelsPerInch.PDF;
|
|
330
|
+
}
|
|
328
331
|
extendOptions(options) {
|
|
329
332
|
this.options = deepExtend(this.options, options);
|
|
330
333
|
}
|
|
@@ -723,13 +726,13 @@ export class PdfViewer extends Component {
|
|
|
723
726
|
return this.pages[index].element;
|
|
724
727
|
});
|
|
725
728
|
}
|
|
726
|
-
createPageElements({ pdfPage = null, zoom = 1, }) {
|
|
729
|
+
createPageElements({ pdfPage = null, zoom = 1, printUnits = null }) {
|
|
727
730
|
if (zoom <= 0) {
|
|
728
731
|
return;
|
|
729
732
|
}
|
|
730
|
-
const
|
|
731
|
-
const scaleNum = zoom ||
|
|
732
|
-
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale:
|
|
733
|
+
const scale = getScale();
|
|
734
|
+
const scaleNum = zoom || scale;
|
|
735
|
+
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
|
|
733
736
|
const { adjustedWidth, adjustedHeight, adjustRatio } = adjustCanvasSize(viewport.width, viewport.height);
|
|
734
737
|
// const styles = {
|
|
735
738
|
// width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
|
|
@@ -750,6 +753,10 @@ export class PdfViewer extends Component {
|
|
|
750
753
|
});
|
|
751
754
|
canvas.height = adjustedHeight;
|
|
752
755
|
canvas.width = adjustedWidth;
|
|
756
|
+
if (printUnits) {
|
|
757
|
+
canvas.width = Math.floor(canvas.width * (printUnits || 1));
|
|
758
|
+
canvas.height = Math.floor(canvas.height * (printUnits || 1));
|
|
759
|
+
}
|
|
753
760
|
const canvasContext = canvas.getContext("2d");
|
|
754
761
|
const canvasWrapper = convertToHtml(`
|
|
755
762
|
<div class="${this.options.elementSelectors.pageCanvasWrapper}"></div>
|
|
@@ -1105,8 +1112,8 @@ export class PdfViewer extends Component {
|
|
|
1105
1112
|
}
|
|
1106
1113
|
openPrintDialog() {
|
|
1107
1114
|
const pages = this.pages;
|
|
1108
|
-
const width = pages[0].rawWidth;
|
|
1109
|
-
const height = pages[0].rawHeight;
|
|
1115
|
+
const width = pages[0].rawWidth * this.getPrintUnits();
|
|
1116
|
+
const height = pages[0].rawHeight * this.getPrintUnits();
|
|
1110
1117
|
const printDialog = window.open('', '', 'innerWidth=' + width + ',innerHeight=' + height + 'location=no,titlebar=no,toolbar=no');
|
|
1111
1118
|
if (!printDialog || !printDialog.document) {
|
|
1112
1119
|
this.triggerError({
|
|
@@ -90,7 +90,7 @@ class AnnotationEditorLayerBuilder {
|
|
|
90
90
|
}
|
|
91
91
|
// Create an AnnotationEditor layer div
|
|
92
92
|
const div = (this.div = document.createElement("div"));
|
|
93
|
-
div.className = "k-annotation-editor-layer
|
|
93
|
+
div.className = "k-annotation-editor-layer";
|
|
94
94
|
div.hidden = true;
|
|
95
95
|
div.dir = __classPrivateFieldGet(this, _AnnotationEditorLayerBuilder_uiManager, "f").direction;
|
|
96
96
|
(_a = __classPrivateFieldGet(this, _AnnotationEditorLayerBuilder_onAppend, "f")) === null || _a === void 0 ? void 0 : _a.call(this, div);
|
|
@@ -136,7 +136,8 @@ class AnnotationLayerBuilder {
|
|
|
136
136
|
const pageWidthAnnotationLayer = (pageView[2] || 0) + "px";
|
|
137
137
|
const pageHeightAnnotationLayer = (pageView[3] || 0) + "px";
|
|
138
138
|
const div = convertToHtml(`
|
|
139
|
-
<div class="k-annotation-layer
|
|
139
|
+
<div class="k-annotation-layer"
|
|
140
|
+
data-main-rotation="0"
|
|
140
141
|
style="width: round(var(--scale-factor) * ${pageWidthAnnotationLayer}, 1px);
|
|
141
142
|
height: round(var(--scale-factor) * ${pageHeightAnnotationLayer}, 1px);">
|
|
142
143
|
</div>
|
|
@@ -692,7 +692,7 @@ class LinkAnnotationElement extends AnnotationElement {
|
|
|
692
692
|
}
|
|
693
693
|
// todo: do not render the class as the rendering is yet to be determined
|
|
694
694
|
// this.container.classList.add("linkAnnotation");
|
|
695
|
-
|
|
695
|
+
this.container.classList.add("k-link-annotation");
|
|
696
696
|
if (isBound) {
|
|
697
697
|
this.container.append(link);
|
|
698
698
|
}
|
|
@@ -43,7 +43,7 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
43
43
|
// );
|
|
44
44
|
// }
|
|
45
45
|
constructor(params) {
|
|
46
|
-
super(Object.assign(Object.assign({}, params), { name: "k-highlight-editor
|
|
46
|
+
super(Object.assign(Object.assign({}, params), { name: "k-highlight-editor" }));
|
|
47
47
|
_HighlightEditor_instances.add(this);
|
|
48
48
|
// todo: props
|
|
49
49
|
this.color = "";
|
|
@@ -195,14 +195,14 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
195
195
|
/** @inheritdoc */
|
|
196
196
|
disableEditing() {
|
|
197
197
|
super.disableEditing();
|
|
198
|
-
this.div.classList.toggle("disabled", true);
|
|
199
|
-
|
|
198
|
+
// this.div.classList.toggle("disabled", true);
|
|
199
|
+
this.div.classList.toggle("k-highlight-editor-disabled", true);
|
|
200
200
|
}
|
|
201
201
|
/** @inheritdoc */
|
|
202
202
|
enableEditing() {
|
|
203
203
|
super.enableEditing();
|
|
204
|
-
this.div.classList.toggle("disabled", false);
|
|
205
|
-
|
|
204
|
+
// this.div.classList.toggle("disabled", false);
|
|
205
|
+
this.div.classList.toggle("k-highlight-editor-disabled", false);
|
|
206
206
|
}
|
|
207
207
|
/** @inheritdoc */
|
|
208
208
|
fixAndSetPosition() {
|
|
@@ -137,11 +137,10 @@ export class Page extends Component {
|
|
|
137
137
|
const canvas = this.canvasForPrint;
|
|
138
138
|
const printContentLoadPromise = this.createPromise();
|
|
139
139
|
const printContent = new Image();
|
|
140
|
+
const printUnits = this.pdfViewer.getPrintUnits();
|
|
140
141
|
const viewportRawDimensions = this.viewport.rawDims;
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
// const pageWidth = this.viewport.width;
|
|
144
|
-
// const pageHeight = this.viewport.height;
|
|
142
|
+
const pageHeight = Math.floor(viewportRawDimensions.pageHeight * printUnits);
|
|
143
|
+
const pageWidth = Math.floor(viewportRawDimensions.pageWidth * printUnits);
|
|
145
144
|
printContent.src = canvas.toDataURL();
|
|
146
145
|
printContent.width = pageWidth;
|
|
147
146
|
printContent.height = pageHeight;
|
|
@@ -186,14 +185,11 @@ export class Page extends Component {
|
|
|
186
185
|
}
|
|
187
186
|
renderForPrintAsync() {
|
|
188
187
|
var _a, _b;
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
// viewport,
|
|
192
|
-
// pageElement,
|
|
193
|
-
// _styles
|
|
194
|
-
} = this.pdfViewer.createPageElements({
|
|
188
|
+
const printUnits = this.pdfViewer.getPrintUnits();
|
|
189
|
+
const { canvasContext, canvas } = this.pdfViewer.createPageElements({
|
|
195
190
|
pdfPage: this.pdfPage,
|
|
196
|
-
zoom:
|
|
191
|
+
zoom: 1,
|
|
192
|
+
printUnits
|
|
197
193
|
});
|
|
198
194
|
this.canvasForPrint = canvas;
|
|
199
195
|
// canvasWrapper.appendChild(canvas);
|
|
@@ -201,14 +197,12 @@ export class Page extends Component {
|
|
|
201
197
|
this.setState({
|
|
202
198
|
isPrintingInProgress: true
|
|
203
199
|
});
|
|
204
|
-
const printUnits = this.pdfViewer.options.printResolution / PixelsPerInch.PDF;
|
|
205
200
|
const optionalContentConfigPromise = this.pdfViewer.state.pdfDocument.getOptionalContentConfig({
|
|
206
201
|
intent: "print",
|
|
207
202
|
});
|
|
208
203
|
const renderContext = {
|
|
209
204
|
canvasContext: canvasContext,
|
|
210
205
|
transform: [printUnits, 0, 0, printUnits, 0, 0],
|
|
211
|
-
// viewport: this.pdfPage.getViewport({ scale: 1, rotation: size.rotation }),
|
|
212
206
|
viewport: this.pdfPage.getViewport({ scale: 1, rotation: this.viewport.rotation }),
|
|
213
207
|
intent: "print",
|
|
214
208
|
annotationMode: AnnotationMode.ENABLE_STORAGE,
|
|
@@ -59,7 +59,7 @@ export class PdfViewer extends Component {
|
|
|
59
59
|
// values higher than 200ms can result in browser zoom
|
|
60
60
|
pageWheelThrottleDelay: 200,
|
|
61
61
|
// ported from pdf.js
|
|
62
|
-
printResolution:
|
|
62
|
+
printResolution: 100,
|
|
63
63
|
loadOnDemand: false,
|
|
64
64
|
loadOnDemandPageSize: 2,
|
|
65
65
|
messages: {
|
|
@@ -325,6 +325,9 @@ export class PdfViewer extends Component {
|
|
|
325
325
|
}
|
|
326
326
|
updater();
|
|
327
327
|
}
|
|
328
|
+
getPrintUnits() {
|
|
329
|
+
return this.options.printResolution / PixelsPerInch.PDF;
|
|
330
|
+
}
|
|
328
331
|
extendOptions(options) {
|
|
329
332
|
this.options = deepExtend(this.options, options);
|
|
330
333
|
}
|
|
@@ -723,13 +726,13 @@ export class PdfViewer extends Component {
|
|
|
723
726
|
return this.pages[index].element;
|
|
724
727
|
});
|
|
725
728
|
}
|
|
726
|
-
createPageElements({ pdfPage = null, zoom = 1, }) {
|
|
729
|
+
createPageElements({ pdfPage = null, zoom = 1, printUnits = null }) {
|
|
727
730
|
if (zoom <= 0) {
|
|
728
731
|
return;
|
|
729
732
|
}
|
|
730
|
-
const
|
|
731
|
-
const scaleNum = zoom ||
|
|
732
|
-
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale:
|
|
733
|
+
const scale = getScale();
|
|
734
|
+
const scaleNum = zoom || scale;
|
|
735
|
+
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
|
|
733
736
|
const { adjustedWidth, adjustedHeight, adjustRatio } = adjustCanvasSize(viewport.width, viewport.height);
|
|
734
737
|
// const styles = {
|
|
735
738
|
// width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
|
|
@@ -750,6 +753,10 @@ export class PdfViewer extends Component {
|
|
|
750
753
|
});
|
|
751
754
|
canvas.height = adjustedHeight;
|
|
752
755
|
canvas.width = adjustedWidth;
|
|
756
|
+
if (printUnits) {
|
|
757
|
+
canvas.width = Math.floor(canvas.width * (printUnits || 1));
|
|
758
|
+
canvas.height = Math.floor(canvas.height * (printUnits || 1));
|
|
759
|
+
}
|
|
753
760
|
const canvasContext = canvas.getContext("2d");
|
|
754
761
|
const canvasWrapper = convertToHtml(`
|
|
755
762
|
<div class="${this.options.elementSelectors.pageCanvasWrapper}"></div>
|
|
@@ -1105,8 +1112,8 @@ export class PdfViewer extends Component {
|
|
|
1105
1112
|
}
|
|
1106
1113
|
openPrintDialog() {
|
|
1107
1114
|
const pages = this.pages;
|
|
1108
|
-
const width = pages[0].rawWidth;
|
|
1109
|
-
const height = pages[0].rawHeight;
|
|
1115
|
+
const width = pages[0].rawWidth * this.getPrintUnits();
|
|
1116
|
+
const height = pages[0].rawHeight * this.getPrintUnits();
|
|
1110
1117
|
const printDialog = window.open('', '', 'innerWidth=' + width + ',innerHeight=' + height + 'location=no,titlebar=no,toolbar=no');
|
|
1111
1118
|
if (!printDialog || !printDialog.document) {
|
|
1112
1119
|
this.triggerError({
|
|
@@ -93,7 +93,7 @@ class AnnotationEditorLayerBuilder {
|
|
|
93
93
|
}
|
|
94
94
|
// Create an AnnotationEditor layer div
|
|
95
95
|
const div = (this.div = document.createElement("div"));
|
|
96
|
-
div.className = "k-annotation-editor-layer
|
|
96
|
+
div.className = "k-annotation-editor-layer";
|
|
97
97
|
div.hidden = true;
|
|
98
98
|
div.dir = tslib_1.__classPrivateFieldGet(this, _AnnotationEditorLayerBuilder_uiManager, "f").direction;
|
|
99
99
|
(_a = tslib_1.__classPrivateFieldGet(this, _AnnotationEditorLayerBuilder_onAppend, "f")) === null || _a === void 0 ? void 0 : _a.call(this, div);
|
|
@@ -139,7 +139,8 @@ class AnnotationLayerBuilder {
|
|
|
139
139
|
const pageWidthAnnotationLayer = (pageView[2] || 0) + "px";
|
|
140
140
|
const pageHeightAnnotationLayer = (pageView[3] || 0) + "px";
|
|
141
141
|
const div = (0, core_1.convertToHtml)(`
|
|
142
|
-
<div class="k-annotation-layer
|
|
142
|
+
<div class="k-annotation-layer"
|
|
143
|
+
data-main-rotation="0"
|
|
143
144
|
style="width: round(var(--scale-factor) * ${pageWidthAnnotationLayer}, 1px);
|
|
144
145
|
height: round(var(--scale-factor) * ${pageHeightAnnotationLayer}, 1px);">
|
|
145
146
|
</div>
|
|
@@ -695,7 +695,7 @@ class LinkAnnotationElement extends AnnotationElement {
|
|
|
695
695
|
}
|
|
696
696
|
// todo: do not render the class as the rendering is yet to be determined
|
|
697
697
|
// this.container.classList.add("linkAnnotation");
|
|
698
|
-
|
|
698
|
+
this.container.classList.add("k-link-annotation");
|
|
699
699
|
if (isBound) {
|
|
700
700
|
this.container.append(link);
|
|
701
701
|
}
|
|
@@ -43,7 +43,7 @@ class HighlightEditor extends annotation_editor_1.AnnotationEditor {
|
|
|
43
43
|
// );
|
|
44
44
|
// }
|
|
45
45
|
constructor(params) {
|
|
46
|
-
super(Object.assign(Object.assign({}, params), { name: "k-highlight-editor
|
|
46
|
+
super(Object.assign(Object.assign({}, params), { name: "k-highlight-editor" }));
|
|
47
47
|
_HighlightEditor_instances.add(this);
|
|
48
48
|
// todo: props
|
|
49
49
|
this.color = "";
|
|
@@ -195,14 +195,14 @@ class HighlightEditor extends annotation_editor_1.AnnotationEditor {
|
|
|
195
195
|
/** @inheritdoc */
|
|
196
196
|
disableEditing() {
|
|
197
197
|
super.disableEditing();
|
|
198
|
-
this.div.classList.toggle("disabled", true);
|
|
199
|
-
|
|
198
|
+
// this.div.classList.toggle("disabled", true);
|
|
199
|
+
this.div.classList.toggle("k-highlight-editor-disabled", true);
|
|
200
200
|
}
|
|
201
201
|
/** @inheritdoc */
|
|
202
202
|
enableEditing() {
|
|
203
203
|
super.enableEditing();
|
|
204
|
-
this.div.classList.toggle("disabled", false);
|
|
205
|
-
|
|
204
|
+
// this.div.classList.toggle("disabled", false);
|
|
205
|
+
this.div.classList.toggle("k-highlight-editor-disabled", false);
|
|
206
206
|
}
|
|
207
207
|
/** @inheritdoc */
|
|
208
208
|
fixAndSetPosition() {
|
package/dist/npm/widget/page.js
CHANGED
|
@@ -137,11 +137,10 @@ class Page extends component_1.Component {
|
|
|
137
137
|
const canvas = this.canvasForPrint;
|
|
138
138
|
const printContentLoadPromise = this.createPromise();
|
|
139
139
|
const printContent = new Image();
|
|
140
|
+
const printUnits = this.pdfViewer.getPrintUnits();
|
|
140
141
|
const viewportRawDimensions = this.viewport.rawDims;
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
// const pageWidth = this.viewport.width;
|
|
144
|
-
// const pageHeight = this.viewport.height;
|
|
142
|
+
const pageHeight = Math.floor(viewportRawDimensions.pageHeight * printUnits);
|
|
143
|
+
const pageWidth = Math.floor(viewportRawDimensions.pageWidth * printUnits);
|
|
145
144
|
printContent.src = canvas.toDataURL();
|
|
146
145
|
printContent.width = pageWidth;
|
|
147
146
|
printContent.height = pageHeight;
|
|
@@ -186,14 +185,11 @@ class Page extends component_1.Component {
|
|
|
186
185
|
}
|
|
187
186
|
renderForPrintAsync() {
|
|
188
187
|
var _a, _b;
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
// viewport,
|
|
192
|
-
// pageElement,
|
|
193
|
-
// _styles
|
|
194
|
-
} = this.pdfViewer.createPageElements({
|
|
188
|
+
const printUnits = this.pdfViewer.getPrintUnits();
|
|
189
|
+
const { canvasContext, canvas } = this.pdfViewer.createPageElements({
|
|
195
190
|
pdfPage: this.pdfPage,
|
|
196
|
-
zoom:
|
|
191
|
+
zoom: 1,
|
|
192
|
+
printUnits
|
|
197
193
|
});
|
|
198
194
|
this.canvasForPrint = canvas;
|
|
199
195
|
// canvasWrapper.appendChild(canvas);
|
|
@@ -201,14 +197,12 @@ class Page extends component_1.Component {
|
|
|
201
197
|
this.setState({
|
|
202
198
|
isPrintingInProgress: true
|
|
203
199
|
});
|
|
204
|
-
const printUnits = this.pdfViewer.options.printResolution / pdf_mjs_1.PixelsPerInch.PDF;
|
|
205
200
|
const optionalContentConfigPromise = this.pdfViewer.state.pdfDocument.getOptionalContentConfig({
|
|
206
201
|
intent: "print",
|
|
207
202
|
});
|
|
208
203
|
const renderContext = {
|
|
209
204
|
canvasContext: canvasContext,
|
|
210
205
|
transform: [printUnits, 0, 0, printUnits, 0, 0],
|
|
211
|
-
// viewport: this.pdfPage.getViewport({ scale: 1, rotation: size.rotation }),
|
|
212
206
|
viewport: this.pdfPage.getViewport({ scale: 1, rotation: this.viewport.rotation }),
|
|
213
207
|
intent: "print",
|
|
214
208
|
annotationMode: pdf_mjs_1.AnnotationMode.ENABLE_STORAGE,
|
|
@@ -42,6 +42,7 @@ export declare class PdfViewer extends Component {
|
|
|
42
42
|
});
|
|
43
43
|
get annotationEditorMode(): any;
|
|
44
44
|
set annotationEditorMode({ mode, editId, isFromKeyboard }: any);
|
|
45
|
+
getPrintUnits(): number;
|
|
45
46
|
extendOptions(options: any): void;
|
|
46
47
|
setOptions(options: any): void;
|
|
47
48
|
bindEvents(): void;
|
|
@@ -85,9 +86,10 @@ export declare class PdfViewer extends Component {
|
|
|
85
86
|
drawPageAsync({ pageIndex }: {
|
|
86
87
|
pageIndex?: number;
|
|
87
88
|
}): Promise<HTMLDivElement>;
|
|
88
|
-
createPageElements({ pdfPage, zoom, }: {
|
|
89
|
+
createPageElements({ pdfPage, zoom, printUnits }: {
|
|
89
90
|
pdfPage?: any;
|
|
90
91
|
zoom?: number;
|
|
92
|
+
printUnits?: any;
|
|
91
93
|
}): {
|
|
92
94
|
canvasContext: CanvasRenderingContext2D;
|
|
93
95
|
canvasWrapper: any;
|
|
@@ -62,7 +62,7 @@ class PdfViewer extends main_1.Component {
|
|
|
62
62
|
// values higher than 200ms can result in browser zoom
|
|
63
63
|
pageWheelThrottleDelay: 200,
|
|
64
64
|
// ported from pdf.js
|
|
65
|
-
printResolution:
|
|
65
|
+
printResolution: 100,
|
|
66
66
|
loadOnDemand: false,
|
|
67
67
|
loadOnDemandPageSize: 2,
|
|
68
68
|
messages: {
|
|
@@ -328,6 +328,9 @@ class PdfViewer extends main_1.Component {
|
|
|
328
328
|
}
|
|
329
329
|
updater();
|
|
330
330
|
}
|
|
331
|
+
getPrintUnits() {
|
|
332
|
+
return this.options.printResolution / pdf_mjs_1.PixelsPerInch.PDF;
|
|
333
|
+
}
|
|
331
334
|
extendOptions(options) {
|
|
332
335
|
this.options = (0, main_1.deepExtend)(this.options, options);
|
|
333
336
|
}
|
|
@@ -726,13 +729,13 @@ class PdfViewer extends main_1.Component {
|
|
|
726
729
|
return this.pages[index].element;
|
|
727
730
|
});
|
|
728
731
|
}
|
|
729
|
-
createPageElements({ pdfPage = null, zoom = 1, }) {
|
|
732
|
+
createPageElements({ pdfPage = null, zoom = 1, printUnits = null }) {
|
|
730
733
|
if (zoom <= 0) {
|
|
731
734
|
return;
|
|
732
735
|
}
|
|
733
|
-
const
|
|
734
|
-
const scaleNum = zoom ||
|
|
735
|
-
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale:
|
|
736
|
+
const scale = (0, utils_1.scale)();
|
|
737
|
+
const scaleNum = zoom || scale;
|
|
738
|
+
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
|
|
736
739
|
const { adjustedWidth, adjustedHeight, adjustRatio } = (0, utils_1.adjustCanvasSize)(viewport.width, viewport.height);
|
|
737
740
|
// const styles = {
|
|
738
741
|
// width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
|
|
@@ -753,6 +756,10 @@ class PdfViewer extends main_1.Component {
|
|
|
753
756
|
});
|
|
754
757
|
canvas.height = adjustedHeight;
|
|
755
758
|
canvas.width = adjustedWidth;
|
|
759
|
+
if (printUnits) {
|
|
760
|
+
canvas.width = Math.floor(canvas.width * (printUnits || 1));
|
|
761
|
+
canvas.height = Math.floor(canvas.height * (printUnits || 1));
|
|
762
|
+
}
|
|
756
763
|
const canvasContext = canvas.getContext("2d");
|
|
757
764
|
const canvasWrapper = (0, main_1.convertToHtml)(`
|
|
758
765
|
<div class="${this.options.elementSelectors.pageCanvasWrapper}"></div>
|
|
@@ -1108,8 +1115,8 @@ class PdfViewer extends main_1.Component {
|
|
|
1108
1115
|
}
|
|
1109
1116
|
openPrintDialog() {
|
|
1110
1117
|
const pages = this.pages;
|
|
1111
|
-
const width = pages[0].rawWidth;
|
|
1112
|
-
const height = pages[0].rawHeight;
|
|
1118
|
+
const width = pages[0].rawWidth * this.getPrintUnits();
|
|
1119
|
+
const height = pages[0].rawHeight * this.getPrintUnits();
|
|
1113
1120
|
const printDialog = window.open('', '', 'innerWidth=' + width + ',innerHeight=' + height + 'location=no,titlebar=no,toolbar=no');
|
|
1114
1121
|
if (!printDialog || !printDialog.document) {
|
|
1115
1122
|
this.triggerError({
|
package/package.json
CHANGED