예제 #1
0
        public void SetPageCropBox(int index, float left, float right, float top, float bottom)
        {
            IntPtr pageHandle = PdfiumDLL.FPDF_LoadPage(documentHandle, index);

            PdfiumDLL.FPDFPage_SetCropBox(pageHandle, left, bottom, right, top);
            PdfiumDLL.FPDF_ClosePage(pageHandle);
        }
예제 #2
0
        public PageRectangle GetPageCropBox(int index)
        {
            var    rect       = new PageRectangle();
            IntPtr pageHandle = PdfiumDLL.FPDF_LoadPage(documentHandle, index);

            PdfiumDLL.FPDFPage_GetCropBox(pageHandle, out rect.left, out rect.bottom, out rect.right, out rect.top);
            PdfiumDLL.FPDF_ClosePage(pageHandle);

            return(rect);
        }
예제 #3
0
        protected byte[] GetPagePixelsInternal(byte[] buffer, int pageIndex, int width, int height, float dpiX, float dpiY, bool forPrinting)
        {
            IntPtr bitmapHandle;

            bitmapHandle = PdfiumDLL.FPDFBitmap_CreateEx(width, height, 4, buffer, width * 4);
            PdfiumDLL.FPDFBitmap_FillRect(bitmapHandle, 0, 0, width, height, new FPDFColor(0xFFFFFFFF));

            IntPtr pageHandle = PdfiumDLL.FPDF_LoadPage(documentHandle, pageIndex);

            PdfiumDLL.FPDF_RenderPageBitmap(bitmapHandle, pageHandle, 0, 0, width, height, 0, 0);
            PdfiumDLL.FPDF_ClosePage(pageHandle);

            PdfiumDLL.FPDFBitmap_Destroy(bitmapHandle);

            return(buffer);
        }
예제 #4
0
        public Bitmap GetPageImage(int pageIndex, int width, int height, float dpiX, float dpiY, bool forPrinting)
        {
            var        bitmap     = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            BitmapData bitmapData = bitmap.LockBits(
                new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, bitmap.PixelFormat);
            IntPtr bitmapHandle = PdfiumDLL.FPDFBitmap_CreateEx(width, height, 4, bitmapData.Scan0, width * 4);

            PdfiumDLL.FPDFBitmap_FillRect(bitmapHandle, 0, 0, width, height, new FPDFColor(0xFFFFFFFF));

            IntPtr pageHandle = PdfiumDLL.FPDF_LoadPage(documentHandle, pageIndex);

            PdfiumDLL.FPDF_RenderPageBitmap(bitmapHandle, pageHandle, 0, 0, width, height, 0, 0);
            PdfiumDLL.FPDF_ClosePage(pageHandle);

            bitmap.UnlockBits(bitmapData);
            PdfiumDLL.FPDFBitmap_Destroy(bitmapHandle);

            return(bitmap);
        }