Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
See more:
In my windows application i will use PDF-XChnage Viewer ActiveX Control and i will call like below


PDFxDoc.OpenDocument(System.Windows.Forms.Application.StartupPath & "\Temp\" + fname)

and it will open pdf document also,but i need to check PDFXDoc control have open document or not ?
if it is document is opened in pdf control i will close using following code


but even though document is not open then i will try to close document using PDFxDoc.CloseDocument(0) ,it will show error.

So i need to check first document is open or not ? so pls tell me how check pdf control have document or not before going to close.

Note: Need to check in if condition like

If(PDFxDoc) Then 'Here need to check pdf control have document or not ? how to check here ??

PDFxDoc.CloseDocument(0)'This line close document



Pls reply asap

Updated 19-Mar-14 4:16am

It seem like a question to the company wrote the ActiveX...[^]
Share this answer
Aravindba 19-Mar-14 9:51am    
hi thanx for ur reply ,actually i have that dll and reference same dll and i used for view pdf,it will work also,but i need to check pdf viewer opened document or not ,if only open in pdf viewer then only close document,if not open then don't want to close document.pls read my question clearly....
Kornfeld Eliyahu Peter 19-Mar-14 9:59am    
I got your question - what I'm telling you that you have a commercial product in your hand, so ask the company!
Aravindba 19-Mar-14 10:06am    
that company not deal with coding.that company only sell the product,like software selling company,i will use that dll and can open pdf file using that viewer,
my need is how to check whether pdf viewer open pdf file or not,bcz if file is open in pdf viewer and try to delete form folder,it show error like 'file is used by other process....." so only need to check file is open or not first then only can delete file
Kornfeld Eliyahu Peter 19-Mar-14 10:24am    
I just downloaded the installer at the link I gave you - installed it and found a PDF full of info...
One of the sections says that there is a CloseAllDocuments method that closes all without knowing the Id of opened document (or without checking if there are any)...
Aravindba 19-Mar-14 11:12am    
how it will delete file form folder when file is open in pdf viewer ?u cant delete at all,it will show error like " cannot delete bcz used by other process....."
u can try manually like ,open one pdf file and try to delete open pdf file (same file) definitely it show error "The action can't be complete because file is open in Adobe Reader"
I have solved this problem myself,
Before going to delete file from Temp folder i will open file in pdf viewer ,same like view file in pdf viewer and then close document,now we know definitely file is not open in pdf viewer,so no need to check file is open or not in the pdf viewer.

 PDFxDoc.OpenDocument(System.Windows.Forms.Application.StartupPath & "\sample.pdf")

Why i am ask need to check file is open or not in pdf viewer,in one Form user view pdf file and go to other Form for some other process ,so that time file is open in pdf viewer and user click logout button,sometimes user not open pdf file directly go to other Form and user click logout button.When user click logout button i will clear Temp folder in the StartupPath ,like
My.Computer.FileSystem.DeleteDirectory(System.Windows.Forms.Application.StartupPath + "\Temp", FileIO.DeleteDirectoryOption.DeleteAllContents)

So file is open in pdf viewer definitely it show error like "...used by other process....".
For this ,file is open or not by user ,when logout time i will open one temp pdf file from StartupPath (not form Temp folder which i am going to delete folder) to viewer and close it,so definitely those file open from Temp folder ,that file are released form viewer and can delete Temp Folder also.

Why i am use Temp folder in my application,user upload pdf file and i will store in sql server in the format of bytes,so if user need to open ,first i will get byte from sql server and convert as pdf file and save in Temp folder and view in pdf viewer.So each and every time if user see the pdf file ,Temp folder get lot of pdf files and space occupy more,so need to clear that files and get space.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900