IronOCR OCR 프로그램으로 pdf 텍스트 추출 후 PDF 파일 크기 줄이기
IronOCR에서 출력 PDF의 파일 크기를 줄이려면 어떻게 하나요?
IronOCR은 정확한 읽기 결과를 보장하기 위해 저품질(150DPI 미만)로 감지된 입력을 자동으로 업스케일합니다.
DPI가 150 미만으로 감지되면, TargetDPI(기본 225DPI)가 PDF가 렌더링되는 DPI를 정의합니다. 이것은 TargetDPI = 225을 수동으로 설정하는 것과 같습니다.
출력 파일 크기를 줄이기 위해, 더 작은 PDF를 생성할 수 있는 낮은 TargetDPI을 설정할 수 있습니다. 그러나 너무 낮게 설정하면 OCR 성능에 영향을 미칠 수 있으므로 균형을 유지하는 것이 중요합니다.
권장 값은 각각 96, 72, 48입니다.
// Example of reducing PDF output file size by lowering the DPI
// Example 1: Reducing DPI to 96
using IronOcr; // Import IronOCR namespace
var Ocr = new IronTesseract(); // Initialize IronTesseract for OCR operations
using (var Input = new OcrInput()) // Create OCR input object
{
Input.TargetDPI = 96; // Set the desired DPI; 96 is used for smaller output size
Input.AddPdf("example.pdf", "password"); // Add input PDF (with optional password)
var Result = Ocr.Read(Input); // Perform OCR on the input
Console.WriteLine(Result.Text); // Output recognized text to the console
}
// Example 2: Another way to set DPI
var ocr = new IronTesseract();
using (var ocrInput = new OcrInput()) // Create a new OCR input object
{
ocrInput.AddPdf("img/Input.pdf", 72); // Add PDF with the specified DPI of 72
var ocrResult = ocr.Read(ocrInput); // Read and process the PDF
ocrResult.SaveAsSearchablePdf(@"Output.pdf"); // Save result to a searchable PDF
}
// Example of reducing PDF output file size by lowering the DPI
// Example 1: Reducing DPI to 96
using IronOcr; // Import IronOCR namespace
var Ocr = new IronTesseract(); // Initialize IronTesseract for OCR operations
using (var Input = new OcrInput()) // Create OCR input object
{
Input.TargetDPI = 96; // Set the desired DPI; 96 is used for smaller output size
Input.AddPdf("example.pdf", "password"); // Add input PDF (with optional password)
var Result = Ocr.Read(Input); // Perform OCR on the input
Console.WriteLine(Result.Text); // Output recognized text to the console
}
// Example 2: Another way to set DPI
var ocr = new IronTesseract();
using (var ocrInput = new OcrInput()) // Create a new OCR input object
{
ocrInput.AddPdf("img/Input.pdf", 72); // Add PDF with the specified DPI of 72
var ocrResult = ocr.Read(ocrInput); // Read and process the PDF
ocrResult.SaveAsSearchablePdf(@"Output.pdf"); // Save result to a searchable PDF
}
' Example of reducing PDF output file size by lowering the DPI
' Example 1: Reducing DPI to 96
Imports IronOcr ' Import IronOCR namespace
Private Ocr = New IronTesseract() ' Initialize IronTesseract for OCR operations
Using Input = New OcrInput() ' Create OCR input object
Input.TargetDPI = 96 ' Set the desired DPI; 96 is used for smaller output size
Input.AddPdf("example.pdf", "password") ' Add input PDF (with optional password)
Dim Result = Ocr.Read(Input) ' Perform OCR on the input
Console.WriteLine(Result.Text) ' Output recognized text to the console
End Using
' Example 2: Another way to set DPI
Dim ocr = New IronTesseract()
Using ocrInput As New OcrInput() ' Create a new OCR input object
ocrInput.AddPdf("img/Input.pdf", 72) ' Add PDF with the specified DPI of 72
Dim ocrResult = ocr.Read(ocrInput) ' Read and process the PDF
ocrResult.SaveAsSearchablePdf("Output.pdf") ' Save result to a searchable PDF
End Using
자동 업스케일링을 비활성화하려면 TargetDPI = 0을 사용하세요. 이렇게 하면 IronOCR이 TargetDPI 값을 무시하고 입력 파일을 그대로 읽습니다.
API에 대한 자세한 정보는 다음을 참조하세요: IronOCR API 참조문서

