Пример #1
0
        public CGSize GetPageSize(int pdfPage)
        {
            float width = 0, height = 0;

            lock (staticLock) {
                IntPtr page = MuPDFLib.LoadPage(context, Handle, pdfPage);
                try {
                    MuPDFLib.GetPageSize(Handle, page, out width, out height);
                    return(new CGSize((int)Math.Ceiling(width), (int)Math.Ceiling(height)));
                } finally {
                    MuPDFLib.ClosePage(context, Handle, page);
                }
            }
        }
Пример #2
0
        public NativeBitmap RenderToBitmap(IntPtr ctx, CGRect bbox, double K, int pdfPage, int angle, ref MuPDFLib.Cookie cookie)
        {
            lock (this) {
                NativeBitmap nbmp = null;

                IntPtr PDFPage = MuPDFLib.LoadPage(ctx, Handle, pdfPage);
                try {
                    nbmp = new NativeBitmap((int)bbox.Width, (int)bbox.Height, 32);
                    MuPDFLib.RenderPageToBytes(ctx, Handle, PDFPage, nbmp.bits, (int)bbox.X, (int)bbox.Y, (int)bbox.Width, (int)bbox.Height, (float)K, angle / 90, ref cookie);

                    if (cookie.abort != 0)
                    {
                        nbmp.Dispose();
                        nbmp = null;
                    }
                } finally {
                    MuPDFLib.ClosePage(ctx, Handle, PDFPage);
                }

                return(nbmp);
            }
        }