如何更改打印选项PdfWriter.AllowPrinting [英] How to change printing option PdfWriter.AllowPrinting

查看:228
本文介绍了如何更改打印选项PdfWriter.AllowPrinting的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了以下代码来保护pdf。

但是我忘了允许打印选项。

现在所有受保护的pdf都禁用了打印选项。

是否有任何解决方案可以更改打印选项以允许所有受保护的pdf。

 使用 iTextSharp.text.pdf; 

使用(Stream input = new FileStream(InputFile,FileMode.Open, FileAccess.Read,FileShare.Read))
{
使用(流输出= new FileStream(OutputFile,FileMode.Create,FileAccess.Write,FileShare.None))
{
PdfReader reader = new PdfReader(输入) ;
PdfEncryptor.Encrypt(reader,output, true ,userpwd,masterpwd,PdfWriter.AllowScreenReaders);
}
}

解决方案

嗨!!!

这是怎么回事如果您仍希望加密pdf,则启用打印。

 System.Text.UTF8Encoding encoding =  new  System.Text.UTF8Encoding(); 
writer.SetEncryption( null ,encoding.GetBytes( 12345678),PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING,PdfWriter.STRENGTH40BITS);





refreance:< a href =http://weblog.kevinattard.com/2011/08/itextsharp-disable-pdf-printing.html> http://weblog.kevinattard.com/2011/08/itextsharp-disable-pdf-printing .html [ ^


I had created below code to protect pdf.
But I forgot to allow printing option.
Now printing option is disabled in all my protected pdfs.
Is there any solution to change the printing option to allow for all protected pdfs.

using iTextSharp.text.pdf;

using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
      using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
      {
            PdfReader reader = new PdfReader(input);
            PdfEncryptor.Encrypt(reader, output, true, userpwd, masterpwd,PdfWriter.AllowScreenReaders);
       }
}

解决方案

Hi!!!
And this is how to enable printing if you still want the pdf to be encrypted.

System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
writer.SetEncryption(null, encoding.GetBytes("12345678"), PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING, PdfWriter.STRENGTH40BITS);



refreance:http://weblog.kevinattard.com/2011/08/itextsharp-disable-pdf-printing.html[^]


这篇关于如何更改打印选项PdfWriter.AllowPrinting的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