Hello,

Thanks for your answer.

I've found  !!!!
My watermark is named Watermark (added under Acrobat)

This is my code working.

        Dim myFile As String
        Dim subrep As String
        Dim NewDir As String
        Dim password As String = "scandoc"

        Dim i, j As Integer
        Dim nb_pages As Integer

        Dim dict As New Dictionary(Of String, PdfLayer)()


        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))
        Dim pdf_stamper As New PdfStamper(pdf_reader, New FileStream(myFile, 
System.IO.FileMode.Create))

        nb_pages = pdf_reader.NumberOfPages

        Dim page As PdfDictionary
        Dim annot As PdfLayer



        For i = 1 To nb_pages
            page = pdf_reader.GetPageN(i)

            dict = pdf_stamper.GetPdfLayers

            If dict.Count = 1 Then
                ' "watermark" is here...
                If dict.ContainsKey("Watermark") Then
                    annot = dict("Watermark")
                    annot.On = False
                End If
            End If
        Next

        pdf_reader.Close()
        pdf_stamper.Close()



Thanks !!!



De : iText mailing list [mailto:i...@1t3xt.info]
Envoyé : mardi 20 janvier 2015 15:37
À : Post all your questions about iText here
Objet : Re: [iText-questions] Itext : do not know how to remove watermark 
(filigrane)

You sound like you know more about the nature of the watermark.
Please share that information with us.
For instance:
- is the watermark added as an annotation or as content that is part of the 
content stream?
- if it's part of the content stream, is it part of the same content stream as 
the rest of the content, or is it part of a separate content stream.
- if it's a separate content stream, is there any way to detect that the 
separate content stream contains a watermark?
- is the watermark marked as a watermark, e.g. using Marked Content operators?

Without the answer to these counter-questions, there is NO WAY any one can 
answer your question. You may even be trying to do something that is 
impossible, e.g. if there is no way for a machine to distinguish the watermark 
from other content.

Please note that this mailing-list is about to be closed down.

You should either post your question on StackOverflow, or post it to the issue 
tracker at iText Software. The latter option is only available for iText 
customers.

On 1/20/2015 15:12 PM, Prevost, Sylvain wrote:
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.




------------------------------------------------------------------------------

New Year. New Location. New Benefits. New Data Center in Ashburn, VA.

GigeNET is offering a free month of service with a new server in Ashburn.

Choose from 2 high performing configs, both with 100TB of bandwidth.

Higher redundancy.Lower latency.Increased capacity.Completely compliant.

http://p.sf.net/sfu/gigenet




_______________________________________________

iText-questions mailing list

iText-questions@lists.sourceforge.net<mailto:iText-questions@lists.sourceforge.net>

https://lists.sourceforge.net/lists/listinfo/itext-questions



iText(R) is a registered trademark of 1T3XT BVBA.

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/

Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to