@file-viewer/renderer-pdf 3.3.5 → 3.3.7
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/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/dist/pdf.js +5 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -36,6 +36,10 @@ const options = {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## Print resolution
|
|
40
|
+
|
|
41
|
+
Set `options.pdf.printScale` to a finite positive number, such as `3`, to request more raster detail for printing. The default is `1.75`, and the renderer may reduce it to stay within the page pixel budget. The scale applies to print output pixels. Paper dimensions, preview zoom, and HTML export resolution stay the same.
|
|
42
|
+
|
|
39
43
|
## PDF URL loading
|
|
40
44
|
|
|
41
45
|
The standard PDF renderer accepts URL sources across Vanilla/Web Component, React, Svelte, jQuery and Vue. `pdf.streaming` defaults to `'same-origin'`; use `true` for a CORS-enabled cross-origin or signed URL and supply `filename: 'document.pdf'` or `type: 'pdf'` when the URL has no extension. The renderer gives that URL directly to PDF.js without a complete core prefetch. Range requests require server support and, across origins, exposed `Accept-Ranges`, `Content-Length` and `Content-Range` response headers.
|
package/README.zh-CN.md
CHANGED
|
@@ -31,6 +31,10 @@ const options = {
|
|
|
31
31
|
}
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
## 打印分辨率
|
|
35
|
+
|
|
36
|
+
通过 `options.pdf.printScale` 设置打印光栅倍率,例如 `3`。默认值为 `1.75`,可填写有限正数。单页像素预算可能降低实际倍率。该参数调节打印像素密度,纸张尺寸、预览缩放和 HTML 导出分辨率不受影响。
|
|
37
|
+
|
|
34
38
|
## PDF URL 读取
|
|
35
39
|
|
|
36
40
|
标准 PDF 渲染器在 Vanilla/Web Component、React、Svelte、jQuery 和 Vue 使用相同的 URL 策略。`pdf.streaming` 默认 `same-origin`;跨域或签名 URL 可显式设为 `true`,无扩展名 URL 同时提供 `filename: 'document.pdf'` 或 `type: 'pdf'`。此时直接交给 PDF.js,不先在 core 完整下载。Range 需要服务端支持;跨域还须通过 CORS 暴露 `Accept-Ranges`、`Content-Length`、`Content-Range`。
|
package/dist/pdf.js
CHANGED
|
@@ -1544,8 +1544,12 @@ export default async function renderPdf(buffer, target, context) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
};
|
|
1546
1546
|
const getPdfExportRatio = (width, height, mode) => {
|
|
1547
|
-
const preferredRatio = mode === 'print' ? 1.75 : 1.5;
|
|
1548
1547
|
const maxRatio = Math.sqrt(PDF_EXPORT_MAX_PAGE_PIXELS / Math.max(width * height, 1));
|
|
1548
|
+
const printScale = options === null || options === void 0 ? void 0 : options.printScale;
|
|
1549
|
+
if (mode === 'print' && typeof printScale === 'number' && Number.isFinite(printScale) && printScale > 0) {
|
|
1550
|
+
return Math.min(Math.max(0.75, printScale), maxRatio);
|
|
1551
|
+
}
|
|
1552
|
+
const preferredRatio = mode === 'print' ? 1.75 : 1.5;
|
|
1549
1553
|
return Math.max(0.75, Math.min(preferredRatio, maxRatio));
|
|
1550
1554
|
};
|
|
1551
1555
|
const getPdfPrintPageSize = async (pageNumber = 1) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-pdf",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone PDF renderer plugin for File Viewer powered by PDF.js.",
|
|
@@ -306,7 +306,7 @@
|
|
|
306
306
|
"THIRD_PARTY_NOTICES.md"
|
|
307
307
|
],
|
|
308
308
|
"dependencies": {
|
|
309
|
-
"@file-viewer/core": "3.3.
|
|
309
|
+
"@file-viewer/core": "3.3.7",
|
|
310
310
|
"@fontsource-variable/noto-sans-sc": "5.3.1"
|
|
311
311
|
},
|
|
312
312
|
"peerDependencies": {
|