/// <summary> /// Gets rescaling factor for native width x height of the page /// so it maximizes the dimOne x dimTwo rectangle /// </summary> /// <param name="page">Page object</param> /// <param name="dimOne">Smaller dimension</param> /// <param name="dimTwo">Larger dimension</param> /// <returns>Scaling factor</returns> private static double GetScalingFactor(FpdfPageT page, int dimOne, int dimTwo) { var width = fpdf_view.FPDF_GetPageWidth(page); var height = fpdf_view.FPDF_GetPageHeight(page); var scaleOne = dimOne / Math.Min(width, height); var scalingTwo = dimTwo / Math.Max(width, height); return(Math.Min(scaleOne, scalingTwo)); }
internal static int FPDFImageObjLoadJpegFile(FpdfPageT pages, int nCount, FpdfPageobjectT image_object, FileHandle fileAccess) { unsafe { var array = new[] { pages.__Instance }; fixed(IntPtr *dataPtr = &array[0]) { return(FPDFImageObjLoadJpegFileInternal(dataPtr, nCount, image_object.__Instance, fileAccess)); } } }
public RenderPageAction(ThreadDispatcher dispatcher, FpdfPageT pageInstance, float scale, RectangleF viewport, RenderFlags flags, Color?backgroundColor) { _pageInstance = pageInstance; _scale = scale; _viewport = viewport; _flags = flags; _backgroundColor = backgroundColor; _dispatcher = dispatcher; }
/// <summary> /// Gets rescaling factor for native width x height of the page /// so it maximizes the dimOne x dimTwo rectangle /// /// Note: make sure that the semaphore is locked before access. /// </summary> /// <param name="page">Page object.</param> /// <returns>Scaling factor.</returns> internal double GetScalingFactor(FpdfPageT page) { if (_scalingFactor != null) { return(_scalingFactor.Value); } var width = fpdf_view.FPDF_GetPageWidth(page); var height = fpdf_view.FPDF_GetPageHeight(page); var scaleOne = DimOne / Math.Min(width, height); var scalingTwo = DimTwo / Math.Max(width, height); return(Math.Min(scaleOne, scalingTwo)); }
public PageReader(DocumentWrapper docWrapper, int pageIndex, PageDimensions pageDimensions) { PageIndex = pageIndex; lock (DocLib.Lock) { _page = fpdf_view.FPDF_LoadPage(docWrapper.Instance, pageIndex); if (_page == null) { throw new DocnetException($"failed to open page for page index {pageIndex}"); } _text = fpdf_text.FPDFTextLoadPage(_page); if (_text == null) { throw new DocnetException($"failed to open page text for page index {pageIndex}"); } _scaling = pageDimensions.GetScalingFactor(_page); } }
private PdfPage(ThreadDispatcher dispatcher, FpdfDocumentT documentInstance, FpdfPageT pageInstance) { _dispatcher = dispatcher; _documentInstance = documentInstance; _pageInstance = pageInstance; }