diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf.cs b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf.cs
deleted file mode 100644
index 3538ecc..0000000
--- a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf.cs
+++ /dev/null
@@ -1,309 +0,0 @@
-// Copyright © 2017 Paddy Xu
-//
-// This file is part of QuickLook program.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-using System;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-using QuickLook.Helpers;
-
-namespace QuickLook.Plugin.PDFViewer
-{
- internal class LibMuPdf
- {
- public static Bitmap RenderPage(IntPtr context, IntPtr document, IntPtr page, double zoomFactor)
- {
- var pageBound = new Rectangle();
-
- var ctm = new Matrix();
- var pix = IntPtr.Zero;
- var dev = IntPtr.Zero;
-
- if (App.Is64Bit)
- NativeMethods.BoundPage_64(document, page, ref pageBound);
- else
- NativeMethods.BoundPage_32(document, page, ref pageBound);
-
- var scale = DpiHelper.GetCurrentScaleFactor();
- var zoomX = zoomFactor * scale.Horizontal;
- var zoomY = zoomFactor * scale.Vertical;
-
- // gets the size of the page and multiplies it with zoom factors
- var width = (int) (pageBound.Width * zoomX);
- var height = (int) (pageBound.Height * zoomY);
-
- // sets the matrix as a scaling matrix (zoomX,0,0,zoomY,0,0)
- ctm.A = (float) zoomX;
- ctm.D = (float) zoomY;
-
- // creates a pixmap the same size as the width and height of the page
- if (App.Is64Bit)
- pix = NativeMethods.NewPixmap_64(context,
- NativeMethods.LookupDeviceColorSpace_64(context, "DeviceRGB"), width, height);
- else
- pix = NativeMethods.NewPixmap_32(context,
- NativeMethods.LookupDeviceColorSpace_32(context, "DeviceRGB"), width, height);
- // sets white color as the background color of the pixmap
- if (App.Is64Bit)
- NativeMethods.ClearPixmap_64(context, pix, 0xFF);
- else
- NativeMethods.ClearPixmap_32(context, pix, 0xFF);
-
- // creates a drawing device
- dev = App.Is64Bit
- ? NativeMethods.NewDrawDevice_64(context, pix)
- : NativeMethods.NewDrawDevice_32(context, pix);
-
- // draws the page on the device created from the pixmap
- if (App.Is64Bit)
- NativeMethods.RunPage_64(document, page, dev, ref ctm, IntPtr.Zero);
- else
- NativeMethods.RunPage_32(document, page, dev, ref ctm, IntPtr.Zero);
-
- if (App.Is64Bit)
- NativeMethods.FreeDevice_64(dev); // frees the resources consumed by the device
- else
- NativeMethods.FreeDevice_32(dev); // frees the resources consumed by the device
- dev = IntPtr.Zero;
-
- // creates a colorful bitmap of the same size of the pixmap
- var bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
- var imageData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, width, height), ImageLockMode.ReadWrite,
- bmp.PixelFormat);
- unsafe
- {
- // converts the pixmap data to Bitmap data
- byte* ptrSrcOrigin;
- if (App.Is64Bit)
- ptrSrcOrigin =
- (byte*) NativeMethods.GetSamples_64(context, pix); // gets the rendered data from the pixmap
- else
- ptrSrcOrigin = (byte*) NativeMethods
- .GetSamples_32(context, pix); // gets the rendered data from the pixmap
- var ptrDestOrigin = (byte*) imageData.Scan0;
-
- Parallel.For(0, height, y =>
- {
- var ptrDest = ptrDestOrigin + imageData.Stride * y;
- var ptrSrc = ptrSrcOrigin + width * 4 * y;
-
- Parallel.For(0, width, x =>
- {
- var pl = ptrDest + 3 * x;
- var sl = ptrSrc + 4 * x;
- //Swap these here instead of in MuPDF because most pdf images will be rgb or cmyk.
- //Since we are going through the pixels one by one anyway swap here to save a conversion from rgb to bgr.
- pl[2] = sl[0]; //b-r
- pl[1] = sl[1]; //g-g
- pl[0] = sl[2]; //r-b
- //sl[3] is the alpha channel, we will skip it here
- });
- });
-
- /*for (var y = 0; y < height; y++)
- {
- var pl = ptrDestOrigin;
- var sl = ptrSrcOrigin;
- for (var x = 0; x < width; x++)
- {
- //S these here instead of in MuPDF because most pdf images will be rgb or cmyk.
- //Since we are going through the pixels one by one anyway swap here to save a conversion from rgb to bgr.
- pl[2] = sl[0]; //b-r
- pl[1] = sl[1]; //g-g
- pl[0] = sl[2]; //r-b
- //sl[3] is the alpha channel, we will skip it here
- pl += 3;
- sl += 4;
- }
- ptrDestOrigin += imageData.Stride;
- ptrSrcOrigin += width * 4;
- }*/
- }
- bmp.UnlockBits(imageData);
- if (App.Is64Bit)
- NativeMethods.DropPixmap_64(context, pix);
- else
- NativeMethods.DropPixmap_32(context, pix);
-
- bmp.SetResolution(scale.Horizontal * DpiHelper.DefaultDpi, scale.Vertical * DpiHelper.DefaultDpi);
-
- return bmp;
- }
-
- public struct Rectangle
- {
- public float Left, Top, Right, Bottom;
-
- public float Width => Right - Left;
- public float Height => Bottom - Top;
- }
-
- public struct Matrix
- {
- public float A, B, C, D, E, F;
-
- public Matrix(float a, float b, float c, float d, float e, float f)
- {
- A = a;
- B = b;
- C = c;
- D = d;
- E = e;
- F = f;
- }
- }
-
- internal class NativeMethods
- {
- private const uint FzStoreDefault = 256 << 20;
- private const string MuPdfVersion = "1.6";
-
- public static IntPtr NewContext()
- {
- return App.Is64Bit
- ? NewContext_64(IntPtr.Zero, IntPtr.Zero, FzStoreDefault, MuPdfVersion)
- : NewContext_32(IntPtr.Zero, IntPtr.Zero, FzStoreDefault, MuPdfVersion);
- }
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_new_context_imp",
- CallingConvention = CallingConvention.Cdecl)]
- private static extern IntPtr NewContext_32(IntPtr alloc, IntPtr locks, uint maxStore, string version);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_free_context", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr FreeContext_32(IntPtr ctx);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_open_file_w", CharSet = CharSet.Unicode,
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr OpenFile_32(IntPtr ctx, string fileName);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "pdf_open_document_with_stream",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr OpenDocumentStream_32(IntPtr ctx, IntPtr stm);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_close", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr CloseStream_32(IntPtr stm);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "pdf_close_document",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr CloseDocument_32(IntPtr doc);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "pdf_count_pages", CallingConvention = CallingConvention.Cdecl)]
- public static extern int CountPages_32(IntPtr doc);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "pdf_bound_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern void BoundPage_32(IntPtr doc, IntPtr page, ref Rectangle bound);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_clear_pixmap_with_value",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern void ClearPixmap_32(IntPtr ctx, IntPtr pix, int byteValue);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_lookup_device_colorspace",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr LookupDeviceColorSpace_32(IntPtr ctx, string colorspace);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_free_device", CallingConvention = CallingConvention.Cdecl)]
- public static extern void FreeDevice_32(IntPtr dev);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "pdf_free_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern void FreePage_32(IntPtr doc, IntPtr page);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "pdf_load_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr LoadPage_32(IntPtr doc, int pageNumber);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_new_draw_device",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr NewDrawDevice_32(IntPtr ctx, IntPtr pix);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_new_pixmap", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr NewPixmap_32(IntPtr ctx, IntPtr colorspace, int width, int height);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "pdf_run_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern void RunPage_32(IntPtr doc, IntPtr page, IntPtr dev, ref Matrix transform,
- IntPtr cookie);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_drop_pixmap", CallingConvention = CallingConvention.Cdecl)]
- public static extern void DropPixmap_32(IntPtr ctx, IntPtr pix);
-
- [DllImport("LibMuPdf32.dll", EntryPoint = "fz_pixmap_samples", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr GetSamples_32(IntPtr ctx, IntPtr pix);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_new_context_imp",
- CallingConvention = CallingConvention.Cdecl)]
- private static extern IntPtr NewContext_64(IntPtr alloc, IntPtr locks, uint maxStore, string version);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_free_context", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr FreeContext_64(IntPtr ctx);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_open_file_w", CharSet = CharSet.Unicode,
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr OpenFile_64(IntPtr ctx, string fileName);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "pdf_open_document_with_stream",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr OpenDocumentStream_64(IntPtr ctx, IntPtr stm);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_close", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr CloseStream_64(IntPtr stm);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "pdf_close_document",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr CloseDocument_64(IntPtr doc);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "pdf_count_pages", CallingConvention = CallingConvention.Cdecl)]
- public static extern int CountPages_64(IntPtr doc);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "pdf_bound_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern void BoundPage_64(IntPtr doc, IntPtr page, ref Rectangle bound);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_clear_pixmap_with_value",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern void ClearPixmap_64(IntPtr ctx, IntPtr pix, int byteValue);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_lookup_device_colorspace",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr LookupDeviceColorSpace_64(IntPtr ctx, string colorspace);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_free_device", CallingConvention = CallingConvention.Cdecl)]
- public static extern void FreeDevice_64(IntPtr dev);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "pdf_free_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern void FreePage_64(IntPtr doc, IntPtr page);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "pdf_load_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr LoadPage_64(IntPtr doc, int pageNumber);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_new_draw_device",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr NewDrawDevice_64(IntPtr ctx, IntPtr pix);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_new_pixmap", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr NewPixmap_64(IntPtr ctx, IntPtr colorspace, int width, int height);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "pdf_run_page", CallingConvention = CallingConvention.Cdecl)]
- public static extern void RunPage_64(IntPtr doc, IntPtr page, IntPtr dev, ref Matrix transform,
- IntPtr cookie);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_drop_pixmap", CallingConvention = CallingConvention.Cdecl)]
- public static extern void DropPixmap_64(IntPtr ctx, IntPtr pix);
-
- [DllImport("LibMuPdf64.dll", EntryPoint = "fz_pixmap_samples",
- CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr GetSamples_64(IntPtr ctx, IntPtr pix);
- }
- }
-}
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf32.dll b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf32.dll
deleted file mode 100644
index 375d73f..0000000
Binary files a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf32.dll and /dev/null differ
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf64.dll b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf64.dll
deleted file mode 100644
index 85900b5..0000000
Binary files a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf64.dll and /dev/null differ
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.Wpf.dll b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.Wpf.dll
new file mode 100644
index 0000000..9e92d16
Binary files /dev/null and b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.Wpf.dll differ
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.Wpf.xml b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.Wpf.xml
new file mode 100644
index 0000000..6d7dfe0
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.Wpf.xml
@@ -0,0 +1,27 @@
+
+
+
+ PDFiumSharp.Wpf
+
+
+
+
+ Renders the page to a
+
+ The page which is to be rendered.
+ The bitmap to which the page is to be rendered.
+ The destination rectangle in .
+ The orientation at which the page is to be rendered.
+ The flags specifying how the page is to be rendered.
+
+
+
+ Renders the page to a
+
+ The page which is to be rendered.
+ The bitmap to which the page is to be rendered.
+ The orientation at which the page is to be rendered.
+ The flags specifying how the page is to be rendered.
+
+
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.dll b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.dll
new file mode 100644
index 0000000..96bcd8a
Binary files /dev/null and b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.dll differ
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.xml b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.xml
new file mode 100644
index 0000000..8e91bf4
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/PDFiumSharp.xml
@@ -0,0 +1,1521 @@
+
+
+
+ PDFiumSharp
+
+
+
+
+ PDF Action Types
+
+
+
+
+ Unsupported action type.
+
+
+
+
+ Go to a destination within current document.
+
+
+
+
+ Go to a destination within another document.
+
+
+
+
+ URI, including web pages and other Internet resources.
+
+
+
+
+ Launch an application or open a file.
+
+
+
+
+ Gray scale bitmap, one byte per pixel.
+
+
+
+
+ 3 bytes per pixel, byte order: blue, green, red.
+
+
+
+
+ 4 bytes per pixel, byte order: blue, green, red, unused.
+
+
+
+
+ 4 bytes per pixel, byte order: blue, green, red, alpha.
+
+
+
+
+ Flags specifying document permissions.
+
+
+
+ PDF Reference: Table 22
+
+
+
+ For of 2: Print the document.
+ For of 3 or greater: Print the document
+ (possibly not at the highest quality level, depending on whether is also set).
+
+
+
+
+ Modify the contents of the document by operations other than those controlled by ,
+ and .
+
+
+
+
+ For of 2: Copy or otherwise extract text and graphics from the document,
+ including extracting text and graphics (in support of accessibility to users with disabilities or for other purposes).
+ For of 3 or greater: Copy or otherwise extract text and graphics from
+ the document by operations other than that controlled by .
+
+
+
+
+ Add or modify text annotations, fill in interactive form fields, and, if is also set,
+ create or modify interactive form fields (including signature fields).
+
+
+
+
+ For of 3 or greater: Fill in existing interactive form fields
+ (including signature fields), even if is not set.
+
+
+
+
+ For of 3 or greater: Extract text and graphics
+ (in support of accessibility to users with disabilities or for other purposes).
+
+
+
+
+ For of 3 or greater: Assemble the document
+ (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if is not set.
+
+
+
+
+ For of 3 or greater: Print the document to a representation
+ from which a faithful digital copy of the PDF content could be generated. When is not set
+ (and is set), printing is limited to a low-level representation of the appearance, possibly of degraded quality.
+
+
+
+
+ Flatten for normal display.
+
+
+
+
+ Flatten for print.
+
+
+
+
+ Flatten operation failed.
+
+
+
+
+ Flatten operation succeed.
+
+
+
+
+ Nothing to be flattened.
+
+
+
+
+ Unknown page mode.
+
+
+
+
+ Document outline, and thumbnails hidden.
+
+
+
+
+ Document outline visible.
+
+
+
+
+ Thumbnail images visible.
+
+
+
+
+ Full-screen mode, no menu bar, window controls, or other decorations visible.
+
+
+
+
+ Optional content group panel visible.
+
+
+
+
+ Attachments panel visible.
+
+
+
+
+
+
+
+ Gets the pages in the current .
+
+
+
+
+ Gets the PDF file version. File version: 14 for 1.4, 15 for 1.5, ...
+
+
+
+
+ Gets the revision of the security handler.
+
+ PDF Reference: Table 21
+
+
+
+ Creates a new .
+ must be called in order to free unmanaged resources.
+
+
+
+
+ Loads a from the file system.
+ must be called in order to free unmanaged resources.
+
+ Filepath of the PDF file to load.
+
+
+
+ Loads a from memory.
+ must be called in order to free unmanaged resources.
+
+ Byte array containing the bytes of the PDF document to load.
+ The index of the first byte to be copied from .
+ The number of bytes to copy from or a negative value to copy all bytes.
+
+
+
+ Loads a from '' bytes read from a .
+ must be called in order to free unmanaged resources.
+
+
+ The number of bytes to read from the .
+ If the value is equal to or smaller than 0, the stream is read to the end.
+
+
+
+
+ Closes the and frees unmanaged resources.
+
+
+
+
+ Saves the to a .
+
+
+ The new PDF file version of the saved file.
+ 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored.
+
+
+
+
+ Saves the to the file system.
+
+
+ The new PDF file version of the saved file.
+ 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored.
+
+
+
+
+ Static class containing the native (imported) PDFium functions.
+ In case of missing documentation, refer to the PDFium header files.
+
+
+
+
+ Gets a value indicating whether the PDFium library is available.
+ false is returned if the native libraries could not be
+ loaded for some reason.
+
+
+
+
+ Loads a PDF document from memory.
+
+ The data to load the document from.
+ The index of the first byte to be copied from .
+ The number of bytes to copy from or a negative value to copy all bytes.
+
+
+
+ Loads a PDF document from '' bytes read from a stream.
+
+
+ The number of bytes to read from the .
+ If the value is equal to or smaller than 0, the stream is read to the end.
+
+
+
+
+ Get the named destination by index.
+
+ Handle to a document.
+ The index of a named destination.
+
+ The destination handle and name for a given index, or (, null)
+ if there is no named destination corresponding to .
+
+
+
+
+
+
+ Get the title of .
+
+ Handle to the bookmark.
+ The title of the bookmark.
+
+
+
+ Gets the file path of a of type or .
+
+ Handle to the action. Must be of type or .
+ The file path of .
+
+
+
+
+ Gets URI path of a of type .
+
+ Handle to the document.
+ Handle to the action. Must be of type .
+ The URI path of .
+
+
+
+
+ Enumerates all the link annotations in .
+
+ Handle to the page.
+ All the link annotations in .
+
+
+
+ Get meta-data content from .
+
+ Handle to the document.
+
+ The tag to retrieve. The tag can be one of:
+ Title, Author, Subject, Keywords, Creator, Producer,
+ CreationDate, or ModDate.
+
+ The meta-data.
+
+ For detailed explanations of these tags and their respective
+ values, please refer to PDF Reference 1.6, section 10.2.1,
+ 'Document Information Dictionary'.
+
+ PDF Reference
+
+
+
+
+ Get meta-data content from .
+
+ Handle to the document.
+ The tag to retrieve.
+ The meta-data.
+
+ For detailed explanations of these tags and their respective
+ values, please refer to PDF Reference 1.6, section 10.2.1,
+ 'Document Information Dictionary'.
+
+ PDF Reference
+
+
+
+
+ Insert into .
+
+ Handle to a page.
+ Handle to a page object. The will be automatically freed.
+
+
+
+ Load an image from a JPEG image file and then set it into .
+
+ All loaded pages, may be null.
+ Handle to an image object.
+ Stream which provides access to an JPEG image.
+ The number of bytes to read from or 0 to read to the end.
+
+ If true, this function loads the JPEG image inline, so the image
+ content is copied to the file. This allows
+ to be closed after this function returns.
+
+ true on success.
+
+ The image object might already have an associated image, which is shared and
+ cached by the loaded pages. In that case, we need to clear the cached image
+ for all the loaded pages. Pass to this API
+ to clear the image cache. If the image is not previously shared, null is a
+ valid value.
+
+
+
+
+ Set to .
+
+ All loaded pages, may be null.
+ Handle to an image object.
+ Handle of the bitmap.
+ true on success.
+
+
+
+ Returns a font object loaded from a stream of data. The font is loaded
+ into the document. The caller does not need to free the returned object.
+
+ Handle to the document.
+ A value specifying if the font is a CID font or not.
+ The data, which will be copied by the font object.
+ The index of the first byte to be copied from .
+ The number of bytes to copy from or a negative value to copy all bytes.
+ Returns NULL on failure.
+
+
+
+ Imports pages from to
+
+ Zero-based index of where the imported pages should be inserted in the destination document.
+ Zero-based indices of the pages to import in the source document
+
+
+
+ Saves a PDF document to a stream.
+
+
+ The new PDF file version of the saved file.
+ 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored.
+
+
+
+
+
+
+ Get the alternative text for a given element.
+
+ Handle to the struct element.
+ The alternative text for .
+
+
+ Initialize the PDFium library
+ Convenience function to call for
+ backwards comatibility purposes.
+
+
+
+ Initialize the PDFium library
+ You have to call this function before you can call any PDF
+ processing functions.
+
+
+
+ Release all resources allocated by the PDFium library.
+ You can call this function to release all memory blocks allocated by
+ the library.
+ After this function is called, you should not call any PDF
+ processing functions.
+
+
+
+ Open and load a PDF document.Path to the PDF file (including extension).
+ A string used as the password for the PDF file.
+ If no password is needed, or null can be used.
+ A handle to the loaded document, or NULL on failure.
+ Loaded document can be closed by .
+ If this function fails, you can use to retrieve
+ the reason why it failed.
+
+
+
+
+ Open and load a PDF document from memory.Pointer to a buffer containing the PDF document.Number of bytes in the PDF document.
+ A string used as the password for the PDF file.
+ If no password is needed, or null can be used.
+ A handle to the loaded document, or NULL on failure.
+
+ The memory buffer must remain valid when the document is open.
+ The loaded document can be closed by .
+ If this function fails, you can use to retrieve
+ the reason why it failed.
+
+
+ If PDFium is built with the XFA module, the application should call
+ function after the PDF document loaded to support XFA
+ fields defined in the fpdfformfill.h file.
+
+
+
+
+
+ Load PDF document from a custom access descriptor.A structure for accessing the file.Optional password for decrypting the PDF file.A handle to the loaded document, or NULL on failure.
+
+ The application must keep the file resources valid until the PDF
+ document is closed.
+ The loaded document can be closed with FPDF_CloseDocument.
+
+
+ If PDFium is built with the XFA module, the application should call
+ function after the PDF document loaded to support XFA
+ fields defined in the fpdfformfill.h file.
+
+
+
+
+
+ Get the file version of the given PDF document.Handle to a document.The PDF file version. File version: 14 for 1.4, 15 for 1.5, ...True if succeeds, false otherwise.
+ If the document was created by ,
+ then this function will always fail.
+
+
+
+
+ Get last error code when a function fails.
+ If the previous SDK call succeeded, the return value of this
+ function is not defined.
+
+
+
+
+
+
+
+
+
+
+
+ Get total number of pages in the document.Handle to document.Total number of pages in the document.
+
+
+
+
+ Load a page inside the document.Handle to document.Zero-based index of the page.A handle to the loaded page, or NULL if page load fails.The loaded page can be closed using FPDF_ClosePage.
+
+
+
+
+ Get page width.Handle to the page.
+ Page width (excluding non-displayable area) measured in points.
+ One point is 1/72 inch (around 0.3528 mm).
+
+
+
+
+ Get page height.Handle to the page.
+ Page height (excluding non-displayable area) measured in points.
+ One point is 1/72 inch (around 0.3528 mm)
+
+
+
+
+ Get the size of the page at the given index.Handle to document.Zero-based index of the page.Pointer to a double to receive the page width (in points).Pointer to a double to receive the page height (in points).
+
+
+
+ Render contents of a page to a device independent bitmap.
+ Handle to the device independent bitmap (as the
+ output buffer). The bitmap handle can be created
+ by .
+ Handle to the page.Left pixel position of the display area in bitmap coordinates.Top pixel position of the display area in bitmap coordinates.Horizontal size (in pixels) for displaying the page.Vertical size (in pixels) for displaying the page.Page orientation.
+ for normal display, or combination of the Page
+ Rendering flags defined above. With the
+ flag, it renders all annotations that do not require
+ user-interaction, which are all annotations except
+ widget and popup annotations.
+
+
+
+
+ Render contents of a page to a device independent bitmap.
+ Handle to the device independent bitmap (as the
+ output buffer). The bitmap handle can be created
+ by .
+ Handle to the page.The transform matrix.The rect to clip to.
+ for normal display, or combination of the Page
+ Rendering flags defined above. With the
+ flag, it renders all annotations that do not require
+ user-interaction, which are all annotations except
+ widget and popup annotations.
+
+
+
+ Close a loaded PDF page.Handle to the loaded page.
+
+
+
+ Close a loaded PDF document.Handle to the loaded document.
+
+
+
+
+
+
+
+
+
+
+
+ Create a device independent bitmap (FXDIB).The number of pixels in width for the bitmap. Must be greater than 0. The number of pixels in height for the bitmap. Must be greater than 0.A value indicating whether the alpha channel is used.The bitmap handle, or if parameter error or out of memory.
+ The bitmap always uses 4 bytes per pixel. The first byte is always
+ double word aligned.
+
+ The byte order is BGRx (the last byte unused if no alpha channel) or BGRA.
+
+ The pixels in a horizontal line are stored side by side, with the
+ left most pixel stored first (with lower memory address).
+ Each line uses width * 4 bytes.
+
+ Lines are stored one after another, with the top most line stored
+ first. There is no gap between adjacent lines.
+
+ This function allocates enough memory for holding all pixels in the
+ bitmap, but it doesn't initialize the buffer. Applications can use
+ to fill the bitmap using any color.
+
+
+
+
+ Create a device independent bitmap (FXDIB).The number of pixels in width for the bitmap. Must be greater than 0. The number of pixels in height for the bitmap. Must be greater than 0.
+ A pointer to the first byte of the first line if
+ using an external buffer. If this parameter is
+ then the a new buffer will be created.
+ Number of bytes for each scan line, for external buffer only.The bitmap handle, or if parameter error or out of memory.
+ Similar to function, but allows for more formats
+ and an external buffer is supported. The bitmap created by this
+ function can be used in any place that a handle is required.
+
+ If an external buffer is used, then the application should destroy
+ the buffer by itself. function will not destroy
+ the buffer.
+
+
+
+
+ Fill a rectangle in a bitmap.The handle to the bitmap.The left position. Starting from 0 at the left-most pixel.The top position. Starting from 0 at the top-most line.Width in pixels to be filled.Height in pixels to be filled.
+ This function sets the color and (optionally) alpha value in the
+ specified region of the bitmap.
+
+ NOTE: If the alpha channel is used, this function does NOT
+ composite the background with the source color, instead the
+ background will be replaced by the source color and the alpha.
+
+ If the alpha channel is not used, the alpha parameter is ignored.
+
+
+
+
+
+ Get data buffer of a bitmap.Handle to the bitmap as returned by .The pointer to the first byte of the bitmap buffer.
+ The stride may be more than width * number of bytes per pixel
+
+ Applications can use this function to get the bitmap buffer pointer,
+ then manipulate any color and/or alpha values for any pixels in the bitmap.
+
+ The data is in BGRA format. Where the A maybe unused if alpha was
+ not specified.
+
+
+
+
+ Get width of a bitmap.Handle to the bitmap as returned by .The width of the bitmap in pixels.
+
+
+
+ Get height of a bitmap.Handle to the bitmap as returned by .The height of the bitmap in pixels.
+
+
+
+ Get number of bytes for each line in the bitmap buffer.Handle to the bitmap as returned by .The number of bytes for each line in the bitmap buffer.The stride may be more than width * number of bytes per pixel.
+
+
+
+ Destroy a bitmap and release all related buffers.Handle to the bitmap as returned by .
+ This function will not destroy any external buffers provided when
+ the bitmap was created.
+
+
+
+
+ Whether the PDF document prefers to be scaled or not.Handle to the loaded document.
+
+
+
+ Returns the number of copies to be printed.Handle to the loaded document.The number of copies to be printed.
+
+
+
+ Page numbers to initialize print dialog box when file is printed.Handle to the loaded document.The print page range to be used for printing.
+
+
+ Returns the paper handling option to be used when printing from the print dialog.Handle to the loaded document.The paper handling option to be used when printing.
+
+
+
+ Gets the contents for a viewer ref, with a given key. The value must be of type "name".Handle to the loaded document.Name of the key in the viewer pref dictionary.A string to write the contents of the key to.Length of the buffer.
+ The number of bytes in the contents, including the NULL terminator.
+ Thus if the return value is 0, then that indicates an error, such
+ as when |document| is invalid or |buffer| is NULL. If |length| is
+ less than the returned length, or |buffer| is NULL, |buffer| will
+ not be modified.
+
+
+
+ Get the count of named destinations in the PDF document.Handle to the loaded document.The count of named destinations.
+
+
+
+
+ Get a the destination handle for the given name.Handle to the loaded document.The name of a destination.The handle to the destination.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create a new PDF document.Returns a handle to a new document, or NULL on failure.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A bitmap to which a can be rendered.
+
+
+
+
+ Creates a new . Unmanaged memory is allocated which must
+ be freed by calling .
+
+ The width of the new bitmap.
+ The height of the new bitmap.
+ A value indicating wheter the new bitmap has an alpha channel.
+
+ A bitmap created with this overload always uses 4 bytes per pixel.
+ Depending on the is then either
+ or .
+
+
+
+
+ Creates a new using memory allocated by the caller.
+ The caller is responsible for freeing the memory and that the adress stays
+ valid during the lifetime of the returned . To free
+ unmanaged resources, must be called.
+
+ The width of the new bitmap.
+ The height of the new bitmap.
+ The format of the new bitmap.
+ The adress of the memory block which holds the pixel values.
+ The number of bytes per image row.
+
+
+
+ Fills a rectangle in the with .
+ The pixel values in the rectangle are replaced and not blended.
+
+
+
+
+ Fills the whole with .
+ The pixel values in the rectangle are replaced and not blended.
+
+
+
+
+
+ Saves the in the BMP file format.
+
+
+
+
+ Saves the in the BMP file format.
+
+
+
+
+ Exposes the underlying image data directly as read-only stream in the
+ BMP file format.
+
+
+
+
+ Gets the page width (excluding non-displayable area) measured in points.
+ One point is 1/72 inch(around 0.3528 mm).
+
+
+
+
+ Gets the page height (excluding non-displayable area) measured in points.
+ One point is 1/72 inch(around 0.3528 mm).
+
+
+
+
+ Gets the page width and height (excluding non-displayable area) measured in points.
+ One point is 1/72 inch(around 0.3528 mm).
+
+
+
+
+ Gets the page orientation.
+
+
+
+
+ Gets the zero-based index of the page in the
+
+
+
+
+ Gets the which contains the page.
+
+
+
+
+ Renders the page to a
+
+ The bitmap to which the page is to be rendered.
+ The destination rectangle in .
+ The orientation at which the page is to be rendered.
+ The flags specifying how the page is to be rendered.
+
+
+
+ Renders the page to a
+
+ The bitmap to which the page is to be rendered.
+ The orientation at which the page is to be rendered.
+ The flags specifying how the page is to be rendered.
+
+
+
+ Gets the number of pages in the .
+
+
+
+
+ Gets the at the zero-based in the .
+
+
+
+
+ Imports pages of into the current .
+
+
+
+
+
+ Imports pages of into the current .
+
+
+
+
+
+ Inserts a new page at .
+
+
+
+
+ Adds a new page to the end of the document.
+
+
+
+
+ Removes the page at .
+
+
+
+
+ Removes the from the document.
+
+
+
+
+ Set if annotations are to be rendered.
+
+
+
+
+ Set if using text rendering optimized for LCD display.
+
+
+
+
+ Don't use the native text output available on some platforms
+
+
+
+
+ Grayscale output.
+
+
+
+
+ Set if you want to get some debug info.
+
+
+
+
+ Set if you don't want to catch exceptions.
+
+
+
+
+ Limit image cache size.
+
+
+
+
+ Always use halftone for image stretching.
+
+
+
+
+ Render for printing.
+
+
+
+
+ Set to disable anti-aliasing on text.
+
+
+
+
+ Set to disable anti-aliasing on images.
+
+
+
+
+ Set to disable anti-aliasing on paths.
+
+
+
+
+ Set whether to render in a reverse Byte order, this flag is only used when rendering to a bitmap.
+
+
+
+
+ If not set, it will not match case by default.
+
+
+
+
+ If not set, it will not match the whole word by default.
+
+
+
+
+ No error.
+
+
+
+
+ Unknown error.
+
+
+
+
+ File not found or could not be opened.
+
+
+
+
+ File not in PDF format or corrupted.
+
+
+
+
+ Password required or incorrect password.
+
+
+
+
+ Unsupported security scheme.
+
+
+
+
+ Page not found or content error.
+
+
+
+
+ Load XFA error.
+
+
+
+
+ Layout XFA error.
+
+
+
+ Handle to a FPDF_ACTION
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_BITMAP
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_BOOKMARK
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_CLIPPATH
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_DEST
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_DOCUMENT
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_FONT
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_LINK
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_PAGE
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_PAGELINK
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_PAGEOBJECT
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_PAGERANGE
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_RECORDER
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_SCHHANDLE
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_STRUCTELEMENT
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_STRUCTTREE
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_TEXTPAGE
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_STRINGHANDLE
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+ Handle to a FPDF_WIDGET
+
+
+ Gets a value indicating whether the handle is null.
+
+
+ Gets a handle representing null.
+
+
+
+ Handle which can be used with the native functions.
+
+
+
+
+ Gets a value indicating whether was already
+ called on this instance.
+
+
+
+
+ Implementors should clean up here. This method is guaranteed to only be called once.
+
+
+
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/System.ValueTuple.dll b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/System.ValueTuple.dll
new file mode 100644
index 0000000..b7cb4f7
Binary files /dev/null and b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PDFiumSharp/System.ValueTuple.dll differ
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PageIdToImageConverter.cs b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PageIdToImageConverter.cs
deleted file mode 100644
index 41409ae..0000000
--- a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PageIdToImageConverter.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright © 2017 Paddy Xu
-//
-// This file is part of QuickLook program.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-using System;
-using System.Globalization;
-using System.Windows.Data;
-using QuickLook.ExtensionMethods;
-
-namespace QuickLook.Plugin.PDFViewer
-{
- public sealed class PageIdToImageConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values.Length < 2)
- throw new Exception("PageIdToImageConverter");
-
- var zoom = 0.3f;
- if (parameter != null)
- float.TryParse((string) parameter, out zoom);
-
- var handle = values[0] as PdfFile;
- if (handle == null) return null;
-
- var pageId = (int) values[1];
- if (pageId < 0) return null;
-
- var bitmap = handle.GetPage(pageId, zoom);
- var bs = bitmap.ToBitmapSource();
- bitmap.Dispose();
-
- GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized);
-
- return bs;
- }
-
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfFile.cs b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfFile.cs
deleted file mode 100644
index 910e22b..0000000
--- a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfFile.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright © 2017 Paddy Xu
-//
-// This file is part of QuickLook program.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-using System;
-using System.Drawing;
-using Size = System.Windows.Size;
-
-namespace QuickLook.Plugin.PDFViewer
-{
- public class PdfFile : IDisposable
- {
- private readonly IntPtr _ctx;
- private readonly IntPtr _doc;
- private readonly IntPtr _stm;
-
- public PdfFile(string path)
- {
- if (App.Is64Bit)
- {
- _ctx = LibMuPdf.NativeMethods.NewContext();
- _stm = LibMuPdf.NativeMethods.OpenFile_64(_ctx, path);
- _doc = LibMuPdf.NativeMethods.OpenDocumentStream_64(_ctx, _stm);
- TotalPages = LibMuPdf.NativeMethods.CountPages_64(_doc);
- }
- else
- {
- _ctx = LibMuPdf.NativeMethods.NewContext();
- _stm = LibMuPdf.NativeMethods.OpenFile_32(_ctx, path);
- _doc = LibMuPdf.NativeMethods.OpenDocumentStream_32(_ctx, _stm);
- TotalPages = LibMuPdf.NativeMethods.CountPages_32(_doc);
- }
- }
-
- public int TotalPages { get; }
-
- public void Dispose()
- {
- GC.SuppressFinalize(this);
-
- if (App.Is64Bit)
- {
- LibMuPdf.NativeMethods.CloseDocument_64(_doc);
- LibMuPdf.NativeMethods.CloseStream_64(_stm);
- LibMuPdf.NativeMethods.FreeContext_64(_ctx);
- }
- else
- {
- LibMuPdf.NativeMethods.CloseDocument_32(_doc);
- LibMuPdf.NativeMethods.CloseStream_32(_stm);
- LibMuPdf.NativeMethods.FreeContext_32(_ctx);
- }
- }
-
- ~PdfFile()
- {
- Dispose();
- }
-
- public bool IsLastPage(int pageId)
- {
- return pageId >= TotalPages;
- }
-
- public Size GetPageSize(int pageId, double zoomFactor)
- {
- if (pageId < 0 || pageId >= TotalPages)
- throw new OverflowException(
- $"Page id {pageId} should greater or equal than 0 and less than total page count {TotalPages}.");
-
- var p = App.Is64Bit
- ? LibMuPdf.NativeMethods.LoadPage_64(_doc, pageId)
- : LibMuPdf.NativeMethods.LoadPage_32(_doc, pageId);
-
- var realSize = new LibMuPdf.Rectangle();
- if (App.Is64Bit)
- LibMuPdf.NativeMethods.BoundPage_64(_doc, p, ref realSize);
- else
- LibMuPdf.NativeMethods.BoundPage_32(_doc, p, ref realSize);
-
- var size = new Size
- {
- Width = realSize.Right * zoomFactor,
- Height = realSize.Bottom * zoomFactor
- };
-
- if (App.Is64Bit)
- LibMuPdf.NativeMethods.FreePage_64(_doc, p);
- else
- LibMuPdf.NativeMethods.FreePage_32(_doc, p);
-
- return size;
- }
-
- public Bitmap GetPage(int pageId, double zoomFactor)
- {
- if (pageId < 0 || pageId >= TotalPages)
- throw new OverflowException(
- $"Page id {pageId} should greater or equal than 0 and less than total page count {TotalPages}.");
-
- var p = App.Is64Bit
- ? LibMuPdf.NativeMethods.LoadPage_64(_doc, pageId)
- : LibMuPdf.NativeMethods.LoadPage_32(_doc, pageId);
-
- var bmp = LibMuPdf.RenderPage(_ctx, _doc, p, zoomFactor);
-
- if (App.Is64Bit)
- LibMuPdf.NativeMethods.FreePage_64(_doc, p);
- else
- LibMuPdf.NativeMethods.FreePage_32(_doc, p);
-
- return bmp;
- }
- }
-}
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfPageExtension.cs b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfPageExtension.cs
new file mode 100644
index 0000000..6fb715c
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfPageExtension.cs
@@ -0,0 +1,54 @@
+// Copyright © 2017 Paddy Xu
+//
+// This file is part of QuickLook program.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+using System;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using PDFiumSharp;
+using QuickLook.Helpers;
+
+namespace QuickLook.Plugin.PDFViewer
+{
+ internal static class PdfPageExtension
+ {
+ public static BitmapSource RenderThumbnail(this PdfPage page)
+ {
+ var factorX = 130d / page.Width;
+ var factorY = 210d / page.Height;
+
+ return page.Render(Math.Min(factorX, factorY), false);
+ }
+
+ public static BitmapSource Render(this PdfPage page, double factor, bool fixDpi = true)
+ {
+ var scale = DpiHelper.GetCurrentScaleFactor();
+ var dpiX = fixDpi ? scale.Horizontal * DpiHelper.DefaultDpi : 96;
+ var dpiY = fixDpi ? scale.Vertical * DpiHelper.DefaultDpi : 96;
+
+ var realWidth = (int) Math.Ceiling(page.Width * (dpiX / 72) * factor);
+ var realHeight = (int) Math.Ceiling(page.Height * (dpiY / 72) * factor);
+
+ var bitmap = new WriteableBitmap(realWidth, realHeight, dpiX, dpiY, PixelFormats.Bgr24, null);
+ page.Render(bitmap,
+ flags: RenderingFlags.LimitImageCache | RenderingFlags.Annotations | RenderingFlags.DontCatch |
+ RenderingFlags.LcdText);
+
+ bitmap.Freeze();
+ return bitmap;
+ }
+ }
+}
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml
index d106fa9..c7cf7bd 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml
+++ b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml
@@ -12,7 +12,6 @@
d:DesignWidth="720.29">
-
@@ -23,12 +22,12 @@
-
@@ -46,14 +45,7 @@
-
-
-
-
-
-
-
-
+