<commit_before>﻿using System.IO;

using iTextSharp.text.pdf;
using iTextSharp.text;

namespace ArchivePDF.csproj {
	public class UsefulInformationDestroyer {
		private string source;
		private string target;
		public UsefulInformationDestroyer(string sourcePath, string targetPath) {
			source = sourcePath;
			target = targetPath;
		}


		public void RedactUsefulDataFromDocument() {
			try {
				byte[] ba = _RedactUsefulDataFromDocument();
				using (FileStream fs = File.Create(target)) {
					for (int i = 0; i < ba.Length; i++) {
						fs.WriteByte(ba[i]);
					}
					fs.Close();
				}
			} catch (IOException ioe) {
				System.Windows.Forms.MessageBox.Show(ioe.Message, @"Couldn't create redacted version.");
			} catch (System.Exception e) {
				using (ErrMsg er_ = new ErrMsg(e)) {
					er_.ShowDialog();
				}
			}
		}

		private byte[] _RedactUsefulDataFromDocument() {
			using (Document document = new Document()) {
				using (MemoryStream memoryStream = new MemoryStream()) {
					try {
						PdfCopy copy = new PdfCopy(document, memoryStream);
						document.Open();
						using (PdfReader pdfReader = new PdfReader(source)) {
							for (int i = 1; i < pdfReader.NumberOfPages + 1; i++) {
								PdfImportedPage importedPage = copy.GetImportedPage(pdfReader, i);
								PdfCopy.PageStamp pageStamp = copy.CreatePageStamp(importedPage);
								PdfContentByte contentByte = pageStamp.GetOverContent();

								if (i == 1) {
									float y_offset = 137F;
									for (int j = 0; j < 5; j++, y_offset -= 13.5F) {
										Rectangle sourceRevRectangle = new Rectangle(21, y_offset, 44, y_offset + 10);
										sourceRevRectangle.BackgroundColor = BaseColor.WHITE;
										Rectangle sourceECRRectangle = new Rectangle(46, y_offset, 71, y_offset + 10);
										sourceECRRectangle.BackgroundColor = BaseColor.WHITE;
										Rectangle sourceDescrRectangle = new Rectangle(73, y_offset, 988, y_offset + 10);
										sourceDescrRectangle.BackgroundColor = BaseColor.WHITE;

										contentByte.Rectangle(sourceRevRectangle);
										contentByte.Rectangle(sourceECRRectangle);
										contentByte.Rectangle(sourceDescrRectangle);
<commit_msg>Missed three fields.<commit_after>﻿using System.IO;

using iTextSharp.text.pdf;
using iTextSharp.text;

namespace ArchivePDF.csproj {
	public class UsefulInformationDestroyer {
		private string source;
		private string target;
		public UsefulInformationDestroyer(string sourcePath, string targetPath) {
			source = sourcePath;
			target = targetPath;
		}


		public void RedactUsefulDataFromDocument() {
			try {
				byte[] ba = _RedactUsefulDataFromDocument();
				using (FileStream fs = File.Create(target)) {
					for (int i = 0; i < ba.Length; i++) {
						fs.WriteByte(ba[i]);
					}
					fs.Close();
				}
			} catch (IOException ioe) {
				System.Windows.Forms.MessageBox.Show(ioe.Message, @"Couldn't create redacted version.");
			} catch (System.Exception e) {
				using (ErrMsg er_ = new ErrMsg(e)) {
					er_.ShowDialog();
				}
			}
		}

		private byte[] _RedactUsefulDataFromDocument() {
			using (Document document = new Document()) {
				using (MemoryStream memoryStream = new MemoryStream()) {
					try {
						PdfCopy copy = new PdfCopy(document, memoryStream);
						document.Open();
						using (PdfReader pdfReader = new PdfReader(source)) {
							for (int i = 1; i < pdfReader.NumberOfPages + 1; i++) {
								PdfImportedPage importedPage = copy.GetImportedPage(pdfReader, i);
								PdfCopy.PageStamp pageStamp = copy.CreatePageStamp(importedPage);
								PdfContentByte contentByte = pageStamp.GetOverContent();

								if (i == 1) {
									float y_offset = 137F;
									for (int j = 0; j < 5; j++, y_offset -= 13.5F) {
										Rectangle sourceRevRectangle = new Rectangle(21, y_offset, 44, y_offset + 10);
										sourceRevRectangle.BackgroundColor = BaseColor.WHITE;
										Rectangle sourceECRRectangle = new Rectangle(46, y_offset, 71, y_offset + 10);
										sourceECRRectangle.BackgroundColor = BaseColor.WHITE;
										Rectangle sourceDescrRectangle = new Rectangle(73, y_offset, 988, y_offset + 10);
										sourceDescrRectangle.BackgroundColor = BaseColor.WHITE;
										Rectangle sourceDrwnBy = new Rectangle(991, y_offset, 1061, y_offset + 10);
										sourceDrwnBy.BackgroundColor = BaseColor.WHITE;
										Rectangle sourceAppBy = new Rectangle(1063, y_offset, 1133, y_offset + 10);
										sourceAppBy.BackgroundColor = BaseColor.WHITE;
										Rectangle sourceDate = new Rectangle(1135, y_offset, 1205, y_offset + 10);
										sourceDate.BackgroundColor = BaseColor.WHITE;

										contentByte.Rectangle(sourceRevRectangle);
										contentByte.Rectangle(sourceECRRectangle);
										contentByte.Rectangle(sourceDescrRectangle);
										contentByte.Rectangle(sourceDrwnBy);
										contentByte.Rectangle(sourceAppBy);
										contentByte.Rectangle(sourceDate);

{'fraction_non_alphanumeric': 0.10315361139369278, 'fraction_numerical': 0.0185147507629705, 'mean_word_length': 3.2053036783575704, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1354510', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1489, 'n_words': 343}