在IronOCR中減少PDF文件大小

This article was translated from English: Does it need improvement?
Translated
View the article in English

如何在IronOCR中減少輸出PDF的檔案大小?

IronOCR 將自動升級檢測到的低品質輸入(低於150DPI)確保讀取結果的準確性。

如果检测到 DPI 低于150,则 TargetDPI(預設 225DPI)定義了PDF呈現的DPI - 這與手動設置TargetDPI = 225相同。

要減少輸出文件的大小,您可以設置較低的目標DPI,這將創建較小的PDF文件,但是DPI設置過低可能會影響OCR的性能。 一切都在平衡中。

建議值為 96、72、48

// how to reduce and usage by by reducing DPI
    //Example 1
    using IronOcr;
    var Ocr = new IronTesseract();
    using (var Input = new OcrInput())
    {
        Input.TargetDPI = 96;    // DPI of output, default is 225
        Input.AddPdf("example.pdf", "password");
        var Result = Ocr.Read(Input);
        Console.WriteLine(Result.Text);
    }

    //Example 2
    var ocr = new IronTesseract();
    using (var ocrInput = new OcrInput())
    {
    ocrInput.AddPdf("img/Input.pdf", 72); //TargetDPI
    var ocrResult = ocr.Read(ocrInput);
    ocrResult.SaveAsSearchablePdf(@"Output.pdf");
    }
// how to reduce and usage by by reducing DPI
    //Example 1
    using IronOcr;
    var Ocr = new IronTesseract();
    using (var Input = new OcrInput())
    {
        Input.TargetDPI = 96;    // DPI of output, default is 225
        Input.AddPdf("example.pdf", "password");
        var Result = Ocr.Read(Input);
        Console.WriteLine(Result.Text);
    }

    //Example 2
    var ocr = new IronTesseract();
    using (var ocrInput = new OcrInput())
    {
    ocrInput.AddPdf("img/Input.pdf", 72); //TargetDPI
    var ocrResult = ocr.Read(ocrInput);
    ocrResult.SaveAsSearchablePdf(@"Output.pdf");
    }
' how to reduce and usage by by reducing DPI
	'Example 1
	Imports IronOcr
	Private Ocr = New IronTesseract()
	Using Input = New OcrInput()
		Input.TargetDPI = 96 ' DPI of output, default is 225
		Input.AddPdf("example.pdf", "password")
		Dim Result = Ocr.Read(Input)
		Console.WriteLine(Result.Text)
	End Using

	'Example 2
	Dim ocr = New IronTesseract()
	Using ocrInput As New OcrInput()
	ocrInput.AddPdf("img/Input.pdf", 72) 'TargetDPI
	Dim ocrResult = ocr.Read(ocrInput)
	ocrResult.SaveAsSearchablePdf("Output.pdf")
	End Using
VB   C#

要禁用自動上縮放,請使用 TargetDPI = 0。 這將忽略 TargetDPI 值,並將輸入文件按原樣讀取。

請查看 API 以獲取更多資訊:https://ironsoftware.com/csharp/ocr/object-reference/api/IronOcr.OcrInput.html?q=targetdpi#IronOcr_OcrInput_TargetDPI