Пример #1
0
        private void CleanUpPage(int pageNum, IList <PdfCleanUpLocation> cleanUpLocations)
        {
            if (cleanUpLocations.Count == 0)
            {
                return;
            }

            PdfReader      pdfReader = pdfStamper.Reader;
            PdfDictionary  page      = pdfReader.GetPageN(pageNum);
            PdfContentByte canvas    = pdfStamper.GetUnderContent(pageNum);

            byte[] pageContentInput = ContentByteUtils.GetContentBytesForPage(pdfReader, pageNum);
            page.Remove(PdfName.CONTENTS);

            canvas.SaveState();

            PdfCleanUpRegionFilter   filter = CreateFilter(cleanUpLocations);
            PdfCleanUpRenderListener pdfCleanUpRenderListener = new PdfCleanUpRenderListener(pdfStamper, filter);

            pdfCleanUpRenderListener.RegisterNewContext(pdfReader.GetPageResources(page), canvas);

            PdfContentStreamProcessor contentProcessor = new PdfContentStreamProcessor(pdfCleanUpRenderListener);

            PdfCleanUpContentOperator.PopulateOperators(contentProcessor, pdfCleanUpRenderListener);
            contentProcessor.ProcessContent(pageContentInput, page.GetAsDict(PdfName.RESOURCES));
            pdfCleanUpRenderListener.PopContext();

            canvas.RestoreState();

            ColorCleanedLocations(canvas, cleanUpLocations);

            if (redactAnnotIndirRefs != null)   // if it isn't null, then we are in "extract locations from redact annots" mode
            {
                DeleteRedactAnnots(pageNum);
            }
        }
Пример #2
0
 public PdfCleanUpRenderListener(PdfStamper pdfStamper, PdfCleanUpRegionFilter filter)
 {
     this.pdfStamper = pdfStamper;
     this.filter     = filter;
 }
 public PdfCleanUpRenderListener(PdfStamper pdfStamper, PdfCleanUpRegionFilter filter) {
     this.pdfStamper = pdfStamper;
     this.filter = filter;
 }
Пример #4
0
 public PdfCleanUpRenderListener(PdfStamper pdfStamper, PdfCleanUpRegionFilter filter)
 {
     this.pdfStamper = pdfStamper;
     this.filter     = filter;
     InitClippingPath();
 }
 public PdfCleanUpRenderListener(PdfStamper pdfStamper, PdfCleanUpRegionFilter filter) {
     this.pdfStamper = pdfStamper;
     this.filter = filter;
     InitClippingPath();
 }