at System.Drawing.Bitmap.SetResolution(Single xDpi, Single yDpi)
at Aspose.Pdf.ImagePlacement.Save(Stream stream, ImageFormat format)
at #=zjHi53l$6uGI3JvQ1j6D1IoBAvGn0NmjDf7rhl0WCwnjsgttVr9WXG3A=.#=zkNlYWlM=(CallBackGetHocr #=zI7htKj75yPRO, Document #=zpJhYYgQ=)
at Aspose.Pdf.Document.Convert(CallBackGetHocr callback)
at Rectify.Core.Utilities.OcrConverterWithAspose.ConvertPDFToSearchable(String inputFilePath, String outputFilePath) in C:\Users\kumar\Documents\rectify-service\Rectify\000-Shared Library\Rectify.Core\Utilities\OcrConverterWithAspose.cs:line 84
I am getting this Exception while converting pdf to Searchable PDF. This what the code I am applying.
public static String ConvertPDFToSearchable(String inputFilePath, String outputFilePath)
{
Document doc = new Document(inputFilePath);
try
{
//doc.Validate("validation-result-A1A.xml", PdfFormat.PDF_A_1B);
doc.Convert(CallBackGetHocrWidthDLL);
doc.Save(outputFilePath);
}
catch (Exception ex)
{
try
{
String TempPath = String.Format("{0}/{1}.tiff", Path.GetTempPath(), DateTime.Now.ToFileTime());
TiffHelper.PDFToTiffImageOnOCRError(inputFilePath, TempPath);
ConvertTiffToSearchable(TempPath, outputFilePath);
File.Delete(TempPath);
}
catch (Exception innerEx)
{
LOGMANAGER.LogsManager.Logger.LogProcessInfo(typeof(OcrConverterWithAspose)
, COREDATAMODELS.LogLevel.SubComponent
, nameof(OcrConverterWithAspose)
, nameof(ConvertPDFToSearchable)
, null
, String.Format("Exception Occure.. {0}", innerEx.Message)
, COREDATAMODELS.Stage.End);
}
LOGMANAGER.LogsManager.Logger.LogProcessInfo(typeof(OcrConverterWithAspose)
, COREDATAMODELS.LogLevel.Component
, nameof(OcrConverterWithAspose)
, nameof(ConvertPDFToSearchable)
, null
, String.Format("Exception Occure.. {0}", ex.Message)
, COREDATAMODELS.Stage.End);
}
return outputFilePath;
}
And this is coming for a particular PDF. I am attaching the PDF. Form NYS45 Complex RegEx Example.pdf (318.0 KB)