Displaying PDF in eclipse via ActiveX control hangs randomly [message #442510] |
Mon, 06 September 2004 14:39 |
Eclipse User |
|
|
|
Originally posted by: moritz.thomas.empolis.com
Hi,
I'm trying to embed the Acrobat ActiveX control into eclipse. My code is
very much based on the example in:
http://www-106.ibm.com/developerworks/opensource/library/os- activex/
In general this works. The first pdf file (actually it's all single pages)
displays in about 0.5 seconds. Howeveer for roughly 70% (number differs
depending on phase of moon) of the subsequent page views, the display takes
about 10 seconds.
Often it helps to maximize and then minimize the view - the next page
displays fast again.
For reference I'm posting the key pieces of code below.
Thanks in advance
moritz
public boolean loadFile(String file)
{
long time = System.currentTimeMillis();
int[] rgdispid = automation.getIDsOfNames(new String[]{"LoadFile"});
int dispIdMember = rgdispid[0];
Variant[] rgvarg = new Variant[1];
rgvarg[0] = new Variant(file);
Variant result = automation.invoke(dispIdMember, rgvarg);
System.err.println("LoadFile " + file + " took "
+ ((float) (System.currentTimeMillis() - time) / 1000F));
return result.getBoolean();
}
protected void activate()
{
if (!activated)
{
activated = controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE) ==
OLE.S_OK;
}
}
protected void show(String file)
{
activate();
// OleAutomation oleAutomation = new OleAutomation(controlSite);
OlePDF pdfViewer = new OlePDF(controlSite);
try
{
boolean loaded = pdfViewer.loadFile(file);
if (loaded)
{
pdfViewer.setShowToolBar(false);
pdfViewer.setZoomScroll(80f, 300f, 800f);
}
else
{
throw new RuntimeException("LoadFile failed");
}
}
finally
{
pdfViewer.dispose();
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03084 seconds