大中锋熊二内线肉搏奥尼尔 發表於 2024-6-19 17:37:00

国产linux系统(银河麒麟,统信uos)使用 PageOffice 国产版在线打开 pdf 文件

<p>PageOffice 国产版 :支持信创系统,支持银河麒麟V10和统信UOS,支持X86(intel、兆芯、海光等)、ARM(飞腾、鲲鹏、麒麟等)芯片架构。</p>
<p>查看本示例演示效果<br>
本示例关键代码的编写位置<br>
Vue+Springboot</p>
<blockquote>
<p>注意<br>
本文中展示的代码均为关键代码,复制粘贴到您的项目中,按照实际的情况,例如文档路径,用户名等做适当修改即可使用。</p>
</blockquote>
<p>在OA办公、文档流转等各个Web系统中,实现最简单在线查看PDF功能,调用PageOffice只需要几行代码就可以完成。</p>
<h1 id="后端代码">后端代码</h1>
<ol>
<li>在后端编写代码调用webOpen方法打开文件。</li>
</ol>
<pre><code>PDFCtrl pdfCtrl = new PDFCtrl(request);
//pdfCtrl.setAllowCopy(false);//禁止拷贝
pdfCtrl.webOpen("D:\\documents\\test.pdf");
// Linux服务器添加前缀:file://
// pdfCtrl.webOpen("file://"+"/root/documents/test.pdf");
</code></pre>
<h1 id="前端代码">前端代码</h1>
<ol>
<li>在OnPDFCtrlInit事件中添加按钮(根据实际业务需求处理即可);</li>
</ol>
<pre><code>          OnPDFCtrlInit() {
      //PDF的初始化事件回调函数,您可以在这里添加自定义按钮
                  if(("linux")!=(pdfctrl.ClientOS)){
                        pdfctrl.AddCustomToolButton("隐藏/显示书签", "SetBookmarks()", 0);
                }
                pdfctrl.AddCustomToolButton("打印", "PrintFile()", 6);
                pdfctrl.AddCustomToolButton("-", "", 0);
                pdfctrl.AddCustomToolButton("实际大小", "SetPageReal()", 16);
                pdfctrl.AddCustomToolButton("适合页面", "SetPageFit()", 17);
                pdfctrl.AddCustomToolButton("适合宽度", "SetPageWidth()", 18);
                pdfctrl.AddCustomToolButton("缩小", "ZoomOut()", 17);
                pdfctrl.AddCustomToolButton("放大", "ZoomIn()", 18);
                pdfctrl.AddCustomToolButton("-", "", 0);
                pdfctrl.AddCustomToolButton("首页", "FirstPage()", 8);
                pdfctrl.AddCustomToolButton("上一页", "PreviousPage()", 9);
                pdfctrl.AddCustomToolButton("下一页", "NextPage()", 10);
                pdfctrl.AddCustomToolButton("尾页", "LastPage()", 11);
                pdfctrl.AddCustomToolButton("-", "", 0);
                pdfctrl.AddCustomToolButton("向左旋转90度", "SetRotateLeft()", 12);
                pdfctrl.AddCustomToolButton("向右旋转90度", "SetRotateRight()", 13);
    },
</code></pre>
<ol start="2">
<li>实现自定义按钮所调用的js函数;</li>
</ol>
<pre><code>          SetBookmarks() {
               pdfctrl.BookmarksVisible = !pdfctrl.BookmarksVisible;
          },
          PrintFile() {
               pdfctrl.ShowDialog(4);
          },
          SwitchFullScreen() {
               pdfctrl.FullScreen = !pdfctrl.FullScreen;
          },
          SetPageReal() {
               pdfctrl.SetPageFit(1);
          },
          SetPageFit() {
               pdfctrl.SetPageFit(2);
          },
          SetPageWidth() {
               pdfctrl.SetPageFit(3);
          },
          ZoomIn() {
               pdfctrl.ZoomIn();
          },
          ZoomOut() {
               pdfctrl.ZoomOut();
          },
          FirstPage() {
               pdfctrl.GoToFirstPage();
          },
          PreviousPage() {
               pdfctrl.GoToPreviousPage();
          },
          NextPage() {
               pdfctrl.GoToNextPage();
          },
          LastPage() {
               pdfctrl.GoToLastPage();
          },
          SetRotateRight() {
               pdfctrl.RotateRight();
          },
          SetRotateLeft() {
               pdfctrl.RotateLeft();
          },
</code></pre>
<p>参考链接:最简单的打开PDF</p><br><br>
来源:https://www.cnblogs.com/qq742655/p/18256801
頁: [1]
查看完整版本: 国产linux系统(银河麒麟,统信uos)使用 PageOffice 国产版在线打开 pdf 文件