C를 사용하여 PDF에서 편집된 주석을 사용하여 컨텐트를 자세히 확인합니다. #
때때로, 우리는 민감한 내용이나 개인 정보를 노출하지 않은 상태에서 일부 또는 전체 문서를 표시해야 한다.이 경우 PDF 문서에서 기밀 정보를 안전하게 영구적으로 삭제할 수 있도록 편집 교정 기능을 사용할 수 있습니다.
주석 편집을 사용하여 다음과 같은 작업을 수행할 수 있습니다.
내용 표지: 사용자가 밀문 주석을 응용하여 삭제해야 할 내용 영역을 지적한다.다음 단계를 계속하기 전에 주석을 보고, 이동하고, 재정의할 수 있습니다.
내용 삭제: 이 과정에서 표시된 내용은 영구적으로 삭제되고, 주석이 정의한 편집 영역에 표시를 적용합니다.
편집할 텍스트 및 이미지 표시
이 단계에서 우리는 편집해야 할 내용만 표시한다.직사각형 경계를 사용하여 PDF 문서의 텍스트 및 이미지 영역을 표시할 수 있습니다.
다음 코드 예제에서는 편집할 내용을 PdFRedaction Annotation 방법으로 표시하는 프로세스를 보여 줍니다.
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("invoice_merged.pdf");
PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;
//Create redaction annotation.
PdfRedactionAnnotation redactionAnnotation1 = new PdfRedactionAnnotation();
//Assign the rectangle bounds.
redactionAnnotation1.Bounds = new System.Drawing.RectangleF(35, 393, 100, 20);
//Set inner color of the annotation.
redactionAnnotation1.InnerColor = Color.Black;
//Set border color of the annotation.
redactionAnnotation1.BorderColor = Color.Red;
//Add annotation to the page.
loadedPage.Annotations.Add(redactionAnnotation1);
PdfRedactionAnnotation redactionAnnotation2 = new PdfRedactionAnnotation();
redactionAnnotation2.Bounds = new System.Drawing.RectangleF(95, 435, 80, 100);
redactionAnnotation2.InnerColor = Color.Black;
redactionAnnotation2.BorderColor = Color.Red;
loadedPage.Annotations.Add(redactionAnnotation2);
//Save and close the PDF document.
loadedDocument.Save("output.pdf");
loadedDocument.Close(true);
이 코드 예시를 실행하면 다음 화면 캡처와 같이 PDF 문서를 얻을 수 있습니다.편집할 텍스트 및 이미지에 태그 지정
텍스트를 찾아서 암호 주석으로 표시하기
[텍스트 찾기] 기능을 사용하면 PDF 문서에서 특정 텍스트를 찾고 PDF 주석을 사용하여 텍스트를 표시할 수 있습니다.
다음 코드 예제에서는 편집할 텍스트를 PdFRedaction Annotation으로 찾아 표시하는 과정을 보여 줍니다.
// Load an existing PDF.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Invoice.pdf");
TextSearchResultCollection searchCollection;
TextSearchItem text = new TextSearchItem("Invoice Number", TextSearchOptions.None);
//Search the text in PDF document.
loadedDocument.FindText(new List<TextSearchItem> { text }, out searchCollection);
//Iterate search collection to get search results.
foreach (KeyValuePair<int, MatchedItemCollection> textCollection in searchCollection)
{
//Get matched text collection.
foreach (MatchedItem textItem in textCollection.Value)
{
//Create redaction annotation.
PdfRedactionAnnotation redactionAnnotation1 = new PdfRedactionAnnotation();
//Assign the rectangle bounds to cover full invoice number.
redactionAnnotation1.Bounds =new RectangleF(textItem.Bounds.X,textItem.Bounds.Y,textItem.Bounds.Width+55,textItem.Bounds.Height);
//Set inner color of the annotation.
redactionAnnotation1.InnerColor = Color.Black;
//Set border color of the annotation.
redactionAnnotation1.BorderColor = Color.Red;
//Add annotation to the page.
loadedDocument.Pages[textCollection.Key].Annotations.Add(redactionAnnotation1);
}
}
loadedDocument.Save("Redact.pdf");
//Close the document.
loadedDocument.Close(true);
앞의 코드 예제에서 FindText 방법을 사용하여 PDF 문서에서 청구서 번호를 찾습니다.그리고 FindText 방법에서 얻은 경계를 표시하기 위해 PdfRedaction Annotation을 만들었습니다.이 코드 예시를 실행하면 다음 화면 캡처와 같이 PDF 문서를 얻을 수 있습니다.
텍스트를 찾아서 수정 주석으로 표시
편집할 페이지 또는 연속 페이지 표시
PdfredactionAnnotation 태그를 사용하여 전체 PDF 페이지를 편집할 수 있습니다.PDF 문서의 각 페이지를 교체하고 페이지 경계가 있는 Pdfredaction Annotation을 추가할 수도 있습니다.
다음 코드 예제에서는 Pdfredaction Annotation을 사용하여 전체 페이지를 찾아 표시하여 편집하는 과정을 보여 줍니다.
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Invoice.pdf");
//Iterate each page and add redaction annotation.
foreach (PdfLoadedPage page in loadedDocument.Pages)
{
//Create redaction annotation.
PdfRedactionAnnotation redactionAnnotation = new PdfRedactionAnnotation();
//Assign the page bounds to redaction annotation.
redactionAnnotation.Bounds = new System.Drawing.RectangleF(0, 0, page.Size.Width, page.Size.Height);
//Set inner color of the annotation.
redactionAnnotation.InnerColor = Color.Black;
//Set border color of the annotation.
redactionAnnotation.BorderColor = Color.Red;
//Add annotation to the page.
page.Annotations.Add(redactionAnnotation);
}
//Save and close the PDF document.
loadedDocument.Save("WholePage.pdf");
loadedDocument.Close(true);
이 코드 예시를 실행하면 다음 화면 캡처와 같이 PDF 문서를 얻을 수 있습니다.태그 연속 페이지 편집
개정 태그의 모양 변경
사용자 정의 텍스트와 색을 밀문 주석으로 설정할 수 있습니다.이것은 모든 사람이 쉽게 볼 수 있고 나중에 계속할 수 있도록 태그 내용의 정확한 원인을 제공할 것입니다.
다음 코드 예제에서는 PdFRedaction Annotation을 사용하여 암호 태그의 모양을 사용자 정의하는 프로세스를 보여 줍니다.
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Invoice.pdf");
//Create redaction annotation.
PdfRedactionAnnotation redactionAnnotation = new PdfRedactionAnnotation();
//Assign the page bounds to redaction annotation.
redactionAnnotation.Bounds = new System.Drawing.RectangleF(60, 150,170, 120);
//Set inner color of the annotation.
redactionAnnotation.InnerColor = Color.Black;
//Set border color of the annotation.
redactionAnnotation.BorderColor = Color.Red;
//Font for the overlay text.
redactionAnnotation.Font = new PdfStandardFont(PdfFontFamily.Courier, 10);
//Text color.
redactionAnnotation.TextColor = Color.White;
//Text alignment.
redactionAnnotation.TextAlignment = PdfTextAlignment.Center;
//Set overlay text.
redactionAnnotation.OverlayText = "Confidential";
//Set repeat text option.
redactionAnnotation.RepeatText = true;
//Enable appearance of the annotation.
redactionAnnotation.SetAppearance(true);
//Add annotation to the page page.Annotations.Add(redactionAnnotation);
loadedDocument.Pages[0].Annotations.Add(redactionAnnotation);
//Save and close the PDF document.
loadedDocument.Save("CustomAppearance.pdf");
loadedDocument.Close(true);
이 코드 예시를 실행하면 다음 화면 캡처와 같이 PDF 문서를 얻을 수 있습니다.사용자 정의 편집 표시
PDF 문서에서 태그의 컨텐트 삭제
마지막으로 PDF 문서에서 중요한 내용을 삭제할 수 있습니다.이것은 매우 쉽다.우리는 모든 편집 주석을 불러와서 평평하게 펼치기만 하면 된다.
아래의 코드 예시는 평평하게 편집하고 주석을 교정하여 표기 내용을 영구적으로 삭제하는 과정을 보여 준다.
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("InvoiceMarked.pdf");
//Iterate each redaction annotation and apply flatten to redact marked content.
foreach(PdfAnnotation annotation in loadedDocument.Pages[0].Annotations)
{
if(annotation is PdfLoadedRedactionAnnotation)
{
(annotation as PdfLoadedRedactionAnnotation).Flatten = true;
}
}
//Save and close the PDF document.
loadedDocument.Save("Redacted.pdf");
loadedDocument.Close(true);
이 코드 예시를 실행하면 다음 화면 캡처와 같이 PDF 문서를 얻을 수 있습니다.PDF에서 태그 삭제
GitHub 예
다음 GitHub 저장소에서 PDF 컴파일링 주석 예제를 모두 다운로드할 수 있습니다https://github.com/SyncfusionExamples/pdf-redaction-annotation-csharp.
결론
이 블로그에서 우리는 편집할 내용을 표시하고 영구적으로 삭제하는 방법을 배웠다.이렇게 하면 PDF 문서를 편집하기 전에 문서의 중요한 데이터를 쉽게 볼 수 있습니다.
우리 documentation를 자세히 읽으면 다른 옵션과 기능, 그리고 첨부된 코드 예시를 발견할 수 있습니다.
이러한 기능에 대해 궁금한 점이 있으면 아래 설명서에서 알려 주십시오.저희support forum, Direct-Trac 또는 feedback portal를 통해서도 저희에게 연락하실 수 있습니다.예전과 같이, 우리는 기꺼이 당신을 돕겠습니다!
만약 당신이 이 글을 좋아한다면, 우리는 당신도 다음과 같은 PDF 라이브러리에 관한 글을 좋아할 것이라고 생각합니다.
Reference
이 문제에 관하여(C를 사용하여 PDF에서 편집된 주석을 사용하여 컨텐트를 자세히 확인합니다. #), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/syncfusion/double-check-content-using-redaction-annotation-in-pdfs-with-c-1h3n텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)