Click here to Skip to main content
11,479,162 members (63,468 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: itextsharp
I created a pdf with a PdfLayer "PdfStampLayer" and now i want to remove the layer or remove the contants of the Layer.

Anyone could suggest how to remove a layer from pdf?

Note: I do not want to remove all layers. Only the layer Named "PdfStampLayer" i want to remove

PdfLayer stampLayer = new PdfLayer("PdfStampLayer", stamp.Writer);
 
            for (int i = 1; i <= pdfReader.NumberOfPages; i++) // Must start at 1 because 0 is not an actual page.
            {
                // change the content on top of page 1
                PdfContentByte cb = stamp.GetOverContent(i);
                cb.BeginLayer(stampLayer);
 
                Rectangle psize = pdfReader.GetPageSize(i);
                float width = psize.Width;
                float height = psize.Height;
 
                BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                VerticalText vt = new VerticalText(cb);
                //NX D size drawing stamping
                vt.SetVerticalLayout(width - 150, height - 68, height, 1, 0);
                vt.AddText(new Phrase("SAMPLE", new Font(bf, 13)));
 
                vt.Go();
 
                vt.SetVerticalLayout(width - 250, height - 68, height, 1, 0);
                vt.AddText(new Phrase("34567", new Font(bf, 13)));
 
                vt.Go();
                cb.EndLayer();
            }
Posted 25-Oct-12 4:37am
Edited 25-Oct-12 8:45am
(no name)70.7K
v2
Comments
Sergey Alexandrovich Kryukov at 25-Oct-12 13:58pm
   
What do you mean by "remove"? You don't want to modify the code (to skip the creation of unwanted layer) but want to modify existing PDF, is that right?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 205
1 F-ES Sitecore 195
2 OriginalGriff 130
3 Frankie-C 120
4 DamithSL 95
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,366
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 25 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100