以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 默认打印路径和文件名 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=158507) |
-- 作者:yangwenghd -- 发布时间:2020/11/22 12:30:00 -- 默认打印路径和文件名 老师 可以是打印的时候保存的窗口自己设定默认吗? e.Form.Page.Width =297 \'纸张宽度为100毫米 e.Form.Page.Height =210\'纸张高度为120毫米 e.Form.Page.LeftMargin = 10 \'设置左边距 e.Form.Page.RightMargin = 0 \'设置右边距 e.Form.Page.TopMargin = 20 \'设置上边距 e.Form.Page.BottomMargin = 20 \'设置下边距 Dim grp As WinForm.GroupBox = e.Form.Controls("GroupBox1") Dim doc As PrintDoc = e.Form.GernatePrintDoc(grp) Dim rar As new prt.RenderArea rar.Stacking = prt.StackingRulesEnum.InlineLeftToRight Dim rm As prt.RenderImage rm = New prt.RenderImage \'创建一个图片 rm.Width = 15 \'宽度等于页面宽度 rm.Height = 15 \'高度由图片大小自动决定 rm.Image = GetImage("匹士克logo.png") rm.x = 121 rm.y = 0 Dim ra As New prt.RenderText \'设置文本对象的内容 ra.Text = e.Form.Controls("Label13").text ra.Style.TextAlignHorz = prt.AlignHorzEnum.right ra.Style.TextAlignVert =prt.AlignVertEnum.Bottom ra.Style.Borders.Bottom = New prt.LineDef(1, Color.Black) \'设置底边框 ra.Style.Padding.Bottom = 2 \'底端内容缩进0.5毫米 ra.Style.FontSize = 12 \'字体大小为8磅 ra.Height = 10 Dim rt As New prt.RenderText \'设置文本对象的内容 rt.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'靠右对齐 rt.Style.Borders.Top = New prt.LineDef(1, Color.Black) \'设置底边框 rt.Style.Padding.Top = 0.5 \'底端内容缩进0.5毫米 rt.Style.FontSize = 12 \'字体大小为8磅 rt.Height = 15 rar.Children.Add(rm) \'加入图片到RenderArea中 rar.Children.Add(ra) \'加入文本到RenderArea中 Doc.Pageheader = rar \'作为页眉使用 Doc.PageFooter = rt \'作为页眉使用 doc.PageSetting.Landscape = True \'横向打印 \'设置页眉 doc.Preview() \'预览
[此贴子已经被作者于2020/11/22 12:33:55编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/11/22 21:00:00 -- 无法设定。直接保存pdf可以这样:http://www.foxtable.com/webhelp/topics/2450.htm Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "PDF文件|*.pdf" \'设置筛选器 dlg.InitialDirectory = “自己指定的保存目录” dlg.FileName = tables("表A").current("xx列") & ables("表A").current("xx列2") & “.pdf” If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 上面的打印代码 ……Doc.Pageheader = rar \'作为页眉使用
Doc.PageFooter = rt \'作为页眉使用 doc.PageSetting.Landscape = True \'横向打印 doc.SavePDF(dlg.FileName) End If |
-- 作者:yangwenghd -- 发布时间:2020/11/22 21:14:00 -- 谢谢老师, 老师 现在在你的帮助下可以了,只是可以这个样子吗?老师,就是先预览pdf,然后在弹出确定按钮是否需要保存,感谢 感谢 辛苦你了,感谢 Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "PDF文件|*.pdf" \'设置筛选器 \'dlg.InitialDirectory = "自己指定的保存目录" dlg.InitialDirectory = Tables("客户报价表").Current("报价信息_文件路径") dlg.FileName = Tables("客户报价表").current("客户信息_客户名称") & Tables("客户报价表").current("客户信息_负责采购") & Tables("客户报价表").current("客户信息_客户编号") & ".pdf" If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 e.Form.Page.Width =297 \'纸张宽度为100毫米 e.Form.Page.Height =210\'纸张高度为120毫米 e.Form.Page.LeftMargin = 10 \'设置左边距 e.Form.Page.RightMargin = 0 \'设置右边距 e.Form.Page.TopMargin = 20 \'设置上边距 e.Form.Page.BottomMargin = 20 \'设置下边距 Dim grp As WinForm.GroupBox = e.Form.Controls("GroupBox1") Dim doc As PrintDoc = e.Form.GernatePrintDoc(grp) Dim rar As new prt.RenderArea rar.Stacking = prt.StackingRulesEnum.InlineLeftToRight Dim rm As prt.RenderImage rm = New prt.RenderImage \'创建一个图片 rm.Width = 15 \'宽度等于页面宽度 rm.Height = 15 \'高度由图片大小自动决定 rm.Image = GetImage("匹士克logo.png") rm.x = 121 rm.y = 0 Dim ra As New prt.RenderText \'设置文本对象的内容 ra.Text = e.Form.Controls("Label13").text ra.Style.TextAlignHorz = prt.AlignHorzEnum.right ra.Style.TextAlignVert =prt.AlignVertEnum.Bottom ra.Style.Borders.Bottom = New prt.LineDef(1, Color.Black) \'设置底边框 ra.Style.Padding.Bottom = 2 \'底端内容缩进0.5毫米 ra.Style.FontSize = 12 \'字体大小为8磅 ra.Height = 10 Dim rt As New prt.RenderText \'设置文本对象的内容 rt.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'靠右对齐 rt.Style.Borders.Top = New prt.LineDef(1, Color.Black) \'设置底边框 rt.Style.Padding.Top = 0.5 \'底端内容缩进0.5毫米 rt.Style.FontSize = 12 \'字体大小为8磅 rt.Height = 15 rar.Children.Add(rm) \'加入图片到RenderArea中 rar.Children.Add(ra) \'加入文本到RenderArea中 Doc.Pageheader = rar \'作为页眉使用 Doc.PageFooter = rt \'作为页眉使用 doc.PageSetting.Landscape = True \'横向打印 \'设置页眉 doc.Preview() \'预览 End If |
-- 作者:有点蓝 -- 发布时间:2020/11/22 21:45:00 -- 不能。预览和保存需要分开2个按钮,一个按钮只是预览,一个按钮只是保存 |
-- 作者:yangwenghd -- 发布时间:2020/11/22 22:09:00 -- 谢谢老师,能帮忙看看为什么我点击上面的代码,保存的内容和预览的内容不一样呢,保存为pdf的内容是空白,感谢 感谢 |
-- 作者:有点蓝 -- 发布时间:2020/11/22 22:16:00 -- 预览和保存需要分开2个按钮,不能在预览里保存pdf |
-- 作者:yangwenghd -- 发布时间:2020/11/22 22:22:00 -- 谢谢老师,我是分开了的,现在我就是保存,只是保存后没有生成文件,能再帮忙看看吗? 感谢 感谢 我想只保存,但是现在弹出了窗口,点击保存后并没有文件,感谢 感谢
Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "PDF文件|*.pdf" \'设置筛选器 \'dlg.InitialDirectory = "自己指定的保存目录" dlg.InitialDirectory = Tables("客户报价表").Current("报价信息_文件路径") dlg.FileName = Tables("客户报价表").current("客户信息_客户名称") & Tables("客户报价表").current("客户信息_负责采购") & Tables("客户报价表").current("客户信息_报价编号") & ".pdf" If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 e.Form.Page.Width =297 \'纸张宽度为100毫米 e.Form.Page.Height =210\'纸张高度为120毫米 e.Form.Page.LeftMargin = 10 \'设置左边距 e.Form.Page.RightMargin = 0 \'设置右边距 e.Form.Page.TopMargin = 20 \'设置上边距 e.Form.Page.BottomMargin = 20 \'设置下边距 Dim grp As WinForm.GroupBox = e.Form.Controls("GroupBox1") Dim doc As PrintDoc = e.Form.GernatePrintDoc(grp) Dim rar As new prt.RenderArea rar.Stacking = prt.StackingRulesEnum.InlineLeftToRight Dim rm As prt.RenderImage rm = New prt.RenderImage \'创建一个图片 rm.Width = 15 \'宽度等于页面宽度 rm.Height = 15 \'高度由图片大小自动决定 rm.Image = GetImage("匹士克logo.png") rm.x = 121 rm.y = 0 Dim ra As New prt.RenderText \'设置文本对象的内容 ra.Text = e.Form.Controls("Label13").text ra.Style.TextAlignHorz = prt.AlignHorzEnum.right ra.Style.TextAlignVert =prt.AlignVertEnum.Bottom ra.Style.Borders.Bottom = New prt.LineDef(1, Color.Black) \'设置底边框 ra.Style.Padding.Bottom = 2 \'底端内容缩进0.5毫米 ra.Style.FontSize = 12 \'字体大小为8磅 ra.Height = 10 Dim rt As New prt.RenderText \'设置文本对象的内容 rt.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'靠右对齐 rt.Style.Borders.Top = New prt.LineDef(1, Color.Black) \'设置底边框 rt.Style.Padding.Top = 0.5 \'底端内容缩进0.5毫米 rt.Style.FontSize = 12 \'字体大小为8磅 rt.Height = 15 rar.Children.Add(rm) \'加入图片到RenderArea中 rar.Children.Add(ra) \'加入文本到RenderArea中 Doc.Pageheader = rar \'作为页眉使用 Doc.PageFooter = rt \'作为页眉使用 doc.PageSetting.Landscape = True \'横向打印 \'\'设置页眉 \'doc.Preview() \'预览 End If |
-- 作者:有点蓝 -- 发布时间:2020/11/22 23:02:00 -- 这个是预览,不是保存,请认真看2楼 |
-- 作者:yangwenghd -- 发布时间:2020/11/23 9:22:00 -- 老师 我现在是复制二楼的代码,然后会弹出一个保存框,会输入默认的路径和文件名,然后保存就没有文件了,这个预览只是预览这个窗口了,怎么把pdf的内容保存到这个pdf文件里面呀,感谢 感谢 ,实在是搞不定了,感谢 |
-- 作者:有点蓝 -- 发布时间:2020/11/23 9:32:00 -- 直接保存pdf可以这样:http://www.foxtable.com/webhelp/topics/2450.htm Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "PDF文件|*.pdf" \'设置筛选器 dlg.InitialDirectory = “自己指定的保存目录” dlg.FileName = tables("表A").current("xx列") & ables("表A").current("xx列2") & “.pdf” If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 上面的打印代码 ……Doc.Pageheader = rar \'作为页眉使用
Doc.PageFooter = rt \'作为页眉使用 doc.PageSetting.Landscape = True \'横向打印 doc.SavePDF(dlg.FileName) End If |