public PdfHtmlParams(int _flags, int _width, PdfHtmlType _type, PdfImageParams _image_params) { flags = _flags; width = _width; type = _type; image_params = _image_params; }
internal void SetIntStruct(PdfHtmlParamsInt inStruct) { flags = inStruct.flags; width = inStruct.width; type = (PdfHtmlType)inStruct.type; image_params = new PdfImageParams(); image_params.SetIntStruct(inStruct.image_params); }
private static void ExtractImage(PdfPage page, PdsImage image, string savePath) { // widget specific properties var bbox = image.GetBBox(); var page_view = page.AcquirePageView(1, PdfRotate.kRotate0); var rect = page_view.RectToDevice(bbox); PdfMatrix matrix = page_view.GetDeviceMatrix(); page_view.Release(); string imgPath = savePath + "/image_" + (++_imageIndex).ToString() + ".jpg"; Console.WriteLine("Image Found: " + imgPath); var img = PdfixEngine.Instance.CreateImage(rect.right - rect.left, rect.bottom - rect.top, PsImageDIBFormat.kImageDIBFormatArgb); PdfPageRenderParams renderParams = new PdfPageRenderParams { clip_box = bbox, matrix = matrix, image = img }; if (!page.DrawContent(renderParams, null, null)) { PdfixEngine.ThrowException(); } PdfImageParams imgParams = new PdfImageParams { format = PdfImageFormat.kImageFormatJpg, quality = 80 }; if (!img.Save(imgPath, imgParams)) { PdfixEngine.ThrowException(); } img.Destroy(); }
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); }