I need the new syntax in order to be able to convert a PDF into a searchable PDF. My previous code following:
Code: Select all
GdPictureImaging gdImaging = new GdPictureImaging();
GdViewer gdViewer = new GdViewer();
lock (licenseLock)
{
gdImaging.SetLicenseNumber(Properties.Settings.Default.GDPictureLicense);
gdImaging.SetLicenseNumberOCRTesseract(Properties.Settings.Default.GDTesserectLicense);
gdViewer.SetLicenseNumber(Properties.Settings.Default.GDPictureLicense);
gdViewer.DisplayFromFile(fileName);
}
// seems to take a second to get access to the gd library
Thread.Sleep(500);
if (fileName.IndexOf(".pdf") > -1)
{
int newPDFID = gdImaging.PdfOCRStart(defPdfFilePath + "working" + core.ToString() + ".pdf", true, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
for (int y = 1; y <= gdViewer.PageCount; y++)
{
if (stopRunning)
{
return;
}
imageID = gdViewer.PdfRenderPageToGdPictureImage(400, y);
gdImaging.ConvertTo1Bpp(imageID);
gdImaging.PdfAddGdPictureImageToPdfOCR(newPDFID, imageID, TesseractDictionary.TesseractDictionaryEnglish, defPdfFilePath + "OCR\\", string.Empty);
gdImaging.ReleaseGdPictureImage(imageID);
}
gdImaging.PdfOCRStop(newPDFID);
}
else if (fileName.IndexOf(".tif") > -1)
{
gdImaging.TiffOpenMultiPageForWrite(false);
imageID = gdImaging.TiffCreateMultiPageFromFile(fileName);
gdImaging.PdfOCRCreateFromMultipageTIFF(imageID, TesseractDictionary.TesseractDictionaryEnglish, defPdfFilePath + "OCR\\", string.Empty, defPdfFilePath + "working" + core.ToString() + ".pdf", true, fileName, string.Empty, fileName, string.Empty, string.Empty);
gdImaging.ReleaseGdPictureImage(imageID);
}
if (stopRunning)
{
return;
}
// determine if PDF is searchable now
gdViewer.DisplayFromFile(defPdfFilePath + "working" + core.ToString() + ".pdf");
string pdfText = string.Empty;
for (int y = 1; y <= (gdViewer.PageCount > defPages ? defPages : gdViewer.PageCount); y++)
{
pdfText += gdViewer.PdfGetPageText(y);
}
gdViewer.CloseDocument();