Foxtable(狐表)用户栏目专家坐堂 → 控件打印问题


  共有1898人关注过本帖树形打印复制链接

主题:控件打印问题

帅哥哟,离线,有人找我吗?
aidimeng
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:741 积分:7244 威望:0 精华:0 注册:2015/9/14 14:26:00
控件打印问题  发帖心情 Post By:2018/12/23 13:33:00 [只看该作者]

遇到了两个问题

Dim wb As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
wb.Address=Vars("路径")

1、窗口中的 pdf不能显示,提示 文件保存

2、打印问题

 

在webbrpwser 控件上面 加了个 Label 控件,想把 这两个控件的内容 打在一起

 

使用 Dim doc As PrintDoc = e.Form.GernatePrintDoc()
        doc.Preview()

  只能看到 web中的内容 没有 label的内容

 

 

 

pdf文件的生成

Dim reader As New iTextSharp.text.pdf.PdfReader("c:\test.pdf")
Dim document As New iTextSharp.text.Document(reader.GetPageSizeWithRotation(1))
Dim n As Integer = reader.NumberOfPages
Dim baos As New IO.FileStream("c:\123.pdf", IO.FileMode.Create, IO.FileAccess.Write)
Dim copy As New iTextSharp.text.pdf.PdfCopy(document, baos)

Dim ownerPassword = Encoding.default.GetBytes("12345")
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_SCREENREADERS,False)
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_DEGRADED_PRINTING,False)
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_MODIFY_ANNOTATIONS,False)
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_FILL_IN,False)
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_ASSEMBLY,False)
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_COPY,False)
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_MODIFY_CONTENTS,False)
copy.setEncryption(Nothing, ownerPassword, iTextSharp.text.pdf.PdfWriter.ALLOW_PRINTING,False)
copy.ViewerPreferences = iTextSharp.text.pdf.PdfWriter.HideToolbar Or iTextSharp.text.pdf.PdfWriter.HideMenubar Or iTextSharp.text.pdf.PdfWriter.HideWindowUI
'往pdf中写入内容
document.Open()
For i9 As Integer = 1 To n
Dim page As iTextSharp.text.pdf.PdfImportedPage = copy.GetImportedPage(reader, i9)
copy.AddPage(page)
Next
document.Close()
reader.Close()


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/12/23 16:04:00 [只看该作者]

 

我测试没问题,做一个实例发上来测试。(pdf文件)也要加进来才能测试。

 

 


 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:741 积分:7244 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2018/12/24 9:52:00 [只看该作者]

pdf不能通过web打开 可能与我电脑有关系,但没找到解决办法。担心其他电脑也出现这样的问题 我就换了个思路才处理了

 

将pdf转图片 在打印 ,使用了下面的语句

 Dim p As WinForm.Panel = e.Form. Controls("Panel1")
'Dim p As WinForm.PictureBox = e.Form.Controls("PictureBox1")
e.form.Page.PaperKind = 9 '纸张类型改为A4


e.form.Page.LeftMargin = 0 '设置左边距
e.Form. Page.RightMargin = 1 '设置右边距
e.Form. Page.TopMargin = 0 '设置上边距
e.Form. Page.BottomMargin = 20 '设置下边距


Dim doc As PrintDoc = e.Form. GernatePrintDoc(p)

'Doc.SavePDF("c:\111.pdf")
doc.Preview()
        MessageBox.Show("打印完成")
可是打印处理的效果并不理想,如图

 


此主题相关图片如下:qq图片20181224095053.png
按此在新窗口浏览图片

 

好像 上面的边距控制 不起作用


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/12/24 9:59:00 [只看该作者]

 

不应该有问题,具体实例发上来测试。

 

 


 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:741 积分:7244 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2018/12/24 10:33:00 [只看该作者]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目3.rar

引用

 

谢谢,已上传

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

[此贴子已经被作者于2018/12/24 10:37:26编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/12/24 11:00:00 [只看该作者]

改成

 

        Dim p As WinForm.Panel = e.Form. Controls("Panel1")
        Dim doc As PrintDoc = e.Form. GernatePrintDoc(p)
        For Each c As object In Doc.Body.Children
            If Typeof c Is prt.RenderImage Then
                c.x = 0
                c.y = 0
                c.Width = "Parent.Width" '宽度等于页面宽度
                c.Height = "Auto" '高度由图片大小自动决定
                c.Style.ImageAlign.StretchHorz = False '禁止图片水平拉伸
                c.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '居中显示
            End If
        Next
        doc.Preview()

 

或者 http://www.foxtable.com/webhelp/scr/1182.htm

 


 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:741 积分:7244 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2018/12/24 11:57:00 [只看该作者]

谢谢 我试试

 回到顶部