VB.Net / Acrobat - Acrobat hangs after user manually exits program -
i'm having issue vb.net , adobe acrobat. issue comes exiting acrobat windows taskbar still states there acrobat.exe process open. have tried using marshal.releasecomobject(), still hangs there. not want have rely on "end process" option on task bar in order remove it.
below snippet of code try using:
try 'tries close acrobat application acrobatapp.exit() system.runtime.interopservices.marshal.releasecomobject(javascriptobj) javascriptobj = nothing system.runtime.interopservices.marshal.releasecomobject(acropddoc) acropddoc = nothing system.runtime.interopservices.marshal.releasecomobject(acrobatavdoc) acrobatavdoc = nothing system.runtime.interopservices.marshal.releasecomobject(acrobatapp) acrobatapp = nothing 'below snippet of code found garbage collecting, did not work 'gc.collect() 'gc.waitforpendingfinalizers() catch ex exception 'acrobat closed end try although not sure if problem - run javascript saveas script on acrobat side in order make copy of file. reason why hanging, ruled out based on basic knowledge of saving files , exiting other acrobat/microsoft programs.
any beneficial! thanks!
edit: -i forgot mention acrobat closes when application ends. (currently) trying make consider case if user manually closes acrobat application.
i figure not 1 having trouble this, came "dirty answer" question. although not conventional way of answering question, can done through process.
- get total opened acrobat files.
- loop through entire opened acrobat files - , store file names temp data structure (arraylist, array, etc)
- run "acrobatapp.closealldocs()", "acrobatapp.exit()", , function kills entire acrobat process.
- re-open documents vb side - use links stored inside data structure.
display acrobat.
if acrobatapp isnot nothing andalso acrobatapp.getnumavdocs > 0 dim docs(acrobatapp.getnumavdocs) string 'saving , formatting names of opened documents = 0 acrobatapp.getnumavdocs - 1 acrobatavdoc = acrobatapp.getavdoc(i) acropddoc = acrobatavdoc.getpddoc javascriptobj = acropddoc.getjsobject docs(i) = javascriptobj.path().tostring.replace("/", "\").substring(1) position = docs(i).indexof("\") docs(i) = docs(i).substring(0, position) + ":\" + docs(i).substring(position + 1) next 'closing , killing acrobat application acrobatapp.closealldocs() killacrobat() 'creating new instance of acrobat acrobatapp = createobject("acroexch.app") 'opening opened documents = 0 docs.length - 1 acrobatavdoc = createobject("acroexch.avdoc") acrobatavdoc.open(docs(i), path.getfilename(docs(i))) next 'displaying application acrobatapp.show() end if
Comments
Post a Comment