mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 02:09:05 +00:00
let pdfviewer accepts streams
This commit is contained in:
@@ -249,6 +249,21 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
listThumbnails.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public void LoadPdf(MemoryStream stream)
|
||||
{
|
||||
_pdfStream = new MemoryStream();
|
||||
stream.WriteTo(_pdfStream);
|
||||
_pdfStream.Position = 0;
|
||||
|
||||
_pdfHandle = PdfDocument.Load(_pdfStream);
|
||||
_pdfLoaded = true;
|
||||
|
||||
BeginLoadThumbnails(stream);
|
||||
|
||||
if (_pdfHandle.PageCount < 2)
|
||||
listThumbnails.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void BeginLoadThumbnails(string path, string password = null)
|
||||
{
|
||||
new Task(() =>
|
||||
@@ -270,6 +285,28 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private void BeginLoadThumbnails(MemoryStream stream, string password = null)
|
||||
{
|
||||
var localStream = new MemoryStream();
|
||||
stream.WriteTo(localStream);
|
||||
localStream.Position = 0;
|
||||
|
||||
new Task(() =>
|
||||
{
|
||||
using (var handle = PdfDocument.Load(localStream, password))
|
||||
{
|
||||
for (var p = 0; p < handle.PageCount; p++)
|
||||
{
|
||||
var bs = handle.RenderThumbnail(p);
|
||||
|
||||
Dispatcher.BeginInvoke(new Action(() => PageThumbnails.Add(bs)));
|
||||
}
|
||||
|
||||
handle.Dispose();
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
Reference in New Issue
Block a user