가림 처리 및 정화
진정한 가림 처리는 파괴적입니다. 기저 글리프, 이미지, 패스는 검은 사각형으로 단순히 덮는 것이 아니라 콘텐츠 스트림에서 물리적으로 제거되어야 합니다. PDF Oxide v0.3.69는 ISO 32000-1:2008 §12.5.6.23 가림 처리를 구현합니다. redaction_apply는 물리적으로 삭제한 글리프 수를 반환하며, 페이지가 안전하게 재작성할 수 없는 복합/Type0 폰트를 사용하는 경우 조용히 가림 처리를 생략하는 대신 실패 종료(거부)합니다.
이 페이지에서는 표준 파괴적 가림 처리 패밀리(redaction_add / redaction_apply / redaction_count / redaction_scrub_metadata)와 헤더/푸터/아티팩트 제거 패밀리(remove_headers / remove_footers / remove_artifacts, 그리고 페이지별 erase_header / erase_footer / erase_artifacts)를 다룹니다.
두 가지 가림 처리 방식. v0.3.69에는
/Redact어노테이션을 시각적 오버레이로 소각하는 레거시 어노테이션 평탄화 경로(apply_page_redactions/apply_all_redactions)도 여전히 존재합니다. 콘텐츠를 완전히 제거해야 할 때는 여기서 설명하는 파괴적 패밀리를 사용하세요. 파괴적redaction_apply는 소스에 이미 존재하는/Redact어노테이션도 처리하므로 두 방식을 함께 사용할 수 있습니다.
바인딩 지원 범위. 파괴적 가림 처리 패밀리는 Rust, Python, Go, C#, WASM/JavaScript 빌드에서 제공됩니다. 헤더/푸터/아티팩트
remove_*패밀리는 Rust, Python, Go, WASM/JavaScript에서, 페이지별erase_*패밀리는 Rust, Python, WASM/JavaScript에서 제공됩니다. C#은 현재remove_*/erase_*페이지 장식 패밀리를 제공하지 않습니다.
PDF에서 텍스트를 어떻게 가림 처리하나요?
파괴적 워크플로는 세 단계로 구성됩니다.
redaction_add로 가림 처리 사각형을 대기열에 추가합니다(페이지 사용자 공간 좌표; 선택적 DeviceRGB 오버레이 채우기 색상). 소스에 이미 존재하는/Redact어노테이션은 자동으로 포함됩니다.redaction_apply로 적용합니다. 이는 덮인 글리프/이미지/패스를 물리적으로 제거하고, 불투명한 오버레이를 그리고, 선택적으로 문서 메타데이터를 정리하며, 제거된 글리프 수를 반환합니다.- 재작성된 PDF를 저장합니다. 원본
/Contents객체는 하드 드롭(G6)되므로 비밀 정보가 GC에서 누락된 고아 객체로 남을 수 없습니다.
가림 처리 사각형 대기열 추가
redaction_add(page, rect, fill)은 파괴적 사각형을 대기열에 추가합니다. 좌표는 페이지 사용자 공간 (x0, y0, x1, y1)이며, fill은 선택적 DeviceRGB [r, g, b] 오버레이 색상입니다(기본값은 검정).
Rust
use pdf_oxide::editor::{DocumentEditor, EditableDocument};
use pdf_oxide::redaction::RedactionOptions;
let mut editor = DocumentEditor::open("confidential.pdf")?;
// Queue a black redaction box on page 0 (x0, y0, x1, y1 in points).
editor.add_redaction(0, [100.0, 700.0, 300.0, 714.0], None)?;
// Apply destructively, then save. Returns a RedactionReport.
let report = editor.apply_redactions_destructive(RedactionOptions::default())?;
println!("glyphs removed: {}", report.glyphs_removed);
editor.save("redacted.pdf")?;
Python
from pdf_oxide import PdfDocument
doc = PdfDocument("confidential.pdf")
# Queue a black redaction box on page 0 (x0, y0, x1, y1 in points).
doc.add_redaction(0, (100.0, 700.0, 300.0, 714.0))
# Apply destructively (returns a report dict), then save.
report = doc.apply_redactions_destructive()
print("glyphs removed:", report["glyphs_removed"])
doc.save("redacted.pdf")
Go
editor, _ := pdfoxide.OpenEditor("confidential.pdf")
defer editor.Close()
// Queue a redaction box on page 0; pass nil fill for the default black.
_ = editor.AddRedaction(0, [4]float64{100, 700, 300, 714}, nil)
// Apply destructively (scrubMetadata = true). Returns glyphs removed.
glyphs, _ := editor.ApplyRedactions(true)
fmt.Printf("glyphs removed: %d\n", glyphs)
_ = editor.Save("redacted.pdf")
C#
using PdfOxide;
using var editor = DocumentEditor.Open("confidential.pdf");
// Queue a redaction box on page 0 (x1, y1, x2, y2; r, g, b default to black).
editor.AddRedaction(0, 100, 700, 300, 714);
// Apply destructively (scrubMetadata defaults to true). Returns glyphs removed.
int glyphs = editor.ApplyRedactions(scrubMetadata: true);
Console.WriteLine($"glyphs removed: {glyphs}");
editor.Save("redacted.pdf");
JavaScript (WASM)
import { WasmPdfDocument } from "pdf-oxide-wasm";
const doc = new WasmPdfDocument(bytes);
// Queue a redaction box on page 0; pass an [r, g, b] array for a custom fill.
doc.addRedaction(0, 100, 700, 300, 714);
// Apply destructively. Returns a RedactionReport object.
const report = doc.applyRedactionsDestructive(true);
console.log("glyphs removed:", report.glyphs_removed);
const output = doc.save();
doc.free();
Java
import fyi.oxide.pdf.DocumentEditor;
import fyi.oxide.pdf.geometry.BBox;
try (DocumentEditor editor = DocumentEditor.open("confidential.pdf")) {
// Queue a black redaction box on page 0 (x0, y0, x1, y1 in points).
editor.addRedaction(0, new BBox(100.0, 700.0, 300.0, 714.0));
// Apply destructively (scrubs metadata), then save.
editor.applyRedactionsDestructive();
editor.saveTo(java.nio.file.Path.of("redacted.pdf"));
}
Kotlin
import fyi.oxide.pdf.DocumentEditor
import fyi.oxide.pdf.geometry.BBox
DocumentEditor.open("confidential.pdf").use { editor ->
// Queue a black redaction box on page 0 (x0, y0, x1, y1 in points).
editor.addRedaction(0, BBox(100.0, 700.0, 300.0, 714.0))
// Apply destructively (scrubs metadata), then save.
editor.applyRedactionsDestructive()
editor.saveTo(java.nio.file.Path.of("redacted.pdf"))
}
Scala
import fyi.oxide.pdf.DocumentEditor
import fyi.oxide.pdf.geometry.BBox
import scala.util.Using
Using.resource(DocumentEditor.open("confidential.pdf")) { editor =>
// Queue a black redaction box on page 0 (x0, y0, x1, y1 in points).
editor.addRedaction(0, BBox(100.0, 700.0, 300.0, 714.0))
// Apply destructively (scrubs metadata), then save.
editor.applyRedactionsDestructive()
editor.saveTo(java.nio.file.Path.of("redacted.pdf"))
}
Clojure
(require '[pdf-oxide.core :as pdf])
(import '[fyi.oxide.pdf.geometry BBox])
(with-open [ed (pdf/editor "confidential.pdf")]
;; Queue a black redaction box on page 0 (x0, y0, x1, y1 in points).
(pdf/add-redaction ed 0 (BBox. 100.0 700.0 300.0 714.0))
;; Apply destructively (scrubs metadata), then save.
(pdf/apply-redactions ed)
(java.nio.file.Files/write
(java.nio.file.Path/of "redacted.pdf" (into-array String []))
(pdf/editor-save ed)))
PHP
use PdfOxide\DocumentEditor;
$editor = DocumentEditor::open('confidential.pdf');
// Queue a black redaction box on page 0 (x1, y1, x2, y2 in points).
$editor->addRedaction(0, 100.0, 700.0, 300.0, 714.0);
// Apply destructively (scrubMetadata defaults to true). Returns glyphs removed.
$glyphs = $editor->applyRedactionsDestructive(true);
echo "glyphs removed: $glyphs\n";
$editor->saveTo('redacted.pdf');
Ruby
require 'pdf_oxide'
PdfOxide::DocumentEditor.open('confidential.pdf') do |ed|
# Queue a black redaction box on page 0 (x1, y1, x2, y2 in points).
ed.add_redaction(page: 0, rect: [100.0, 700.0, 300.0, 714.0])
# Apply destructively, scrubbing metadata (raises on fail-closed), then save.
ed.apply_redactions!(scrub_metadata: true)
ed.save_to('redacted.pdf')
end
C++
#include <pdf_oxide/pdf_oxide.hpp>
auto editor = pdf_oxide::DocumentEditor::open("confidential.pdf");
// Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
editor.redaction_add(0, 100.0, 700.0, 300.0, 714.0, 0.0, 0.0, 0.0);
// Apply destructively (scrub_metadata = true). Returns glyphs removed.
int glyphs = editor.redaction_apply(/*scrub_metadata=*/true, 0.0, 0.0, 0.0);
std::cout << "glyphs removed: " << glyphs << "\n";
editor.save("redacted.pdf");
Swift
import PdfOxide
let editor = try DocumentEditor.open("confidential.pdf")
// Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
try editor.redactionAdd(0, x1: 100, y1: 700, x2: 300, y2: 714, r: 0, g: 0, b: 0)
// Apply destructively (scrub metadata). Returns glyphs removed.
let glyphs = try editor.redactionApply(scrubMetadata: true, r: 0, g: 0, b: 0)
print("glyphs removed: \(glyphs)")
try editor.save("redacted.pdf")
Dart
import 'package:pdf_oxide/pdf_oxide.dart';
final editor = DocumentEditor.open('confidential.pdf');
// Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
editor.redactionAdd(0, 100, 700, 300, 714);
// Apply destructively, scrubbing metadata. Returns glyphs removed.
final glyphs = editor.redactionApply(scrubMetadata: true);
print('glyphs removed: $glyphs');
editor.save('redacted.pdf');
R
library(pdfoxide)
editor <- pdf_editor_open("confidential.pdf")
# Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
pdf_redaction_add(editor, 0, 100, 700, 300, 714, 0, 0, 0)
# Apply destructively, scrubbing metadata. Returns glyphs removed.
glyphs <- pdf_redaction_apply(editor, scrub_metadata = TRUE, 0, 0, 0)
cat("glyphs removed:", glyphs, "\n")
pdf_editor_save(editor, "redacted.pdf")
Julia
using PdfOxide
editor = open_editor("confidential.pdf")
# Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
redaction_add(editor, 0, 100, 700, 300, 714, 0, 0, 0)
# Apply destructively, scrubbing metadata. Returns glyphs removed.
glyphs = redaction_apply(editor, true, 0, 0, 0)
println("glyphs removed: ", glyphs)
save(editor, "redacted.pdf")
Zig
const pdf_oxide = @import("pdf_oxide");
var editor = try pdf_oxide.DocumentEditor.openEditor("confidential.pdf");
defer editor.deinit();
// Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
try editor.redactionAdd(0, 100, 700, 300, 714, 0, 0, 0);
// Apply destructively, scrubbing metadata. Returns glyphs removed.
const glyphs = try editor.redactionApply(true, 0, 0, 0);
std.debug.print("glyphs removed: {d}\n", .{glyphs});
try editor.save("redacted.pdf");
Objective-C
#import "POXPdfOxide.h"
NSError *err = nil;
POXDocumentEditor *editor = [POXDocumentEditor openEditor:@"confidential.pdf" error:&err];
// Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
[editor redactionAddPage:0 x1:100 y1:700 x2:300 y2:714 r:0 g:0 b:0 error:&err];
// Apply destructively, scrubbing metadata. Returns glyphs removed.
int32_t glyphs = [editor redactionApplyScrubMetadata:YES r:0 g:0 b:0 error:&err];
NSLog(@"glyphs removed: %d", glyphs);
[editor saveToPath:@"redacted.pdf" error:&err];
Elixir
{:ok, editor} = PdfOxide.open_editor("confidential.pdf")
# Queue a black redaction box on page 0 (x1, y1, x2, y2; r, g, b in 0..1).
:ok = PdfOxide.redaction_add(editor, 0, 100, 700, 300, 714, 0.0, 0.0, 0.0)
# Apply destructively, scrubbing metadata. Returns {:ok, glyphs_removed}.
{:ok, glyphs} = PdfOxide.redaction_apply(editor, true, 0.0, 0.0, 0.0)
IO.puts("glyphs removed: #{glyphs}")
PdfOxide.editor_save(editor, "redacted.pdf")
대기 중인 영역 수 확인
redaction_count(page)는 특정 페이지에 대기 중인 영역 수를 반환합니다. 소스의 /Redact 어노테이션과 redaction_add로 추가된 프로그래밍 방식 사각형의 합계입니다. 적용 전에 가림 처리할 내용이 있는지 확인할 때 사용하세요.
let mut editor = DocumentEditor::open("marked.pdf")?;
editor.add_redaction(0, [100.0, 700.0, 300.0, 714.0], None)?;
assert_eq!(editor.redaction_count(0)?, 1);
doc = PdfDocument("marked.pdf")
doc.add_redaction(0, (100.0, 700.0, 300.0, 714.0))
assert doc.redaction_count(0) == 1
editor, _ := pdfoxide.OpenEditor("marked.pdf")
defer editor.Close()
_ = editor.AddRedaction(0, [4]float64{100, 700, 300, 714}, nil)
n, _ := editor.RedactionCount(0) // 1
using var editor = DocumentEditor.Open("marked.pdf");
editor.AddRedaction(0, 100, 700, 300, 714);
int n = editor.RedactionCount(0); // 1
const doc = new WasmPdfDocument(bytes);
doc.addRedaction(0, 100, 700, 300, 714);
const n = doc.redactionCount(0); // 1
가림 처리와 정화의 차이점은 무엇인가요?
기하학적 가림 처리는 사각형 아래의 콘텐츠를 제거합니다. 정화는 가림 처리 사각형으로는 절대 덮을 수 없는 문서 수준의 비밀을 제거합니다. /Info 딕셔너리, 카탈로그 XMP /Metadata 스트림, 문서 JavaScript(/OpenAction, /AA, /Names/JavaScript), /Names/EmbeddedFiles가 이에 해당합니다. 제거된 객체 서브트리는 출력에서 하드 제외됩니다(G6).
redaction_apply는 scrub_metadata 플래그가 설정된 경우(각 바인딩의 기본값) 자동으로 정화를 실행합니다. redaction_scrub_metadata는 기하학적 가림 처리 없이 동일한 정화 패스를 단독으로 실행합니다. 문서만 정화하고 영역을 가림 처리할 필요가 없을 때 사용하세요. 제거된 최상위 구조 수를 반환합니다.
Rust
use pdf_oxide::editor::{DocumentEditor, EditableDocument};
use pdf_oxide::redaction::RedactionOptions;
let mut editor = DocumentEditor::open("input.pdf")?;
let report = editor.sanitize_document(RedactionOptions::default())?;
println!("constructs removed: {}", report.annotations_removed);
editor.save("sanitized.pdf")?;
Python
doc = PdfDocument("input.pdf")
report = doc.sanitize_document()
print("constructs removed:", report["annotations_removed"])
doc.save("sanitized.pdf")
Go
editor, _ := pdfoxide.OpenEditor("input.pdf")
defer editor.Close()
removed, _ := editor.SanitizeDocument() // top-level constructs removed
_ = editor.Save("sanitized.pdf")
C#
using var editor = DocumentEditor.Open("input.pdf");
int removed = editor.SanitizeDocument(); // top-level constructs removed
editor.Save("sanitized.pdf");
JavaScript (WASM)
const doc = new WasmPdfDocument(bytes);
const report = doc.sanitizeDocument(true, true, true); // scrub, removeJS, removeEmbedded
const output = doc.save();
doc.free();
Java
import fyi.oxide.pdf.DocumentEditor;
try (DocumentEditor editor = DocumentEditor.open("input.pdf")) {
editor.scrubMetadata(); // strip /Info, XMP, JS, embedded files — no geometry
editor.saveTo(java.nio.file.Path.of("sanitized.pdf"));
}
Kotlin
import fyi.oxide.pdf.DocumentEditor
DocumentEditor.open("input.pdf").use { editor ->
editor.scrubMetadata() // strip /Info, XMP, JS, embedded files — no geometry
editor.saveTo(java.nio.file.Path.of("sanitized.pdf"))
}
Scala
import fyi.oxide.pdf.DocumentEditor
import scala.util.Using
Using.resource(DocumentEditor.open("input.pdf")) { editor =>
editor.scrubMetadata() // strip /Info, XMP, JS, embedded files — no geometry
editor.saveTo(java.nio.file.Path.of("sanitized.pdf"))
}
Clojure
(require '[pdf-oxide.core :as pdf])
(with-open [ed (pdf/editor "input.pdf")]
(pdf/scrub-metadata ed) ; strip /Info, XMP, JS, embedded files — no geometry
(java.nio.file.Files/write
(java.nio.file.Path/of "sanitized.pdf" (into-array String []))
(pdf/editor-save ed)))
PHP
use PdfOxide\DocumentEditor;
$editor = DocumentEditor::open('input.pdf');
$editor->scrubMetadata(); // strip /Info, XMP, JS, embedded files — no geometry
$editor->saveTo('sanitized.pdf');
Ruby
require 'pdf_oxide'
PdfOxide::DocumentEditor.open('input.pdf') do |ed|
removed = ed.scrub_metadata # top-level constructs removed (no geometry)
puts "constructs removed: #{removed}"
ed.save_to('sanitized.pdf')
end
C++
#include <pdf_oxide/pdf_oxide.hpp>
auto editor = pdf_oxide::DocumentEditor::open("input.pdf");
int removed = editor.redaction_scrub_metadata(); // constructs removed (no geometry)
std::cout << "constructs removed: " << removed << "\n";
editor.save("sanitized.pdf");
Swift
import PdfOxide
let editor = try DocumentEditor.open("input.pdf")
let removed = try editor.redactionScrubMetadata() // constructs removed (no geometry)
print("constructs removed: \(removed)")
try editor.save("sanitized.pdf")
Dart
import 'package:pdf_oxide/pdf_oxide.dart';
final editor = DocumentEditor.open('input.pdf');
final removed = editor.redactionScrubMetadata(); // constructs removed (no geometry)
print('constructs removed: $removed');
editor.save('sanitized.pdf');
R
library(pdfoxide)
editor <- pdf_editor_open("input.pdf")
removed <- pdf_redaction_scrub_metadata(editor) # constructs removed (no geometry)
cat("constructs removed:", removed, "\n")
pdf_editor_save(editor, "sanitized.pdf")
Julia
using PdfOxide
editor = open_editor("input.pdf")
removed = redaction_scrub_metadata(editor) # constructs removed (no geometry)
println("constructs removed: ", removed)
save(editor, "sanitized.pdf")
Zig
const pdf_oxide = @import("pdf_oxide");
var editor = try pdf_oxide.DocumentEditor.openEditor("input.pdf");
defer editor.deinit();
const removed = try editor.redactionScrubMetadata(); // constructs removed (no geometry)
std.debug.print("constructs removed: {d}\n", .{removed});
try editor.save("sanitized.pdf");
Objective-C
#import "POXPdfOxide.h"
NSError *err = nil;
POXDocumentEditor *editor = [POXDocumentEditor openEditor:@"input.pdf" error:&err];
int32_t removed = [editor redactionScrubMetadataWithError:&err]; // constructs removed
NSLog(@"constructs removed: %d", removed);
[editor saveToPath:@"sanitized.pdf" error:&err];
Elixir
{:ok, editor} = PdfOxide.open_editor("input.pdf")
{:ok, removed} = PdfOxide.redaction_scrub_metadata(editor) # constructs removed
IO.puts("constructs removed: #{removed}")
PdfOxide.editor_save(editor, "sanitized.pdf")
반복되는 헤더와 푸터를 어떻게 제거하나요?
헤더, 푸터, 페이지 장식 아티팩트는 여러 페이지에 걸쳐 반복되며 추출이나 재출판 전에 제거하고 싶은 정형적인 요소입니다. PDF Oxide는 두 가지 방법으로 감지합니다. ISO 32000 사양 준수 /Artifact 태그를 우선 사용하고(존재 시 100% 정확도), 없을 경우 페이지 상하 15% 영역에서 반복되는 텍스트를 장식으로 표시하는 휴리스틱으로 전환합니다.
remove_headers(threshold) / remove_footers(threshold) / remove_artifacts(threshold)는 문서 전체에 걸쳐 동작하며 제거된 항목 수를 반환합니다. threshold는 휴리스틱 모드에서 텍스트가 장식으로 처리되기 위해 반복되어야 하는 페이지 비율(0.0–1.0)입니다(기본값 0.8). remove_artifacts는 헤더와 푸터를 동시에 제거하는 편의 함수입니다.
Rust
use pdf_oxide::PdfDocument;
let doc = PdfDocument::open("report.pdf")?;
let headers = doc.remove_headers(0.8)?; // count removed
let footers = doc.remove_footers(0.8)?;
// Or both at once:
let total = doc.remove_artifacts(0.8)?; // headers + footers
println!("removed {} furniture items", total);
Python
from pdf_oxide import PdfDocument
doc = PdfDocument("report.pdf")
doc.remove_headers(0.8) # threshold defaults to 0.8
doc.remove_footers(0.8)
total = doc.remove_artifacts(0.8) # headers + footers, returns count
print("removed", total, "furniture items")
doc.save("clean.pdf")
Go
doc, _ := pdfoxide.Open("report.pdf")
defer doc.Close()
headers, _ := doc.RemoveHeaders(0.8) // count removed
footers, _ := doc.RemoveFooters(0.8)
total, _ := doc.RemoveArtifacts(0.8) // headers + footers
fmt.Printf("removed %d furniture items\n", total)
JavaScript (WASM)
import { WasmPdfDocument } from "pdf-oxide-wasm";
const doc = new WasmPdfDocument(bytes);
doc.removeHeaders(0.8); // returns count removed
doc.removeFooters(0.8);
const total = doc.removeArtifacts(0.8); // headers + footers
const output = doc.save();
doc.free();
C++
#include <pdf_oxide/pdf_oxide.hpp>
auto doc = pdf_oxide::Document::open("report.pdf");
int headers = doc.remove_headers(0.8f); // count removed
int footers = doc.remove_footers(0.8f);
int total = doc.remove_artifacts(0.8f); // headers + footers
std::cout << "removed " << total << " furniture items\n";
Swift
import PdfOxide
let doc = try Document.open("report.pdf")
let headers = try doc.removeHeaders(threshold: 0.8) // count removed
let footers = try doc.removeFooters(threshold: 0.8)
let total = try doc.removeArtifacts(threshold: 0.8) // headers + footers
print("removed \(total) furniture items")
Dart
import 'package:pdf_oxide/pdf_oxide.dart';
final doc = PdfDocument.open('report.pdf');
doc.removeHeaders(0.8); // returns count removed
doc.removeFooters(0.8);
final total = doc.removeArtifacts(0.8); // headers + footers
print('removed $total furniture items');
R
library(pdfoxide)
doc <- pdf_open("report.pdf")
headers <- pdf_remove_headers(doc, 0.8) # count removed
footers <- pdf_remove_footers(doc, 0.8)
total <- pdf_remove_artifacts(doc, 0.8) # headers + footers
cat("removed", total, "furniture items\n")
Julia
using PdfOxide
doc = open_document("report.pdf")
headers = remove_headers(doc, 0.8) # count removed
footers = remove_footers(doc, 0.8)
total = remove_artifacts(doc, 0.8) # headers + footers
println("removed ", total, " furniture items")
Zig
const pdf_oxide = @import("pdf_oxide");
var doc = try pdf_oxide.Document.open("report.pdf");
defer doc.deinit();
const headers = try doc.removeHeaders(0.8); // count removed
const footers = try doc.removeFooters(0.8);
const total = try doc.removeArtifacts(0.8); // headers + footers
std.debug.print("removed {d} furniture items\n", .{total});
Objective-C
#import "POXPdfOxide.h"
NSError *err = nil;
POXDocument *doc = [POXDocument openPath:@"report.pdf" error:&err];
int32_t headers = [doc removeHeaders:0.8 error:&err]; // count removed
int32_t footers = [doc removeFooters:0.8 error:&err];
int32_t total = [doc removeArtifacts:0.8 error:&err]; // headers + footers
NSLog(@"removed %d furniture items", total);
Elixir
{:ok, doc} = PdfOxide.open("report.pdf")
{:ok, headers} = PdfOxide.remove_headers(doc, 0.8) # count removed
{:ok, footers} = PdfOxide.remove_footers(doc, 0.8)
{:ok, total} = PdfOxide.remove_artifacts(doc, 0.8) # headers + footers
IO.puts("removed #{total} furniture items")
단일 페이지의 장식 지우기
장식이 어느 페이지에 있는지 정확히 알 경우, 페이지별 erase_* 패밀리를 사용해 교차 페이지 반복 분석 없이 헤더 영역(상단 15%), 푸터 영역(하단 15%), 또는 양쪽을 삭제 대상으로 표시할 수 있습니다. 이 함수들은 0 기반 페이지 인덱스를 받습니다.
Rust
use pdf_oxide::PdfDocument;
let doc = PdfDocument::open("report.pdf")?;
doc.erase_header(0)?; // erase the top 15% of page 0
doc.erase_footer(0)?; // erase the bottom 15% of page 0
doc.erase_artifacts(0)?; // erase both header and footer of page 0
Python
doc = PdfDocument("report.pdf")
doc.erase_header(0) # erase the top 15% of page 0
doc.erase_footer(0) # erase the bottom 15% of page 0
doc.erase_artifacts(0) # erase both header and footer of page 0
doc.save("clean.pdf")
JavaScript (WASM)
const doc = new WasmPdfDocument(bytes);
doc.eraseHeader(0); // erase the top 15% of page 0
doc.eraseFooter(0); // erase the bottom 15% of page 0
doc.eraseArtifacts(0); // erase both header and footer of page 0
const output = doc.save();
doc.free();
C++
#include <pdf_oxide/pdf_oxide.hpp>
auto doc = pdf_oxide::Document::open("report.pdf");
doc.erase_header(0); // erase the top 15% of page 0
doc.erase_footer(0); // erase the bottom 15% of page 0
doc.erase_artifacts(0); // erase both header and footer of page 0
Swift
import PdfOxide
let doc = try Document.open("report.pdf")
try doc.eraseHeader(0) // erase the top 15% of page 0
try doc.eraseFooter(0) // erase the bottom 15% of page 0
try doc.eraseArtifacts(0) // erase both header and footer of page 0
Dart
import 'package:pdf_oxide/pdf_oxide.dart';
final doc = PdfDocument.open('report.pdf');
doc.eraseHeader(0); // erase the top 15% of page 0
doc.eraseFooter(0); // erase the bottom 15% of page 0
doc.eraseArtifacts(0); // erase both header and footer of page 0
R
library(pdfoxide)
doc <- pdf_open("report.pdf")
pdf_erase_header(doc, 0) # erase the top 15% of page 0
pdf_erase_footer(doc, 0) # erase the bottom 15% of page 0
pdf_erase_artifacts(doc, 0) # erase both header and footer of page 0
Julia
using PdfOxide
doc = open_document("report.pdf")
erase_header(doc, 0) # erase the top 15% of page 0
erase_footer(doc, 0) # erase the bottom 15% of page 0
erase_artifacts(doc, 0) # erase both header and footer of page 0
Zig
const pdf_oxide = @import("pdf_oxide");
var doc = try pdf_oxide.Document.open("report.pdf");
defer doc.deinit();
_ = try doc.eraseHeader(0); // erase the top 15% of page 0
_ = try doc.eraseFooter(0); // erase the bottom 15% of page 0
_ = try doc.eraseArtifacts(0); // erase both header and footer of page 0
Objective-C
#import "POXPdfOxide.h"
NSError *err = nil;
POXDocument *doc = [POXDocument openPath:@"report.pdf" error:&err];
[doc eraseHeader:0 error:&err]; // erase the top 15% of page 0
[doc eraseFooter:0 error:&err]; // erase the bottom 15% of page 0
[doc eraseArtifacts:0 error:&err]; // erase both header and footer of page 0
Elixir
{:ok, doc} = PdfOxide.open("report.pdf")
{:ok, _} = PdfOxide.erase_header(doc, 0) # erase the top 15% of page 0
{:ok, _} = PdfOxide.erase_footer(doc, 0) # erase the bottom 15% of page 0
{:ok, _} = PdfOxide.erase_artifacts(doc, 0) # erase both header and footer of page 0
완전한 가림 처리 워크플로
이 예제에서는 민감한 영역을 찾아 파괴적 가림 처리를 대기열에 추가하고, 메타데이터 정화와 함께 적용한 뒤 깨끗한 파일을 저장합니다.
Python
from pdf_oxide import PdfDocument
doc = PdfDocument("sensitive-report.pdf")
# Step 1: locate sensitive text and queue a destructive box for each match.
for i in range(doc.page_count()):
page = doc.page(i)
for t in page.find_text_containing("SSN"):
x, y, w, h = t.bbox # (x, y, width, height)
doc.add_redaction(i, (x, y, x + w, y + h))
# Step 2: apply destructively + scrub metadata (the default).
report = doc.apply_redactions_destructive(scrub_metadata=True)
print("regions:", report["regions"], "glyphs removed:", report["glyphs_removed"])
# Step 3: save the rewritten document.
doc.save("report-redacted.pdf")
Rust
use pdf_oxide::editor::{DocumentEditor, EditableDocument};
use pdf_oxide::redaction::RedactionOptions;
let mut editor = DocumentEditor::open("sensitive-report.pdf")?;
// Step 1: queue destructive boxes (x0, y0, x1, y1 in points).
editor.add_redaction(0, [100.0, 700.0, 300.0, 714.0], None)?;
editor.add_redaction(0, [100.0, 680.0, 300.0, 694.0], None)?;
// Step 2: apply destructively with safe defaults (scrubs metadata).
let report = editor.apply_redactions_destructive(RedactionOptions::default())?;
println!(
"regions: {}, glyphs removed: {}",
report.regions, report.glyphs_removed
);
// Step 3: save.
editor.save("report-redacted.pdf")?;
Java
import fyi.oxide.pdf.*;
import fyi.oxide.pdf.search.SearchMatch;
try (PdfDocument doc = PdfDocument.open("sensitive-report.pdf");
DocumentEditor editor = DocumentEditor.open("sensitive-report.pdf")) {
// Step 1: locate sensitive text and queue a destructive box for each hit.
for (SearchMatch m : doc.search("SSN")) {
editor.addRedaction(m.pageIndex(), m.bbox()); // bbox is x0,y0,x1,y1
}
// Step 2: apply destructively + scrub metadata (the default).
editor.applyRedactionsDestructive();
// Step 3: save.
editor.saveTo(java.nio.file.Path.of("report-redacted.pdf"));
}
Kotlin
import fyi.oxide.pdf.*
PdfDocument.open("sensitive-report.pdf").use { doc ->
DocumentEditor.open("sensitive-report.pdf").use { editor ->
// Step 1: locate sensitive text and queue a box for each hit.
for (m in doc.search("SSN")) {
editor.addRedaction(m.pageIndex(), m.bbox()) // bbox is x0,y0,x1,y1
}
// Step 2: apply destructively + scrub metadata (the default).
editor.applyRedactionsDestructive()
// Step 3: save.
editor.saveTo(java.nio.file.Path.of("report-redacted.pdf"))
}
}
Scala
import fyi.oxide.pdf.{PdfDocument, DocumentEditor, searchSeq}
import scala.util.Using
Using.resource(PdfDocument.open("sensitive-report.pdf")) { doc =>
Using.resource(DocumentEditor.open("sensitive-report.pdf")) { editor =>
// Step 1: locate sensitive text and queue a box for each hit.
for (m <- doc.searchSeq("SSN"))
editor.addRedaction(m.pageIndex, m.bbox) // bbox is x0,y0,x1,y1
// Step 2: apply destructively + scrub metadata (the default).
editor.applyRedactionsDestructive()
// Step 3: save.
editor.saveTo(java.nio.file.Path.of("report-redacted.pdf"))
}
}
Clojure
(require '[pdf-oxide.core :as pdf])
(with-open [doc (pdf/open "sensitive-report.pdf")
ed (pdf/editor "sensitive-report.pdf")]
;; Step 1: locate sensitive text and queue a box for each hit.
(doseq [m (pdf/search doc "SSN")]
(pdf/add-redaction ed (.pageIndex m) (.bbox m))) ; bbox is x0,y0,x1,y1
;; Step 2: apply destructively + scrub metadata (the default).
(pdf/apply-redactions ed)
;; Step 3: save.
(java.nio.file.Files/write
(java.nio.file.Path/of "report-redacted.pdf" (into-array String []))
(pdf/editor-save ed)))
Ruby
require 'pdf_oxide'
doc = PdfOxide::PdfDocument.open('sensitive-report.pdf')
PdfOxide::DocumentEditor.open('sensitive-report.pdf') do |ed|
# Step 1: locate sensitive text and queue a box for each hit.
doc.search('SSN').each do |m|
b = m[:bbox] # { x:, y:, width:, height: }
ed.add_redaction(page: m[:page], rect: [b[:x], b[:y], b[:x] + b[:width], b[:y] + b[:height]])
end
# Step 2: apply destructively + scrub metadata (raises on fail-closed).
ed.apply_redactions!(scrub_metadata: true)
# Step 3: save.
ed.save_to('report-redacted.pdf')
end
C++
#include <pdf_oxide/pdf_oxide.hpp>
auto doc = pdf_oxide::Document::open("sensitive-report.pdf");
auto editor = pdf_oxide::DocumentEditor::open("sensitive-report.pdf");
// Step 1: locate sensitive text and queue a box for each hit.
for (const auto& m : doc.search_all("SSN", /*case_sensitive=*/false)) {
editor.redaction_add(m.page, m.bbox.x, m.bbox.y,
m.bbox.x + m.bbox.width, m.bbox.y + m.bbox.height,
0.0, 0.0, 0.0);
}
// Step 2: apply destructively + scrub metadata.
int glyphs = editor.redaction_apply(/*scrub_metadata=*/true, 0.0, 0.0, 0.0);
std::cout << "glyphs removed: " << glyphs << "\n";
// Step 3: save.
editor.save("report-redacted.pdf");
Swift
import PdfOxide
let doc = try Document.open("sensitive-report.pdf")
let editor = try DocumentEditor.open("sensitive-report.pdf")
// Step 1: locate sensitive text and queue a box for each hit.
for m in try doc.searchAll("SSN", false) {
try editor.redactionAdd(m.page,
x1: m.bbox.x, y1: m.bbox.y,
x2: m.bbox.x + m.bbox.width, y2: m.bbox.y + m.bbox.height,
r: 0, g: 0, b: 0)
}
// Step 2: apply destructively + scrub metadata.
let glyphs = try editor.redactionApply(scrubMetadata: true, r: 0, g: 0, b: 0)
print("glyphs removed: \(glyphs)")
// Step 3: save.
try editor.save("report-redacted.pdf")
Dart
import 'package:pdf_oxide/pdf_oxide.dart';
final doc = PdfDocument.open('sensitive-report.pdf');
final editor = DocumentEditor.open('sensitive-report.pdf');
// Step 1: locate sensitive text and queue a box for each hit.
for (final m in doc.searchAll('SSN', false)) {
editor.redactionAdd(m.page, m.bbox.x, m.bbox.y,
m.bbox.x + m.bbox.width, m.bbox.y + m.bbox.height);
}
// Step 2: apply destructively + scrub metadata.
final glyphs = editor.redactionApply(scrubMetadata: true);
print('glyphs removed: $glyphs');
// Step 3: save.
editor.save('report-redacted.pdf');
R
library(pdfoxide)
doc <- pdf_open("sensitive-report.pdf")
editor <- pdf_editor_open("sensitive-report.pdf")
# Step 1: locate sensitive text and queue a box for each hit.
for (m in pdf_search_all(doc, "SSN", FALSE)) {
b <- m$bbox # list(x=, y=, width=, height=)
pdf_redaction_add(editor, m$page, b$x, b$y, b$x + b$width, b$y + b$height, 0, 0, 0)
}
# Step 2: apply destructively + scrub metadata.
glyphs <- pdf_redaction_apply(editor, scrub_metadata = TRUE, 0, 0, 0)
cat("glyphs removed:", glyphs, "\n")
# Step 3: save.
pdf_editor_save(editor, "report-redacted.pdf")
Julia
using PdfOxide
doc = open_document("sensitive-report.pdf")
editor = open_editor("sensitive-report.pdf")
# Step 1: locate sensitive text and queue a box for each hit.
for m in search_all(doc, "SSN", false)
b = m.bbox
redaction_add(editor, m.page, b.x, b.y, b.x + b.width, b.y + b.height, 0, 0, 0)
end
# Step 2: apply destructively + scrub metadata.
glyphs = redaction_apply(editor, true, 0, 0, 0)
println("glyphs removed: ", glyphs)
# Step 3: save.
save(editor, "report-redacted.pdf")
Zig
const pdf_oxide = @import("pdf_oxide");
const a = std.heap.page_allocator;
var doc = try pdf_oxide.Document.open("sensitive-report.pdf");
defer doc.deinit();
var editor = try pdf_oxide.DocumentEditor.openEditor("sensitive-report.pdf");
defer editor.deinit();
// Step 1: locate sensitive text and queue a box for each hit.
const hits = try doc.searchAll(a, "SSN", false);
for (hits) |m| {
try editor.redactionAdd(@intCast(m.page), m.bbox.x, m.bbox.y,
m.bbox.x + m.bbox.width, m.bbox.y + m.bbox.height, 0, 0, 0);
}
// Step 2: apply destructively + scrub metadata.
const glyphs = try editor.redactionApply(true, 0, 0, 0);
std.debug.print("glyphs removed: {d}\n", .{glyphs});
// Step 3: save.
try editor.save("report-redacted.pdf");
Objective-C
#import "POXPdfOxide.h"
NSError *err = nil;
POXDocument *doc = [POXDocument openPath:@"sensitive-report.pdf" error:&err];
POXDocumentEditor *editor = [POXDocumentEditor openEditor:@"sensitive-report.pdf" error:&err];
// Step 1: locate sensitive text and queue a box for each hit.
for (POXSearchResult *m in [doc searchAll:@"SSN" caseSensitive:NO error:&err]) {
POXBbox b = m.bbox;
[editor redactionAddPage:m.page x1:b.x y1:b.y x2:b.x + b.width y2:b.y + b.height
r:0 g:0 b:0 error:&err];
}
// Step 2: apply destructively + scrub metadata.
int32_t glyphs = [editor redactionApplyScrubMetadata:YES r:0 g:0 b:0 error:&err];
NSLog(@"glyphs removed: %d", glyphs);
// Step 3: save.
[editor saveToPath:@"report-redacted.pdf" error:&err];
Elixir
{:ok, doc} = PdfOxide.open("sensitive-report.pdf")
{:ok, editor} = PdfOxide.open_editor("sensitive-report.pdf")
# Step 1: locate sensitive text and queue a box for each hit.
{:ok, hits} = PdfOxide.search_all(doc, "SSN", false)
Enum.each(hits, fn m ->
b = m.bbox
PdfOxide.redaction_add(editor, m.page, b.x, b.y, b.x + b.width, b.y + b.height, 0.0, 0.0, 0.0)
end)
# Step 2: apply destructively + scrub metadata.
{:ok, glyphs} = PdfOxide.redaction_apply(editor, true, 0.0, 0.0, 0.0)
IO.puts("glyphs removed: #{glyphs}")
# Step 3: save.
PdfOxide.editor_save(editor, "report-redacted.pdf")
메서드 참조
파괴적 가림 처리
| 표준명 (C ABI) | Rust (DocumentEditor) |
Python (PdfDocument) |
Go (DocumentEditor) |
C# (DocumentEditor) |
JS (WASM) |
|---|---|---|---|---|---|
pdf_redaction_add |
add_redaction(page, [x0,y0,x1,y1], Option<[r,g,b]>) -> Result<()> |
add_redaction(page, rect, fill=None) |
AddRedaction(page, [4]float64, *[3]float64) error |
AddRedaction(pageIndex, x1, y1, x2, y2, r=0, g=0, b=0) |
addRedaction(page, x0, y0, x1, y1, fill?) |
pdf_redaction_count |
redaction_count(page) -> Result<usize> |
redaction_count(page) -> int |
RedactionCount(page) (int, error) |
RedactionCount(pageIndex) -> int |
redactionCount(page) -> number |
pdf_redaction_apply |
apply_redactions_destructive(RedactionOptions) -> Result<RedactionReport> |
apply_redactions_destructive(scrub_metadata=True, remove_javascript=True, remove_embedded_files=True, fill=(0,0,0)) -> dict |
ApplyRedactions(scrubMetadata bool) (int, error) |
ApplyRedactions(scrubMetadata=true, r=0, g=0, b=0) -> int |
applyRedactionsDestructive(scrubMetadata?) -> RedactionReport |
pdf_redaction_scrub_metadata |
sanitize_document(RedactionOptions) -> Result<RedactionReport> |
sanitize_document(scrub_metadata=True, remove_javascript=True, remove_embedded_files=True) -> dict |
SanitizeDocument() (int, error) |
SanitizeDocument() -> int |
sanitizeDocument(scrub?, removeJS?, removeEmbedded?) -> RedactionReport |
Swift 래퍼는
DocumentEditor에서redactionAdd,redactionCount,redactionApply(scrubMetadata:r:g:b:),redactionScrubMetadata()로 동일한 패밀리를 제공합니다.
헤더/푸터/아티팩트 제거
| 표준명 (C ABI) | Rust (PdfDocument) |
Python (PdfDocument) |
Go (PdfDocument) |
JS (WASM) |
|---|---|---|---|---|
pdf_document_remove_headers |
remove_headers(threshold: f32) -> Result<usize> |
remove_headers(threshold=0.8) -> int |
RemoveHeaders(threshold float32) (int, error) |
removeHeaders(threshold) -> number |
pdf_document_remove_footers |
remove_footers(threshold: f32) -> Result<usize> |
remove_footers(threshold=0.8) -> int |
RemoveFooters(threshold float32) (int, error) |
removeFooters(threshold) -> number |
pdf_document_remove_artifacts |
remove_artifacts(threshold: f32) -> Result<usize> |
remove_artifacts(threshold=0.8) -> int |
RemoveArtifacts(threshold float32) (int, error) |
removeArtifacts(threshold) -> number |
pdf_document_erase_header |
erase_header(page: usize) -> Result<()> |
erase_header(page) -> None |
— | eraseHeader(page) |
pdf_document_erase_footer |
erase_footer(page: usize) -> Result<()> |
erase_footer(page) -> None |
— | eraseFooter(page) |
pdf_document_erase_artifacts |
erase_artifacts(page: usize) -> Result<()> |
erase_artifacts(page) -> None |
— | eraseArtifacts(page) |
Swift는
Document에서removeHeaders(threshold:),removeFooters(threshold:),removeArtifacts(threshold:),eraseHeader(_:),eraseFooter(_:),eraseArtifacts(_:)를 제공합니다. Go의PdfDocument는Remove*패밀리를 제공하지만 페이지별Erase*패밀리는 제공하지 않습니다. C#은 현재 어떤 장식 패밀리도 제공하지 않습니다.
RedactionReport
redaction_apply와 redaction_scrub_metadata는 패스가 실제로 작업을 수행했는지 검증할 수 있도록 보고서를 반환합니다.
| 필드 | 의미 |
|---|---|
regions |
적용된 영역 수. |
glyphs_removed |
콘텐츠 스트림에서 물리적으로 제거된 글리프 수. |
images_modified / images_removed |
덮인 픽셀이 덮어씌워진 이미지 수 / 완전히 삭제된 이미지 수. |
paths_pruned |
삭제되거나 기하학적으로 클리핑된 패스 서브패스 수. |
annotations_removed |
제거된 최상위 항목 수(가림 처리용 어노테이션; sanitize_document의 정화된 루트). |
fonts_scrubbed |
/Widths / /ToUnicode가 정리된 폰트 수. |
bytes_removed |
제거된 총 바이트 수의 최선 추정값. |
중요 사항
- 파괴적이며 외관적이지 않습니다.
redaction_apply는 ISO 32000-1:2008 §12.5.6.23에 따라 재작성된 파일에서 덮인 콘텐츠를 물리적으로 제거합니다. 비밀 텍스트는 단순히 오버레이로 덮이는 것이 아니라 파일에서 사라집니다. 원본/Contents객체는 하드 드롭되므로 GC에서 누락된 고아 객체로 살아남을 수 없습니다. - 실패 종료. 가림 처리할 페이지에 복합/Type0 또는 재작성 불가능한 폰트의 텍스트가 있으면
redaction_apply는 조용히 가림 처리를 생략하는 위험을 피하고자 오류를 반환합니다. 오류를 처리하세요. 성공을 가정하지 마세요. - 안전한 기본값.
RedactionOptions::default()는 메타데이터를 정리하고, 문서 JavaScript와 임베디드 파일을 제거하고, 숨겨진 선택적 콘텐츠 레이어를 제거하며, 소스/Redact어노테이션에/IC색상이 없을 때도 불투명한 검은 오버레이를 그립니다. - 되돌릴 수 없습니다. 저장 후 제거는 영구적입니다. 항상 원본 문서의 복사본으로 작업하세요.
- 성능. 가림 처리와 정화는 평균 0.8ms, 100% 통과율을 제공하는 동일한 파서 위에서 실행되므로, 가림 처리 패스의 오버헤드는 콘텐츠 재작성 자체를 크게 초과하지 않습니다.
자주 묻는 질문
PDF Oxide의 가림 처리는 진정으로 파괴적인가요, 아니면 텍스트 위에 검은 박스를 올리는 것뿐인가요?
진정으로 파괴적입니다. redaction_apply(apply_redactions_destructive)는 ISO 32000-1:2008 §12.5.6.23에 따라 덮인 글리프, 이미지, 패스 기하학을 콘텐츠 스트림에서 제거하고 원본 /Contents 객체를 출력에서 하드 드롭합니다. 검은 오버레이는 콘텐츠 제거를 대신하는 것이 아니라 추가로 그려집니다.
복합 폰트를 사용하는 페이지를 안전하게 가림 처리할 수 없는 경우 어떻게 되나요?
가림 처리가 실패 종료됩니다. redaction_apply는 부분적으로 가림 처리하고 회수 가능한 조각을 남기는 대신 오류를 반환합니다. 오류를 캐치하고, 그러한 콘텐츠를 가림 처리해야 한다면 페이지를 래스터화하는 방법으로 대체하세요.
메타데이터만 제거하기 위해 영역을 가림 처리할 필요가 있나요?
아니요. 페이지 기하학에 영향을 주지 않고 /Info, XMP /Metadata, 문서 JavaScript, 임베디드 파일을 제거하는 독립 패스를 위해 redaction_scrub_metadata(sanitize_document)를 호출하세요.
헤더와 푸터는 어떻게 감지되어 제거되나요?
PDF Oxide는 ISO 32000 /Artifact 태그를 우선 사용합니다(존재 시 100% 정확도). 없을 경우 페이지의 상하 15% 영역에서 최소 threshold 비율의 페이지에 걸쳐 반복되는 텍스트를 장식으로 표시하는 휴리스틱을 사용합니다(기본값 0.8).
관련 페이지
- 어노테이션 편집 — 어노테이션 작업
- 페이지 작업 — 대안으로서의 사각형 콘텐츠 지우기
- 텍스트 편집 — 가림 처리할 텍스트 찾기
- 암호화 및 보안 — 가림 처리 후 접근 제한
- PDF/A 및 규정 준수 — 정화 후 아카이브 출력