以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  PDF文件显示  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=145590)

--  作者:刘林
--  发布时间:2020/2/1 13:26:00
--  PDF文件显示
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
wb.InsertHTML("<script src=\'./js/pdfobject.js\'></script>")
wb.InsertHTML("<div style=\'position:fixed;width:100%;height:120px;top:0px;left:0px;\'>")
wb.InsertHTML("<div style=\'width:100%;height:40px;line-height:40px;margin-top:30px;text-align:center\'>新型冠状病毒感染的肺炎</div>")
wb.InsertHTML("<div style=\'width:100%;height:40px;line-height:40px;text-align:center\'>公众指南</div>")
wb.InsertHTML("</div>")
wb.InsertHTML("<div id=\'dispdf\' style=\'width:100%;heigth:100%;margin-top:100px;border:1px solid red;\'>")
wb.InsertHTML("</div>")
wb.InsertHTML("<script>PDFObject.embed(\'./pdf/gzzl.pdf\', \'#dispdf\');</script>")
e.WriteString(wb.Build)
e.Handled=True

老师,我在网上找了个例子在hbulider中是可以,转到FT中这样试就不显示呢PDF内容呢,哪里有问题,请指教,谢谢
[此贴子已经被作者于2020/2/1 13:27:07编辑过]

--  作者:刘林
--  发布时间:2020/2/1 13:54:00
--  

        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar",".png",".apk",".pdf"
            e.WriteFile(fl)
            Return \'这里必须返回
找到了,是因为没加.pdf

但,现在还有个问题显示PDF文件内容的DIV高度不能控制呢,始终是一个固定高度,我想除了标题外其文件内容在屏的剩余高度显示

--  作者:有点蓝
--  发布时间:2020/2/1 14:42:00
--  
这个应该是由pdfobject.js控制的,不受css影响,自己研究一下:https://www.baidu.com/baidu?word=pdfobject.js
[此贴子已经被作者于2020/2/1 14:42:26编辑过]

--  作者:刘林
--  发布时间:2020/2/1 14:49:00
--  
上面问题解决了,现在又出现移动服务器上手机上测试不显示PDF内容了,要注意些什么,怎么解决
--  作者:有点蓝
--  发布时间:2020/2/1 15:14:00
--  
如果网页可以,手机不行应该就是pdfobject本身的兼容性问题。换个其他组件试试。或者提供下载链接,下载后使用其它应用打开
--  作者:刘林
--  发布时间:2020/2/1 17:27:00
--  
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
wb.InsertHTML("<!DOCTYPE html>")
wb.InsertHTML("<html>")
wb.InsertHTML("<head>")
wb.InsertHTML("<meta charset=\'utf-8\'>")
wb.InsertHTML("<meta name=\'viewport\' c />")
wb.InsertHTML("<title></title>")
wb.InsertHTML("<script src=\'../mui/js/mui.min.js\'></script>")
wb.InsertHTML("<link href=\'../mui/css/mui.css\' rel=\'stylesheet\'/>")
wb.InsertHTML("<script Type=\'text/javascript\' charset=\'utf-8\'>mui.init();</script>")
wb.InsertHTML("</head>")
wb.InsertHTML("<body>")
wb.InsertHTML("<header class=\'mui-bar mui-bar-nav mui-bar-nav-bg\'>")
wb.InsertHTML("<a  id=\'icon-menu\' class=\'mui-action-back mui-icon mui-icon-left-nav mui-pull-left\'></a>")
wb.InsertHTML("<h1 class=\'mui-title\'>新型冠状病毒感染的肺炎公众指南</h1>")
wb.InsertHTML("</header>")
wb.InsertHTML("<div class=\'mui-content\'>")
Dim filename As String
Dim i As Integer
For i = 0 To 64
    filename= "./pdf/gzzl/gzzl_" & Format(i,"00") & ".png"
    wb.InsertHTML("<img src=\'" & filename &"\' alt=\'" & i & "\' style=\'width:100%;margin:4px;\'>")
Next
e.WriteString(wb.Build)
wb.InsertHTML("<script src=\'../mui/js/mui.min.js\'></script>")
e.Handled=True
请问老师:
1、如何能够用手指放大图片。
2、如何能点一张图片就直接显示这个图且能放大

--  作者:有点蓝
--  发布时间:2020/2/1 17:41:00
--  
自己完全定义网页的,请不要使用WeUI,即不要使用wb.InsertHTML,因为WeUI自带了html、head等格式,代码有重复添加,会导致网页异常。

sb.AppendLine("<meta name=\'viewport\' c>")

--  作者:刘林
--  发布时间:2020/2/2 12:02:00
--  
sb.AppendLine("<div id=\'example1\'style=\'height:1200px;\'></div>")
sb.AppendLine("<script src=\'../mui/js/pdfobject.js\'></script>")
sb.AppendLine("<script>PDFObject.embed(\'./pdf/gzzl/yqkxzt.pdf\', \'#example1\');</script>")

