

AddRedaction ( redaction ) //Redact the contents from the PDF document document. Red, new PointF ( 5, 5 )) // Add a redaction object into the redaction collection of loaded page page. DrawString ( "Redacted", font, PdfBrushes. Courier, 10 ) //Draw text on the redacted area redaction. Black ) //Font for the overlay text PdfStandardFont font = new PdfStandardFont ( PdfFontFamily. Pages as PdfLoadedPage // Create a redaction object PdfRedaction redaction = new PdfRedaction ( new RectangleF ( 343, 167, 100, 25 ), Color. Read ) PdfLoadedDocument document = new PdfLoadedDocument ( docStream ) //Get the first page from the document PdfLoadedPage page = document. Load the existing PDF document FileStream docStream = new FileStream (, FileMode. Close ( true ) //Defining the ContentType for pdf file string contentType = "application/pdf" //Define the file name string fileName = "output.pdf" //Creates a FileContentResult object by using the file contents, content type, and file name return File ( stream, contentType, fileName ) Save ( stream ) //close the documents document. Redact () // Creating the stream object MemoryStream stream = new MemoryStream () //Save the documents document. Pages as PdfLoadedPage // Create a redaction object PdfRedaction redaction = new PdfRedaction ( new RectangleF ( 343, 147, 60, 17 )) // Add a redaction object into the redaction collection of loaded page page. PictureBox1.SizeMode = PictureBoxSizeMode.// Load the existing PDF document FileStream docStream = new FileStream (, FileMode.

Using (Graphics g = Graphics.FromImage(pictureBox1.Image)) //start redaction PictureBox1.Image = newImage //END Workaround for indexed pixels String x1 = x1 = Regex.Match(l, y1 = y1 = Regex.Match(l, x2 = x2 = Regex.Match(l, y2 = y2 = Regex.Match(l, x3 = x3 = Regex.Match(l, 圓 = 圓 = Regex.Match(l, string to int for redacted pointsīitmap original = (Bitmap)(YOURFILE, true) If you're given the redacted starting points (obviously you have to make the Regex work to your situation): //Regex for pulling points from a file
#Redacted image code#
Thanks to all the help from STO members!! heres the correct code for redacting images if you encounter the error "A Graphics object cannot be created from an image that has an indexed pixel format.". I believe i ran something about using a Bitmap from stream and then closing the stream. Whats going on with the code above, is once it's completed, all it displays is a blackbox with no original image. Then I need to display this redacted image (the original with the redaction) in a picturebox. So I have to change it to a Bitmap so I can actually draw a rectangle on it.

Whats happening is I have a tif in a unsupported format. I'm not sure how I can make this clearer. G.FillRectangle(brush, new Rectangle(x1value, y1value, x3value, 圓value)) Using (SolidBrush brush = new SolidBrush(Color.Black)) Using (Graphics g = Graphics.FromImage(pictureBox1.Image)) Bitmap original = (Bitmap)(coveted, true) īitmap newImage = new Bitmap(original.Width, original.Height) if someone could help me where i'm going wrong that would be awesome. And completly displays the the picture box in all black nothing of the original image. So i had to read it in to bit format, but when i display the box it resizes the box wierd.

I was helped with some code but i continously got the error: A Graphics object cannot be created from an image that has an indexed pixel format. I have to load a tif and then show a blackbox over it. Whats going on is i need to draw a black rectangle over the image.
