Replacing Save with SaveAs

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Replacing Save with SaveAs

Post by jeffp »

Here's a situation I need to better deal with.

I am using an outside scanning component to create a PDF scan. I am placing the PDF output in the Windows Temp directory and then I'm opening it in the ActiveX Viewer. To the user, this appears as a new PDF scan that hasn't yet been saved (while technically it exists in the Temp folder).

As such, when the user hits Save I need the ability to throw up the Save As dialog and ask the user where the PDF should be saved. Currently, clicking the Save button will just save any changes back to the Temp location.

So, is there anyway I can intercept the save call in this case and replace it with a SaveAs dialog?

Alternatively, it would be nice to assign the Documents[xx].FileName property to just the name part of the full path and let you deal with it like your internal scan. However, this property is read only.

Have you thought about allowing the developer to change the Documents[xx].FileName to just a name that doesn't exists yet (like NewDocument.pdf) and then deal with it internally as a temp file. That is, you would always fire the SaveAs dialog when saving, etc.

Thanks.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Replacing Save with SaveAs

Post by John - Tracker Supp »

Hi Jeff,

have asked Vasya to answer you specifically - but if you own our PDF-Tools SDK you could use the option there to scan and pass as a Stream - which subject to confirmation from Vasya might give you what you need ...

Will ask the guys to confirm ..
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: Replacing Save with SaveAs

Post by jeffp »

I'm using another scan component for various reasons so what I need to accomplish needs to happen without using your internal scan functions (at least for now).

As such, I'm just looking for a way to open a PDF file in ActiveX Viewer and somehow make the save work as save as.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Replacing Save with SaveAs

Post by John - Tracker Supp »

Understood - Vasya is going to explain a new option called ...

"Documents[xx].ForceSaveAs"
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: Replacing Save with SaveAs

Post by Vasyl - PDF-XChange »

Hi, jeffp.

Also, you may use:
1. our XCScan40 library for scanning and creating new images(or you may use your other software for scanning).
2. our PXCLib40 library for creation new pdf(s) from images and call PXC_WriteDocumentToIStream(from this library) for saving new pdf(s) into your stream object(s).
3. and pass filled stream object into our PDF-Viewer ActiveX for viewing and saving.
In this case when user presses the 'Save' button then "Save As" dialog will be displayed by default.

The new document's option "Documents[xx].Temp"("Temp" instead of "ForceSaveAs") means:
for the end-user - if is is "true" then the "Save" operation will display the "Save As" dialog and will set it to "false" automatically when the save operation was successful. The default value is "false".
This flag will be ignored if the save operation is called by the developer.

This option will be described in the updated Help file.

HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: Replacing Save with SaveAs

Post by jeffp »

Perfect. Just what I needed. Thanks again.
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: Replacing Save with SaveAs

Post by jeffp »

One follow up:

In the case where I pass a stream to the ActiveX Viewer, how does the default naming of such document work once it gets into the viewer? Do I have the ability to set what appears on the document tab in the viewer or do you control the naming convention?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: Replacing Save with SaveAs

Post by Vasyl - PDF-XChange »

Hi, jeffp.

You may call:

Code: Select all

SetProperty("Documents[<DocID>].DispFileName", "This is My Document", 0);
HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Replacing Save with SaveAs

Post by John - Tracker Supp »

Hi Jeff, after your email I have discussed this further with the project team and they suggest the best and most viable solution for you is to use the stream option ..

1. Pass this stream object with the document to our ActiveX(see our ActiveX SDK samples). Afters this our control will open the document from this stream.
2. Setup special property for the opened document:
SetProperty("Documents[#<DocID>].DispFileName", "C:\MyStorage\This is My Document.pdf", 0);
After this the ActiveX displays this string in all UI-places. And if end-user launches any save operations then this 'pseudo' will be displayed also.

There also exists an advanced feature. a developer can setup special stream usage mode by:

SetProperty("Documents.UseStreamsDirectly", "true", 0);

After this the each input-stream passed with an OpenDocument operation will be captured by our control and can be used for an end-user's "Save" operation.

The stream object should be created and filled by client(developer) before passing to our ActiveX. In most programming languages and in the WinAPI there exists a simple way to create stream objects. Our SDK package contains some examples for creating/filling/passing streams under different programming languages: C#, VB.NET, VB6, Delphi, C++.

Not 100% what you wanted - but a more robust and complete solution we hope you will agree.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: Replacing Save with SaveAs

Post by jeffp »

John,

Thanks much. I'll give this a try and let you know.

Is Documents[#<DocID>].DispFileName a new property? I don't see it in the User manual anywhere.
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: Replacing Save with SaveAs

Post by jeffp »

Ok. I think I have this working nicely but it brings up two follow up questions.

1. When I load a PDF file via a Stream and set UseStreamsDirectly to true, I would assume that the PDF File would no longer be locked by the Viewer. For example, I open the PDF as described above in a stream and then went to Windows explorer, clicked on the PDF file, and tried to delete it. Windows then gave me a message saying the file is locked. Is there a way to take the lock off once the file is loaded into the Viewer?

2. Are there any performance issues with opening all my files into the Viewer via the Stream approach? Is it faster, slower? Also, can I use the stream approach for all my files? Or should I just use this approach in those cases described in this thread? Are there memory issues with the Stream approach as the user starts to add comments and markups, and then saves.

Thanks.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: Replacing Save with SaveAs

Post by Vasyl - PDF-XChange »

Hi, Jeff.
1. When I load a PDF file via a Stream and set UseStreamsDirectly to true, I would assume that the PDF File would no longer be locked by the Viewer. For example, I open the PDF as described above in a stream and then went to Windows explorer, clicked on the PDF file, and tried to delete it. Windows then gave me a message saying the file is locked. Is there a way to take the lock off once the file is loaded into the Viewer?
This behavior occurs because control locks the passed stream for possible save operation in the future(UseStreamsDirectly==true).
If you don't wish to lock a input-stream resource you may try:
1. set UseStreamsDirectly to false.
2. Pass the your stream object to control for open.
3. Call:

Code: Select all

SetProperty("Documents[#<DocID>].DispFileName", "C:\MyStorage\This is My Document.pdf", 0); // setup pseudo file name which will be displayed in UI.
After this the first end-user's "Save" operation will be replaced by "Save As" operation.
Are there any performance issues with opening all my files into the Viewer via the Stream approach? Is it faster, slower? Also, can I use the stream approach for all my files? Or should I just use this approach in those cases described in this thread? Are there memory issues with the Stream approach as the user starts to add comments and markups, and then saves.
Opening from stream can be some slower for a very big files. You may use the stream approach for all your files. When you pass stream object to our control - the control copies entire data from stream to private temporary storage and works with it. If you specify the UseStreamsDirectly to true then control locks your stream for possible save operation in the future.

May be in the future we will add the new event like as "OnSaveDocument" for simple customization of this situation...

HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: Replacing Save with SaveAs

Post by jeffp »

Code: Select all

After this the first end-user's "Save" operation will be replaced by "Save As" operation.
This is true. But do this.

1. Set Modified to true.
2. Try to close the PDF. This brings up the Confirm Document Save dialog.
3. Click Yes. This saves the PDF without displaying the SaveAs. Seems like the save here should also be SaveAs.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: Replacing Save with SaveAs

Post by Vasyl - PDF-XChange »

Confirmed. This issue is identical to:
http://www.docu-track.com/forum3/viewto ... =36&t=7827

Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.