1. Jay Madren
  2. Valentina Reports ADK
  3. Tuesday, February 27 2018, 10:07 PM
  4.  Subscribe via email
Xojo app on Windows:

When I use PrintToDisk to create a PDF file, I can't open or edit the resultant PDF until I exit the Xojo application. How can I make it close and release the file?
Comment
There are no comments made yet.
Sergey Pashkov Accepted Answer
Hello Jay,

Is it a desktop application?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 1
Jay Madren Accepted Answer
Yes.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 2
Sergey Pashkov Accepted Answer
The reference to the file is not kept, there must be something else which prevents access to it.

So you call PrintToDisk and try to open in Acrobat Reader? Edit in Acrobat? What exact message?

How do you get the path to the PDF file - is it constant or does it come from the open file dialogue?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 3
Jay Madren Accepted Answer
Yes, trying to open in Acrobat Reader, or even trying to rename the file is not allowed. The message from Acrobat is "There was an error opening this document. This file is already open or in use by another application." If I try to rename the PDF the resultant error message names the Xojo app as the one that has the file open. All of this goes away when I exit the Xojo app.

Saving the file on a shared volume, I can then see the file locked status which says it's locked for Write.

Doing some more testing I found that this only occurs in 64-bit Windows apps. 32-bit works fine.

The problem does not appear to be Xojo itself, as I can create a file and write to it with BinaryStream, but still access/rename/delete that file without exiting the Xojo app.

Edit: The file comes from the open file dialog.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 4
Sergey Pashkov Accepted Answer
Thanks for the details, I reproduced this issue in the 64-bit application.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 5
Sergey Pashkov Accepted Answer
Hello Jay,

There will not be a fast fix for this issue - it is even not reproducible in the debug build.
As a workaround PrintToBuffer method should be used with saving to file using Xojo classes.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 6
Jay Madren Accepted Answer
Ok, thanks. I'll try the PrintToBuffer method and see if it works ok.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 7
Jay Madren Accepted Answer
Ok, the PrintToBuffer method works fine. It doesn't take very much code to do it - I just called PrintToBuffer directly in a single BinaryStream.Write call.

Thanks.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 8
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.