npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@byzk/document-web-reader

v1.1.2

Published

web文件阅读器

Downloads

140

Readme

在 web 中中阅读文件并对文件进行签章的视图展示库, 底层采用图片进行展示,文件转换功能以及印章操作相关功能需由调用方自行完成,本库只提供基础接口

目录

安装 示例

安装

浏览器中使用

<script src="https://raw.githubusercontent.com/SuLinXin66/bk-web-document-reader/main/dist/index-iife.min.js"></script>

注: 如果要兼容 IE 系列浏览器请引用如下 js

<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js"></script>
<script src="https://raw.githubusercontent.com/SuLinXin66/bk-web-document-reader/main/dist/index-iife-ie.min.js"></script>

npm 中使用

npm install --save @byzk/document-web-reader

yarn 中使用

yarn add @byzk/document-web-reader

示例

浏览器中使用示例

<!DOCTYPE html>
<html lang="zh_CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script type="text/javascript" src="./dist/index-iife-ie.min.js"></script>
    <style>
      #app {
        margin: 0;
        padding: 0;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
      }
    </style>
    <style>
      .seal-list-content:first-child {
        margin-top: 18px;
      }

      .seal-list-content {
        padding: 12px 0;
        transition: all 0.5s;
        cursor: pointer;
      }

      .seal-list-content:hover,
      .seal-list-content.active {
        background-color: rgba(255, 255, 255, 0.8);
      }
    </style>
  </head>

  <body>
    <div id="app">我是APP</div>
    <input accept="application/pdf" type="file" id="file" />
  </body>

  <script>
    window.unitConversion = function () {
      /**
       * 获取DPI
       * @returns {Array}
       */
      this.conversion_getDPI = function () {
        var arrDPI = new Array();
        if (window.screen.deviceXDPI) {
          arrDPI[0] = window.screen.deviceXDPI;
          arrDPI[1] = window.screen.deviceYDPI;
        } else {
          var tmpNode = document.createElement("DIV");
          tmpNode.style.cssText =
            "width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden";
          document.body.appendChild(tmpNode);
          arrDPI[0] = parseInt(tmpNode.offsetWidth);
          arrDPI[1] = parseInt(tmpNode.offsetHeight);
          tmpNode.parentNode.removeChild(tmpNode);
        }
        return arrDPI;
      };
      /**
       * px转换为mm
       * @param value
       * @returns {number}
       */
      this.pxConversionMm = function (value) {
        var inch = value / this.conversion_getDPI()[0];
        var c_value = inch * 33.8;
        //      console.log(c_value);
        return c_value;
      };
      /**
       * mm转换为px
       * @param value
       * @returns {number}
       */
      this.mmConversionPx = function (value) {
        var inch = value / 26.4;
        var c_value = inch * this.conversion_getDPI()[0];
        //      console.log(c_value);
        return c_value;
      };
    };
  </script>
  <script>
    const usbkeyServerUrl = "https://192.168.85.140:48000/api";
    // const usbkeyServerUrl = "https://127.0.0.1:48000/api";
    const unitConversion = new window.unitConversion();
    window.getSealList = async () => {
      try {
        // const passwd = window.prompt("请输入Key密码")
        const passwd = "88888888";
        const getUsbkeyCertAlgResult = await (
          await fetch(`${usbkeyServerUrl}/EPSAPP_GetUsbKeyCertAlg`, {
            method: "post",
          })
        ).json();
        if (getUsbkeyCertAlgResult.code !== 0) {
          throw new Error(getUsbkeyCertAlgResult.msg);
        }

        const serverSealListData = new URLSearchParams();
        serverSealListData.append("password", passwd);
        serverSealListData.append("keyType", getUsbkeyCertAlgResult.keyType);
        const serverSealList = await (
          await fetch(`${usbkeyServerUrl}/EPSAPP_GetServerStampList`, {
            method: "post",
            body: serverSealListData,
          })
        ).json();
        if (serverSealList.code !== 0) {
          throw new Error(serverSealList.msg);
        }
        return serverSealList.sealImgList;
      } catch (e) {
        alert("获取签章列表失败: " + e.message);
      }
    };

    window.addSeal = async (sealInfo) => {
      try {
        debugger;
        const getUsbkeyCertAlgResult = await (
          await fetch(`${usbkeyServerUrl}/EPSAPP_GetUsbKeyCertAlg`, {
            method: "post",
          })
        ).json();
        if (getUsbkeyCertAlgResult.code !== 0) {
          throw getUsbkeyCertAlgResult.msg;
        }

        // fetch(`${usbkeyServerUrl}/EPSAPP_GetFile`, {
        //     method: "post"
        // })

        const x = parseInt(unitConversion.pxConversionMm(sealInfo.x)) + "";
        const y = parseInt(unitConversion.pxConversionMm(sealInfo.y)) + "";

        const signatureStampExData = new URLSearchParams();
        signatureStampExData.append("password", "88888888");
        signatureStampExData.append("file", window.pdfFileBase64);
        signatureStampExData.append("keyType", getUsbkeyCertAlgResult.keyType);
        signatureStampExData.append(
          "qzList",
          JSON.stringify([
            {
              sealID: sealInfo.sealInfo.id,
              pageNum: sealInfo.pageNum + "",
              x,
              y,
            },
          ])
        );
        const signatureStampExResult = await (
          await fetch(`${usbkeyServerUrl}/EPSAPP_SignatureStampEx`, {
            method: "post",
            body: signatureStampExData,
          })
        ).json();
        if (signatureStampExResult.code !== 0) {
          throw new Error(signatureStampExResult.msg);
        }

        const lastFileResult = await (
          await fetch(`${usbkeyServerUrl}/EPSAPP_GetLastFile`, {
            method: "post",
          })
        ).json();
        if (lastFileResult.code !== 0) {
          throw new Error(lastFileResult.msg);
        }

        const signFile = lastFileResult.lastFile;

        const data = new FormData();
        data.append("data", signFile);
        const result = await fetch(
          "http://127.0.0.1:8061/pdf/convert/bas464/png",
          {
            method: "post",
            body: data,
          }
        );
        const jsonData = await result.json();
        if (jsonData.error) {
          throw new Error(jsonData.msg);
        }

        window.pdfFileBase64 = jsonData.result.base64File;

        return jsonData.result;
      } catch (e) {
        alert("添加印章失败 => " + e.message);
        return undefined;
      }
    };
  </script>
  <script>
    window.h = readerLib.snabbdom.h;
    window.onload = function () {
      var reader = readerLib.newReader(document.getElementById("app"));
      const sealContentList = [];

      const readerParam = {
        toolbars: {
          btns: [
            {
              text: "打开",
              on: {
                click: function () {
                  document.getElementById("file").click();
                },
              },
            },
          ],
        },
        sideTollbars: {
          nodes: [
            {
              text: "印章列表",
              imageUrl:
                "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAEltJREFUeF7tnX2MHPV5x59n9lxfjOPdtbFaYptCGqCqgJpAHdwiixdho4jgpCkR0JgYaFDq2/nNnes2kKQilUAESHw3v1k7rSteYiqB6qrFppUAV9ilcQk0dp2kqpS4JSk2L42xd9dgx8S781Rz9hm/3e3M7MzcvHzn33teP8/vq9/OzRtTgkejVrvaKJXmishcIprHInPFMOaSyDwimp1gKUiVfgJ7iXk3u+4eYd5DRLuZeY/b6eyp1utbkyqf40zUGBycL677eyWi64loiRD1x5kPsYtBgIkOE9HzHaLNbBjbqiMjO+PqPHKBtCxriYh8jkSuIuYL4yoccUHgOAGRnxDzd5n5b8u2/XyUZCITyHtDQ5cc6XSGmOiOKAtELBAIQkCIHp9SKg1PHx7+URC/8Wx7FsiBgYFZbqk0RESDRHRWFEUhBgj0SOAgEY0Ync7wjDVr9vUSqyeBtCxrhYh4wriglyLgCwIx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b4e4oICNHGUqdz16kXAruVGFggYwEbpukwc61bAvwdBCabgIjUq45jhqkjtEBGz0uOXnEfxG0pYdDDJwECu5h55ExXyP3m7kkgYz+53FJpiIg8oeAuYL/kYRcngYNENGJ0OsNBf1KdWlTPAhkL6N0qf6TTGcLzJHHOHbG7EfCe55hSKg2feMt6N5+J/h6ZQMaSeE8mukS3MNEiEvloL8XBFwR8EWB+TYheMoieHnsS0JefD6PIBXJizpZpLhDma4noWk8wuGXFx0Rg0pWAd4uIJwgiepFFXiw7zqtdnUIaxCqQU2vyXnNqlEpzRWQuEc1jkbliGHNJZB4+4hNygvl120vMu9l19wjzHiLazcx73E5nT7Ve35pU2/8PRLqBF+byQVsAAAAASUVORK5CYII=",
              on: {
                click: async (event, isOpen) => {
                  if (!isOpen) {
                    return;
                  }
                  const sealList = await window.getSealList();
                  if (!sealList) {
                    return false;
                  }

                  const unitConversion = new window.unitConversion();
                  const width = unitConversion.mmConversionPx(30);
                  const height = unitConversion.mmConversionPx(30);
                  for (let i = 0; i < sealList.length; i++) {
                    const img = new Image();
                    sealList[i].sealImgUrl =
                      "data:image/png;base64," + sealList[i].sealImg;
                    // img.src = sealList[i].sealImgUrl;
                    sealList[i].width = width;
                    sealList[i].height = height;
                    sealList[i].positionBase = "leftBottom";
                  }

                  sealContentList.splice(0, sealList.length);
                  sealList.forEach((seal) => {
                    sealContentList.push({
                      ele: h(
                        "div.seal-list-content",
                        {
                          style: {
                            width: "100%",
                          },
                        },
                        h("img", {
                          props: {
                            src: seal.sealImgUrl,
                          },
                          style: {
                            width: "138px",
                            height: "138px",
                            display: "block",
                            margin: "0 auto",
                          },
                          on: {
                            click: (event) => {
                              event.preventDefault();
                              event.stopPropagation();
                              const ele = event.target.parentElement;

                              const sealListContents = document.getElementsByClassName(
                                "seal-list-content"
                              );
                              for (let sealContent of sealListContents) {
                                if (sealContent === ele) {
                                  continue;
                                }
                                sealContent.className = "";
                              }

                              const className = ele.className;
                              if (className.includes("active")) {
                                ele.className = "seal-list-content";
                                reader.cancelDragSeal();
                                return;
                              }

                              ele.className = "seal-list-content active";
                              reader.dragSeal(seal);
                              // reader.dragSeal({
                              //     sealImgUrl: "https://up.66152.com/allimg/2139/39_88909.jpg",
                              //     width: 138,
                              //     height: 138
                              // })
                            },
                          },
                        })
                      ),
                    });
                  });
                  reader.updateView();
                },
              },
              contents: sealContentList,
            },
          ],
          hide: true,
        },
        // bottomToolbars: {
        //     show: true
        // },
        reader: {
          type: 2,
          page: true,
          zoom: {
            show: true,
          },
          action: {
            loadFileInterface: {
              loadingOk: (loadAllOk, currentLoadPage) => {
                reader.updateView({
                  sideTollbars: {
                    hide: false,
                  },
                });
              },
              filePathConvertPng: async (path) => {
                const result = await fetch(
                  "http://127.0.0.1:8061/pdf/convert/path/png?p=" + path
                );
                const data = await result.json();
                if (data.error) {
                  throw data.msg;
                }
                return data.result;
              },
              fileConvertPng: async (file) => {
                const data = new FormData();
                data.append("file", file);
                const result = await fetch(
                  "http://127.0.0.1:8061/pdf/convert/file/png",
                  {
                    method: "post",
                    body: data,
                  }
                );
                const jsonData = await result.json();
                if (jsonData.error) {
                  throw jsonData.msg;
                }

                window.pdfFileBase64 = jsonData.result.base64File;

                return jsonData.result;
              },
              getPageInfo: async (fileId, currentPage) => {
                const result = await fetch("http://127.0.0.1:8061/get/png", {
                  method: "post",
                  body: JSON.stringify({
                    id: fileId,
                    currentPage: currentPage - 1,
                  }),
                });
                const data = await result.json();
                if (data.error) {
                  throw data.msg;
                }
                return data.result;
              },
            },
            sealInterface: {
              addSeal: async (data) => {
                try {
                  return await window.addSeal(data);
                } catch (e) {}
              },
            },
          },
          sealContextMenu: {
            menuItems: [
              {
                type: "text",
                text: "测试验章",
              },
            ],
          },
        },
      };

      document.getElementById("file").onchange = async function (event) {
        const file = event.target.files[0];
        file.path =
          "/Users/sulinxin/Documents/00-projects/01-博雅中科/02-电子签章应用平台/03-code/02-go/javaseal/test_datas/cs1_temp_temp.pdf";
        reader.updateView({
          sideToolbars: {
            hide: true,
          },
        });

        try {
          await reader.loadFile(file);
        } catch (e) {
          alert("文件加载出错: " + e.message);
          reader.updateView({
            sideToolbars: {
              hide: true,
            },
          });
        } finally {
          event.target.value = "";
        }
      };

      reader.initView(readerParam);
    };
  </script>
</html>