Foxtable(狐表)用户栏目专家坐堂 → [求助]Savetopdf 生成的pdf修改问题


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

主题:[求助]Savetopdf 生成的pdf修改问题

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


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

 

pdf文件发上来(原来的pdf以及生成的新的d:\123.pdf,一起发上)

 

 


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


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

试试改成

 

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()


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


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

谢谢甜总

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


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


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

执行这段代码后没问题,请认真测试

 

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()


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


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

非常感谢,不能编辑了, 不知道是不是 上面代码的问题

 

现在 在WebBrowser中 不能显示 pdf了, 提示保存文件

[此贴子已经被作者于2018/12/21 17:33:14编辑过]

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


加好友 发短信
等级:六尾狐 帖子:1359 积分:12004 威望:0 精华:0 注册:2012/3/5 11:32:00
  发帖心情 Post By:2021/11/17 17:58:00 [只看该作者]

 老师,请问  这个  如果是 pdf 插入图片  怎么弄呢

 回到顶部
总数 16 上一页 1 2