public static int CountPages(IPDFSource source, string password = null) { using (PDFFileStream stream = new PDFFileStream(source)) { ValidatePassword(stream.Document, password); return(MuPDFNativeApi.Native.CountPages(stream.Document)); } }
public static Bitmap ExtractPage(IPDFSource source, int pageNumber, float zoomFactor = 1.0f, string password = null) { int pageNumberIndex = Math.Max(0, pageNumber - 1); using (PDFFileStream stream = new PDFFileStream(source)) { ValidatePassword(stream.Document, password); IntPtr ptr = IntPtr.Zero; try { ptr = MuPDFNativeApi.Native.LoadPage(stream.Document, pageNumberIndex); return(RenderPage(stream.Context, stream.Document, ptr, zoomFactor)); } finally { if (ptr != IntPtr.Zero) { MuPDFNativeApi.Native.FreePage(stream.Document, ptr); } } } }
public static System.Windows.Size[] GetPageBounds(IPDFSource source, ImageRotation rotation = ImageRotation.NONE, string password = null) { using (PDFFileStream stream = new PDFFileStream(source)) { ValidatePassword(stream.Document, password); int pageSize = MuPDFNativeApi.Native.CountPages(stream.Document); return(Enumerable.Range(0, pageSize - 1) .Select(x => { IntPtr ptr = IntPtr.Zero; try { ptr = MuPDFNativeApi.Native.LoadPage(stream.Document, x); MuPDFLibrary.Interop.Rectangle bound = MuPDFNativeApi.Native.BoundPage(stream.Document, ptr); return SizeCallback(rotation)(bound.Width, bound.Height); } finally { if (ptr != IntPtr.Zero) { MuPDFNativeApi.Native.FreePage(stream.Document, ptr); } } }).ToArray()); } }
public static bool NeedsPassword(IPDFSource source) { using (PDFFileStream stream = new PDFFileStream(source)) { return(NeedsPassword(stream.Document)); } }