public ATAPY.Common.IO.Files CreatePageFiles(ATAPY.Common.IO.File PdfFile) { Trace.Assert(PdfFile != null); ATAPY.Common.IO.Files Ret = new ATAPY.Common.IO.Files(); try { using (GdPicturePDF SourcePDF = new GdPicturePDF()) { if (SourcePDF.LoadFromFile(PdfFile.FullPath, true) != GdPictureStatus.OK) { throw new Warning("Cannot open source file.\r\nSource file -" + PdfFile.FullPath); } if (SourcePDF.IsEncrypted()) { throw new Warning("Source PDF file is encrypted."); } int PagesCount = SourcePDF.GetPageCount(); using (GdPictureImaging Imaging = new GdPictureImaging()) { for (int i = 1; i <= PagesCount; i++) { SourcePDF.SelectPage(i); int RenderedPageId = SourcePDF.RenderPageToGdPictureImageEx((float)DEFAULT_RENDER_DPI, true, System.Drawing.Imaging.PixelFormat.Format24bppRgb); ATAPY.Common.IO.File RetFile = new ATAPY.Common.IO.File(PageImagesFolder, PdfFile.NameWithoutExtension + "_" + i.ToString("D3") + ".png"); Imaging.SaveAsPNG(RenderedPageId, RetFile.FullPath); Imaging.ReleaseGdPictureImage(RenderedPageId); Ret.Add(RetFile); } } SourcePDF.CloseDocument(); } } catch (Exception ex) { GlobalObjects.Log.WriteError(ex); throw; } return(Ret); }
public Document GetDocument(ATAPY.Common.IO.File image, string language) { if (string.IsNullOrEmpty(language)) { throw new ArgumentException("No Languages specified!"); } var document = new ATAPY.Document.Data.Core.Document(); document.Scale = Scale; document.SourceFormat = E_SourceFormat.HOCR; document.SourceFile = image.Clone(); FillPagesData(document, image.FullPath, language); return(document); }
public Document GetDocument(ATAPY.Common.IO.File file) { return(GetDocument(file, "eng")); }