public void Delete(PsImage Obj) { //suppression de l'image de toutes les boutiques DBPrestashop.PsImageShop.DeleteAllOnSubmit(ListInShop(Obj.IDImage)); this.DBPrestashop.PsImage.DeleteOnSubmit(Obj); this.Save(); }
public bool OcrImageToPage(PsImage _image, PdfMatrix _matrix, PdfPage _page, PdfCancelProc _cancel_proc, IntPtr _cancel_data) { CheckBaseObj(); PdfMatrixInt _matrixInt = _matrix.GetIntStruct(); IntPtr _matrix_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(PdfMatrixInt))); Marshal.StructureToPtr(_matrixInt, _matrix_ptr, true); byte ret = TesseractDocOcrImageToPage(m_obj, _image == null ? IntPtr.Zero : _image.m_obj, _matrix_ptr, _page == null ? IntPtr.Zero : _page.m_obj, _cancel_proc, _cancel_data); Marshal.FreeHGlobal(_matrix_ptr); _matrix_ptr = IntPtr.Zero; return(ret != 0); }
public void Add(PsImage Obj, UInt32 IDShop) { this.DBPrestashop.PsImage.InsertOnSubmit(Obj); this.Save(); //Si l'image n'existe pas dans la boutique, elle est rajoutée. if (!ExistInShop(Obj.IDImage, IDShop)) { DBPrestashop.PsImageShop.InsertOnSubmit(new PsImageShop() { IDImage = Obj.IDImage, IDShop = IDShop, #if (PRESTASHOP_VERSION_161 || PRESTASHOP_VERSION_172) IDProduct = Obj.IDProduct, Cover = Obj.Cover, #elif (PRESTASHOP_VERSION_160) Cover = (sbyte)Obj.Cover, #elif (PREStASHOP_VERSION_15) Cover = Obj.Cover, #endif }); DBPrestashop.SubmitChanges(); } }
public async Task <List <string> > ExtractImage( String email, String licenseKey, String openPath, String imgPath, Double zoom ) { List <string> imageList = new List <string>(); try { Pdfix pdfix = new Pdfix(); if (pdfix == null) { throw new Exception("Pdfix initialization fail"); } if (!pdfix.Authorize(email, licenseKey)) { throw new Exception(pdfix.GetError()); } PdfDoc doc = pdfix.OpenDoc(openPath, ""); if (doc == null) { throw new Exception(pdfix.GetError()); } for (int i = 0; i < doc.GetNumPages(); i++) { PdfPage page = doc.AcquirePage(i); if (page == null) { throw new Exception(pdfix.GetError()); } PdfPageView pageView = page.AcquirePageView(zoom, PdfRotate.kRotate0); if (pageView == null) { throw new Exception(pdfix.GetError()); } int width = pageView.GetDeviceWidth(); int height = pageView.GetDeviceHeight(); PsImage image = pdfix.CreateImage(width, height, PsImageDIBFormat.kImageDIBFormatArgb); if (image == null) { throw new Exception(pdfix.GetError()); } PdfPageRenderParams pdfPageRenderParams = new PdfPageRenderParams(); pdfPageRenderParams.image = image; pdfPageRenderParams.matrix = pageView.GetDeviceMatrix(); pdfPageRenderParams.render_flags = Pdfix.kRenderAnnot; if (!page.DrawContent(pdfPageRenderParams, null, IntPtr.Zero)) { throw new Exception(pdfix.GetError()); } PsStream stream = pdfix.CreateFileStream(imgPath + i.ToString() + ".jpg", PsFileMode.kPsWrite); PdfImageParams imgParams = new PdfImageParams(); imgParams.format = PdfImageFormat.kImageFormatJpg; imgParams.quality = 75; if (!image.SaveToStream(stream, imgParams)) { throw new Exception(pdfix.GetError()); } imageList.Add(imgPath + i.ToString()); stream.Destroy(); pageView.Release(); page.Release(); } doc.Close(); } catch (Exception ex) { throw ex; } return(imageList); }