コード例 #1
0
ファイル: MuPDF.cs プロジェクト: droideveloper/GalleonCSharp
 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));
     }
 }
コード例 #2
0
ファイル: MuPDF.cs プロジェクト: droideveloper/GalleonCSharp
        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);
                    }
                }
            }
        }
コード例 #3
0
ファイル: MuPDF.cs プロジェクト: droideveloper/GalleonCSharp
 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());
     }
 }
コード例 #4
0
ファイル: MuPDF.cs プロジェクト: droideveloper/GalleonCSharp
 public static bool NeedsPassword(IPDFSource source)
 {
     using (PDFFileStream stream = new PDFFileStream(source)) {
         return(NeedsPassword(stream.Document));
     }
 }