找回密码
 立即注册

QQ登录

只需一步,快速开始

foxtable
金牌服务用户   /  发表于:2017-4-19 09:04  /   查看:3337  /  回复:3
我通过下面的代码将结果保存为一个PDF文件:
Dim doc As new C1.C1Preview.C1PrintDocument
Dim rt As New C1.C1Preview.RenderText
rt.Text = "Hello GrapeCity"
doc.Body.Children.Add(rt)
Dim exPDF As New C1.C1Preview.Export.PdfExporter
'exPDF.ShowOptions = False '显示对话框
exPDF.Document= doc
expdf.Export("c:\data\test.pdf")

我想问的时,如何通过代码设置密码、禁止编辑、禁止打印等属性:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

3 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2017-4-19 16:01:47
沙发
谢谢您的反馈。
不好意思回复晚了。
您图里提供的内容是默认的。
如果仅仅是不想要展示对话框,那么直接通过C1PrintPreview.FileSave(string filename)方法打印。
如果想要展示对话框,但是又想自定义,那么没有直接的接口来设置。

你就需要自己去定义这段代码逻辑,代码参考:
  1. private void button2_Click(object sender, System.EventArgs e)
  2. {
  3. SaveFileDialog sfd = new SaveFileDialog();
  4. // set up your dialog options here
  5. if (sfd.ShowDialog(this) == DialogResult.OK)
  6. {
  7. // will save as .c1d
  8. this.c1PrintDocument1.Save(sfd.FileName);
  9. // ... or, use this to save as HTML
  10. C1.C1PrintDocument.Export.HtmlExporter exh = new C1.C1PrintDocument.Export.HtmlExporter();
  11. exh.Document = this.c1PrintPreview1.Document;
  12. exh.OutputFileName = sfd.FileName;
  13. // fine-tune other exh options here...
  14. exh.Export();
  15. // ... or this to save as PDF
  16. C1.C1PrintDocument.Export.PdfExporter exp = new C1.C1PrintDocument.Export.PdfExporter();
  17. exp.Document = this.c1PrintPreview1.Document;
  18. exp.OutputFileName = sfd.FileName;
  19. // fine-tune other exp options here...
  20. exp.Export();
  21. }
  22. }
复制代码

请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
foxtable
金牌服务用户   /  发表于:2017-4-21 11:39:36
板凳
我不想显示对话框,我想直接用代码设置。

Dim doc As new C1.C1Preview.C1PrintDocument
Dim rt As New C1.C1Preview.RenderText
rt.Text = "Hello GrapeCity"
doc.Body.Children.Add(rt)
Dim exPDF As New C1.C1Preview.Export.PdfExporter
'如何用代码设置为生成的pdf文件只读
exPDF.Document= doc
expdf.Export("c:\data\test.pdf"
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-4-21 17:54:43
地板
foxtable 发表于 2017-4-21 11:39
我不想显示对话框,我想直接用代码设置。

Dim doc As new C1.C1Preview.C1PrintDocument

不好意思,没有提供这个接口。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部