@koi-br/ocr-web-sdk 1.0.32 → 1.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koi-br/ocr-web-sdk",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "一个支持多种Office文件格式预览的Vue3组件SDK,包括PDF、Word、Excel、图片、OFD、TIF等格式",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -123,6 +123,7 @@
123
123
  :key="pageIndex"
124
124
  :data-page-number="pageIndex + 1"
125
125
  class="image-page-container"
126
+ :style="getPageContainerStyle(pageIndex + 1)"
126
127
  >
127
128
  <div
128
129
  class="image-wrapper"
@@ -514,6 +515,35 @@ const getPageBlocksData = (pageNo: number) => {
514
515
  return props.blocksData.filter((block) => block.pageNo === pageNo);
515
516
  };
516
517
 
518
+ // 计算指定页面缩放后的尺寸(考虑旋转)
519
+ const getPageScaledSize = (pageNo: number) => {
520
+ const pageSize = imageSizes.get(pageNo);
521
+ if (!pageSize || pageSize.width === 0 || pageSize.height === 0) {
522
+ return { width: 0, height: 0 };
523
+ }
524
+
525
+ const { width, height } = pageSize;
526
+ const scaledWidth = width * scale.value;
527
+ const scaledHeight = height * scale.value;
528
+
529
+ // 如果旋转了 90 度或 270 度,交换宽高
530
+ const normalizedRotation = ((rotation.value % 360) + 360) % 360;
531
+ const isRotated = normalizedRotation === 90 || normalizedRotation === 270;
532
+
533
+ return {
534
+ width: isRotated ? scaledHeight : scaledWidth,
535
+ height: isRotated ? scaledWidth : scaledHeight,
536
+ };
537
+ };
538
+
539
+ // 获取页面容器的样式(响应式,会根据缩放和旋转自动更新)
540
+ const getPageContainerStyle = (pageNo: number) => {
541
+ const scaledSize = getPageScaledSize(pageNo);
542
+ return {
543
+ height: scaledSize.height > 0 ? `${scaledSize.height}px` : 'auto',
544
+ };
545
+ };
546
+
517
547
  // 隐藏定时器
518
548
  let hideTimer: any = null;
519
549