Prevost, Sylvain
2015-01-20 14:12:07 UTC
Hello,
This is my code (in VB.Net), using unprotect password process, but I do not know really how to do to remove the watermark and then save my file ...
Please help....
Annots id Nothing ... Which is the property to use ? CONTENTS seems not working also...
The PDF has been generated with Acrobat Std. The watermark is added as a Gif.
Private Sub Remove_Password_PDF(ByVal F_FullName As String, ByVal F_Name As String, ByVal Dir_Out As String)
Dim myFile As String
Dim subrep As String
Dim NewDir As String
Dim password As String = "xxxxxx"
Dim i, j As Integer
Dim nb_pages As Integer
subrep = Get_Dir_File(F_Name)
NewDir = Path.Combine(Dir_Out, subrep)
If Directory.Exists(NewDir) Then
'Ne rien Faire
Else
Directory.CreateDirectory(NewDir)
End If
myFile = Path.Combine(Dir_Out, subrep, F_Name)
Dim pdf_reader As New PdfReader(F_FullName, New System.Text.ASCIIEncoding().GetBytes(password))
nb_pages = pdf_reader.NumberOfPages
Dim page As PdfDictionary
Dim annot As PdfDictionary
Dim annots As PdfArray
Dim content As PdfString
Dim Rcontent As PdfStream
For i = 1 To nb_pages
page = pdf_reader.GetPageN(i)
annots = page.GetAsArray(PdfName.ANNOTS)
If annots IsNot Nothing Then
'Code to add here to remove WaterMark which is the overlayer
End If
Next
Dim pdf_stamper As New PdfStamper(pdf_reader, New FileStream(myFile, System.IO.FileMode.Create))
pdf_reader.Close()
pdf_stamper.Close()
End Sub
________________________________
Recipharm Legal Notice:
The information transmitted may contain confidential material and
is intended only for the person or entity to which it is
addressed. Any review, retransmission, dissemination or other
use of, or taking of any action by persons or entities other than
the intended recipient is prohibited. If you are not the
intended recipient, please delete the information from your
system and contact the sender.
This is my code (in VB.Net), using unprotect password process, but I do not know really how to do to remove the watermark and then save my file ...
Please help....
Annots id Nothing ... Which is the property to use ? CONTENTS seems not working also...
The PDF has been generated with Acrobat Std. The watermark is added as a Gif.
Private Sub Remove_Password_PDF(ByVal F_FullName As String, ByVal F_Name As String, ByVal Dir_Out As String)
Dim myFile As String
Dim subrep As String
Dim NewDir As String
Dim password As String = "xxxxxx"
Dim i, j As Integer
Dim nb_pages As Integer
subrep = Get_Dir_File(F_Name)
NewDir = Path.Combine(Dir_Out, subrep)
If Directory.Exists(NewDir) Then
'Ne rien Faire
Else
Directory.CreateDirectory(NewDir)
End If
myFile = Path.Combine(Dir_Out, subrep, F_Name)
Dim pdf_reader As New PdfReader(F_FullName, New System.Text.ASCIIEncoding().GetBytes(password))
nb_pages = pdf_reader.NumberOfPages
Dim page As PdfDictionary
Dim annot As PdfDictionary
Dim annots As PdfArray
Dim content As PdfString
Dim Rcontent As PdfStream
For i = 1 To nb_pages
page = pdf_reader.GetPageN(i)
annots = page.GetAsArray(PdfName.ANNOTS)
If annots IsNot Nothing Then
'Code to add here to remove WaterMark which is the overlayer
End If
Next
Dim pdf_stamper As New PdfStamper(pdf_reader, New FileStream(myFile, System.IO.FileMode.Create))
pdf_reader.Close()
pdf_stamper.Close()
End Sub
________________________________
Recipharm Legal Notice:
The information transmitted may contain confidential material and
is intended only for the person or entity to which it is
addressed. Any review, retransmission, dissemination or other
use of, or taking of any action by persons or entities other than
the intended recipient is prohibited. If you are not the
intended recipient, please delete the information from your
system and contact the sender.