/// <summary> Extracts a thumbnail image from a PDF file </summary> /// <param name="Resource"> Incoming digital resource object </param> /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns> public override bool DoWork(Incoming_Digital_Resource Resource) { string resourceFolder = Resource.Resource_Folder; // Get the executable path/file for ghostscript and imagemagick string ghostscript_executable = MultiInstance_Builder_Settings.Ghostscript_Executable; string imagemagick_executable = MultiInstance_Builder_Settings.ImageMagick_Executable; // Preprocess each PDF string[] pdfs = Directory.GetFiles(resourceFolder, "*.pdf"); foreach (string thisPdf in pdfs) { // Get the fileinfo and the name FileInfo thisPdfInfo = new FileInfo(thisPdf); string fileName = thisPdfInfo.Name.Replace(thisPdfInfo.Extension, ""); // Does the thumbnail exist for this item? if ((!String.IsNullOrEmpty(ghostscript_executable)) && (!String.IsNullOrEmpty(imagemagick_executable))) { if (!File.Exists(resourceFolder + "\\" + fileName + "thm.jpg")) { PDF_Tools.Create_Thumbnail(resourceFolder, thisPdf, resourceFolder + "\\" + fileName + "thm.jpg", ghostscript_executable, imagemagick_executable); } } } return(true); }
private void _GenerarComPDFmand() { path = DependencyService.Get <IPathService>().GetDataBasePath("MiPDF.pdf"); PDF_Tools.CreateNewPDF(path); Debug.WriteLine(path); }
/// <summary> Gets the page count from a PDF file, for statiscal reporting </summary> /// <param name="Resource"> Incoming digital resource object </param> /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns> public override bool DoWork(Incoming_Digital_Resource Resource) { // If there are no pages, look for a PDF we can use to get a page count if (Resource.Metadata.Divisions.Physical_Tree.Pages_PreOrder.Count <= 0) { string[] pdf_files = Directory.GetFiles(Resource.Resource_Folder, "*.pdf"); if (pdf_files.Length > 0) { int pdf_page_count = PDF_Tools.Page_Count(pdf_files[0]); if (pdf_page_count > 0) { Resource.Metadata.Divisions.Page_Count = pdf_page_count; } } } return(true); }
/// <summary> Extracts indexable text from a PDF file </summary> /// <param name="Resource"> Incoming digital resource object </param> /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns> public override bool DoWork(Incoming_Digital_Resource Resource) { string resourceFolder = Resource.Resource_Folder; // Preprocess each PDF string[] pdfs = Directory.GetFiles(resourceFolder, "*.pdf"); foreach (string thisPdf in pdfs) { // Get the fileinfo and the name FileInfo thisPdfInfo = new FileInfo(thisPdf); string fileName = thisPdfInfo.Name.Replace(thisPdfInfo.Extension, ""); // Does the full text exist for this item? if (!File.Exists(resourceFolder + "\\" + fileName + "_pdf.txt")) { PDF_Tools.Extract_Text(thisPdf, resourceFolder + "\\" + fileName + "_pdf.txt"); } } return(true); }