老师我测试了在电脑上可以预览下载
但在手机上就不行,我找了个这个看,https://www.cnblogs.com/zdz8207/p/html5-pdf-js.html,懂不起,请老师帮研究下用ft如何实现,因为很需要实现这个东西,谢谢帮忙


--  作者:有点蓝
--  发布时间:2020/2/2 23:49:00
--  
pdf.js这玩意功能很强大,就是用起来非常麻烦,如果看不懂官方的文档,建议还是不要玩了:http://mozilla.github.io/pdf.js/api/draft/module-pdfjsLib.html

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:pdfview.zip


把附件和pdf文件一起放到d:\\web目录里,启动代码改为:
HttpServer.Close
HttpServer.Prefixes.Add("http://192.168.0.1/") ‘改为自己的ip
HttpServer.WebPath = "d:\\web"
HttpServer.Extensions.add(".pdf")
HttpServer.Start()

测试地址:http://192.168.0.1/pdfview.htm

--  作者:刘林
--  发布时间:2020/2/3 7:57:00
--  
Dim e As RequestEventArgs = args(0)
Dim sb As New StringBuilder
sb.AppendLine("<!DOCTYPE html Public \'-//W3C//DTD XHTML 1.0 Transitional//EN\' \'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\'>")
sb.AppendLine("<html>")
sb.AppendLine("<head>")
sb.AppendLine("<meta charset=\'utf-8\'>")
sb.AppendLine("<script Type=\'text/javascript\' language=\'javascript\' src=\'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/build/pdf.js\'></script>")
sb.AppendLine("<script Type=\'text/javascript\' language=\'javascript\' src=\'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/web/pdf_viewer.js\'></script>")
sb.AppendLine("<meta name=\'viewport\' c />")
\'sb.AppendLine("<script src=\'../mui/js/mui.min.js\'></script>")
\'sb.AppendLine("<script src=\'../mui/js/pdfobject.js\'></script>")
\'sb.AppendLine("<link href=\'../mui/css/mui.css\' rel=\'stylesheet\'/>")
\'sb.AppendLine("<script Type=\'text/javascript\' charset=\'utf-8\'>mui.init();</script>")
sb.AppendLine("</head>")
sb.AppendLine("<body>")
sb.AppendLine("<header class=\'mui-bar mui-bar-nav mui-bar-nav-bg\'>")
sb.AppendLine("<a  id=\'icon-menu\' class=\'mui-action-back mui-icon mui-icon-left-nav mui-pull-left\'></a>")
sb.AppendLine("<h1 class=\'mui-title\'>延期开学通知</h1>")
sb.AppendLine("</header>")
\'sb.AppendLine("<div class=\'mui-content\'>")
sb.AppendLine("<div style=\'width:100%;text-align: center;position: fixed;bottom: 10px;\'><button id=\'prev\'>上一页</button><span><span id=\'page_num\'></span> / <span id=\'page_count\'></span></span><button id=\'next\'>下一页</button></div><canvas id=\'the-canvas\'></canvas>")
sb.AppendLine("<script id=\'script\'>var url = \'./pdf/gg1/gg2.pdf\' pdfjsLib.GlobalWorkerOptions.workerSrc = \'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.2.228/build/pdf.worker.js\';var pdfDoc = null,pageNum = 1,pageRendering = False,pageNumPending = null,scale = 1,canvas = document.getElementById(\'the-canvas\'),ctx = canvas.getContext(\'2d\');")
sb.AppendLine("Function renderPage(num) {pageRendering = true;pdfDoc.getPage(num).Then(Function(page) {var viewport = page.getViewport(scale);canvas.height = viewport.height;canvas.width = viewport.width;var renderContext = {canvasContext: ctx,viewport: viewport};")
sb.AppendLine("var renderTask = page.render(renderContext);renderTask.promise.Then(Function() {pageRendering = false;if (pageNumPending !== null) {renderPage(pageNumPending);pageNumPending = null;}});});")
sb.AppendLine("document.getElementById(\'page_num\').textContent = pageNum;}")
sb.AppendLine("Function queueRenderPage(num) {If (pageRendering) {pageNumPending = num;} Else {renderPage(num);}}")
sb.AppendLine("Function onPrevPage() {If (pageNum <= 1) {return;}pageNum--;queueRenderPage(pageNum);}document.getElementById(\'prev\').addEventListener(\'click\', onPrevPage);")
sb.AppendLine("Function onNextPage() {If (pageNum >= pdfDoc.numPages) {return;}pageNum++;queueRenderPage(pageNum);}document.getElementById(\'next\').addEventListener(\'click\', onNextPage);")
sb.AppendLine("pdfjsLib.getDocument(url).Then(Function(pdfDoc_) {pdfDoc = pdfDoc_;document.getElementById(\'page_count\').textContent = pdfDoc.numPages;renderPage(pageNum);});</script>")
sb.AppendLine("</body>")
sb.AppendLine("</html>")
e.WriteString(sb.ToString)
e.Handled=True
老师,我在hbulider测试可以使用,我为了测试将其不动移到FT中就不能显示出文件了呢,请帮看下哪里有问题