Top priority: Performance in both windows explorer preview and embedded gui preview. I need to cycle through pdf previews as fast as possible.
Second Priority: Ability to hide the entire user interface of pdf preview host program to remove distractions and maximize the size of the pdf viewport when it is embedded in my wrapper GUI.
I tested several viewers and did a benchmark to see how long it took to load the same pdf file in the explorer preview pane. Below are results.
Code: Select all
/*
Average time to preview sample file in windows explorer (10 Samples)
Adobe DC: 1.013s
Adobe XI: 0.361s
Foxit 0.203s
SumatraPDF: 0.192s
*/
Foxit is just as fast, but it does not have ability to fully hide the UI except for in reader mode. Reader mode does not work because it spawns a quick access toolbar that steals focus from the host GUI. Also, their ativex plugin is noticeably slower than adobe XI.
Currently I am using Adobe XI. It allows for a fullscreen embed and is fast enough. However, it crashes a lot and locks windows explorer folders with file preview. I want to move away for stability and security concerns.
Adobe DC is beyond hope.
I did see some stuff about pdfium. It looks interesting, but am not sure if this sort of thing could ever be used as a gui control.
Here it is in use https://www.youtube.com/watch?v=tSW3l0A-r84
So, anyone have a secret way to embed a pdf in gui?
benchmark.ahk
Code: Select all
#NoEnv
#SingleInstance Force
SetBatchLines -1
coordMode,pixel,screen
;pixels to wait for. when they become visible the pdf has loaded
;knownPix := {x:970,y:655,color:"0x000000"} ;adobeDC
;knownPix := {x:968,y:673,color:"0x000000"} ;sumatra
;knownPix := {x:974,y:607,color:"0x000000"} ;foxit
knownPix := {x:727,y:467,color:"0x000000"} ;adobeXI
numSamples := 10
results := 0
loop % numSamples
{
selectInExplorer("Y:\Downloads\test\Start.txt") ;deselect pdf
selectInExplorer("Y:\Downloads\test\A.pdf") ;select the pdf
results += waitForPreviewComplete(knownPix) ;time it
}
msgbox % round(results / numSamples,3) . "s"
waitForPreviewComplete(p)
{
start := a_tickCount
loop
{
PixelGetColor, actualColor, % p.x, % p.y
if(actualColor == p.color)
{
return (a_tickCount - start) / 1000
}
}
}
selectInExplorer(fp)
{
WinGet, currentHandle , id, A
SplitPath, fp , OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
For pExp in ComObjCreate("Shell.Application").Windows
{
try
{
if(OutDir == pExp.Document.Folder.self.path)
{
pExp.Document.SelectItem(fp ,0x1D) ; Select our File
Return
}
}
catch
{
;tooltip fail find
}
}
}