How do I close a pdf file opened with wx.lib.pdfwin.PDFWindow

Hi,

I use PDFWindow to open a pdf file. After that, I want to close the
file and then delete it. But even though PDFWindow is destroyed, the
pdf file is still open. I can not find an explicit method to close the
file, PDFWindow has only LoadFile.

Is there a possible solution? My application runs under Windows, so
when an file is open, it can not be deleted.

Best Regards

···

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn

Yuan HOng wrote:

Hi,

I use PDFWindow to open a pdf file. After that, I want to close the
file and then delete it. But even though PDFWindow is destroyed, the
pdf file is still open. I can not find an explicit method to close the
file, PDFWindow has only LoadFile.

Is there a possible solution? My application runs under Windows, so
when an file is open, it can not be deleted.

Best Regards

You can use LoadFile to open a different file, which closes the first
file. I usually keep a special, empty PDF file handy for this.

Regards,

David Hughes

Yuan HOng wrote:

Hi,

I use PDFWindow to open a pdf file. After that, I want to close the
file and then delete it. But even though PDFWindow is destroyed, the
pdf file is still open. I can not find an explicit method to close the
file, PDFWindow has only LoadFile.

Is there a possible solution?

Did you try loading another file? (Perhaps just a small simple one that
shows your logo or something.)

My application runs under Windows, so
when an file is open, it can not be deleted.

BTW, I can't duplicate this. I ran the demo, loaded a PDF, switched to
another sample in the demo, and then tried deleting the PDF file. It
deleted without any error.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

What I attempted to achieve is to generate a temporary PDF file from
business objects in my project, show it to the user for preview or
printing. When the user closes the view window, the temporary file
should be deleted.

Attached below is a small demonstration of this. Instead of generating
a PDF file, I just copy from an existing one. After the view dialog is
destroyed, os.remove returns:

WindowsError: [Error 32] : 'c:\\docume~1\\hong\\locals~1\\temp\\tmpd0mdvj'

testwx.py (1.88 KB)

···

On 6/14/07, Robin Dunn <robin@alldunn.com> wrote:

BTW, I can't duplicate this. I ran the demo, loaded a PDF, switched to
another sample in the demo, and then tried deleting the PDF file. It
deleted without any error.

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn

That's a nice workaround. Thanks.

···

On 6/13/07, David Hughes <dfh@foresoft.co.uk> wrote:

You can use LoadFile to open a different file, which closes the first
file. I usually keep a special, empty PDF file handy for this.

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn

Yuan HOng wrote:

···

On 6/14/07, Robin Dunn <robin@alldunn.com> wrote:

BTW, I can't duplicate this. I ran the demo, loaded a PDF, switched to
another sample in the demo, and then tried deleting the PDF file. It
deleted without any error.

What I attempted to achieve is to generate a temporary PDF file from
business objects in my project, show it to the user for preview or
printing. When the user closes the view window, the temporary file
should be deleted.

Attached below is a small demonstration of this. Instead of generating
a PDF file, I just copy from an existing one. After the view dialog is
destroyed, os.remove returns:

WindowsError: [Error 32] : 'c:\\docume~1\\hong\\locals~1\\temp\\tmpd0mdvj'

I think it's a timing thing. Watching the processes in Windows Task Manager, there is quite a delay before AcroRd32.exe terminates and releases the file. It also seems to depend on the version of Acrobat Reader (or possibly which Activex control in wx.lib.pdfwin is being used).
--
Regards,

David Hughes

Hi,

I created a FileDialog then call ShowModal on this new dialog.
Then, I close my application (using the windows tray).

Just before exiting my application, I try to close each opened Frane (including the FileDialog) using Destroy() (Close(force = True) give the same result)

But this FileDialog (or a DirDialog) stay opened.

so Is it possibled to close this Frame ?

Thanks

Wursteisen David wrote:

Hi,

I created a FileDialog then call ShowModal on this new dialog.
Then, I close my application (using the windows tray).

Just before exiting my application, I try to close each opened Frane (including the FileDialog) using Destroy() (Close(force = True) give the same result)

But this FileDialog (or a DirDialog) stay opened.

so Is it possibled to close this Frame ?

The FileDialog and most of the other common dialogs are not true wx.Dialogs. The are just wrappers around a system API that shows the system dialog and returns some values. Because of this most of the wx.Window or wx.Dialog methods are simply ignored. The only way that I know of to close a wx.FileDialog is for the user to do it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!