mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-17 05:42:42 +00:00
faster PDF file type determination and loading
This commit is contained in:
@@ -185,7 +185,7 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
ReRenderCurrentPage();
|
||||
}
|
||||
|
||||
public Size GetDesiredControlSizeByFirstPage(string path)
|
||||
public static Size GetDesiredControlSizeByFirstPage(string path)
|
||||
{
|
||||
var tempHandle = new PdfFile(path);
|
||||
|
||||
|
@@ -19,17 +19,16 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
if (File.Exists(path) && Path.GetExtension(path).ToLower() == ".pdf")
|
||||
return true;
|
||||
|
||||
using (var br = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
|
||||
{
|
||||
return Encoding.ASCII.GetString(br.ReadBytes(4)) == "%PDF";
|
||||
}
|
||||
//using (var br = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
|
||||
//{
|
||||
// return Encoding.ASCII.GetString(br.ReadBytes(4)) == "%PDF";
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
_pdfControl = new PdfViewerControl();
|
||||
|
||||
var desiredSize = _pdfControl.GetDesiredControlSizeByFirstPage(path);
|
||||
var desiredSize = PdfViewerControl.GetDesiredControlSizeByFirstPage(path);
|
||||
|
||||
context.SetPreferredSizeFit(desiredSize, 0.8);
|
||||
}
|
||||
|
Reference in New Issue
Block a user