查看: 3|回复: 0

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

[复制链接]

0

主题

0

回帖

0

积分

积极分子

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2009-7-22
发表于 2024-6-19 17:37:00 | 显示全部楼层 |阅读模式

PageOffice 国产版 :支持信创系统,支持银河麒麟V10和统信UOS,支持X86(intel、兆芯、海光等)、ARM(飞腾、鲲鹏、麒麟等)芯片架构。

查看本示例演示效果
本示例关键代码的编写位置
Vue+Springboot

注意
本文中展示的代码均为关键代码,复制粘贴到您的项目中,按照实际的情况,例如文档路径,用户名等做适当修改即可使用。

在OA办公、文档流转等各个Web系统中,实现最简单在线查看PDF功能,调用PageOffice只需要几行代码就可以完成。

后端代码

  1. 在后端编写代码调用webOpen方法打开文件。
PDFCtrl pdfCtrl = new PDFCtrl(request);
//pdfCtrl.setAllowCopy(false);//禁止拷贝
pdfCtrl.webOpen("D:\\documents\\test.pdf");
// Linux服务器添加前缀:file://
// pdfCtrl.webOpen("file://"+"/root/documents/test.pdf");

前端代码

  1. 在OnPDFCtrlInit事件中添加按钮(根据实际业务需求处理即可);
	  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);
    },
  1. 实现自定义按钮所调用的js函数;
	  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();
	  },

参考链接:最简单的打开PDF



来源:https://www.cnblogs.com/qq742655/p/18256801
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部