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