Reducir el tamaño de archivos PDF en IronOCR

19 de enero, 2022
Actualizado 20 de octubre, 2024
Compartir:
This article was translated from English: Does it need improvement?
Translated
View the article in English

¿Cómo puedo reducir el tamaño del archivo PDF de salida en IronOCR?

IronOCR escalará automáticamente los datos de entrada que se detecten como de baja calidad (por debajo de 150 DPI) para garantizar resultados de lectura precisos.

Si se detecta un DPI inferior a 150, TargetDPI (por defecto 225DPI) define el DPI al que se renderiza un PDF; esto es lo mismo que configurar manualmente TargetDPI = 225.

Para reducir el tamaño del archivo de salida, puede establecer un TargetDPI más bajo, lo que creará PDF más pequeños, pero un valor demasiado bajo puede afectar al rendimiento del OCR. Todo en equilibrio.

Los valores sugeridos son 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
$vbLabelText   $csharpLabel

Para desactivar el aumento de escala automático, utilice TargetDPI = 0. Esto ignorará el valor TargetDPI y el archivo de entrada se leerá tal cual.

Consulte la API para más información: https://ironsoftware.com/csharp/ocr/object-reference/api/IronOcr.OcrInput.html?q=targetdpi#IronOcr_OcrInput_TargetDPI