Unable to save edited pdf file frm PDFXChange Viewer

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

johnnyjoe
User
Posts: 35
Joined: Thu Nov 26, 2009 3:14 am

Unable to save edited pdf file frm PDFXChange Viewer

Post by johnnyjoe »

Hi! Im using VB.NET 2010 + PDF XChange Viewer SDK + Windows 7 Ultimate.

1. I had added the licenses in the project.
2. Open the pdf file with the pdf viewer from my project path which like:
C:\Users\Test\Desktop\TT\TT\bin\Debug\Temp\oop.pdf

3. Just use stamp Draft on the pdf file
4. Use via code to save it:
Call PDFXCview1.SetProperty("Prompts.ConfirmDocumentSave.UserChoice", "YES", 0)

The problem is the file is not save at all. There is no error prompt out.
May i know the reason why? How to solve it?

I also unable to use the savedocument method. It was hang all the way.

Is it i need to clear Viewer first before i save by via code?

But the toolbar button save was able to save. why?
May i know how to detect the toolbar button save is been clicked?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Unable to save edited pdf file frm PDFXChange Viewer

Post by Stefan - PDF-XChange »

Hello johnnyjoe,

You need to specify the save location before setting this prompt:
The example in pseudocode from the manual is:

Code: Select all

function OnEvent(Type, Name, DataIn, DataOut, Flags)
{
  ...
     if (Type == PXCVA_OnDisplayPrompt)
     {
        if (Name == "Prompts.ConfirmDocumentSave")
        {
            // set another file name
            SetProperty("Prompts.ConfirmDocumentSave.FileName",
                        DataIn("C:\Test2.pdf"), 0);
            //
            // skip original dialog and
            // try to save document into "C:\Test2.pdf"
            SetProperty("Prompts.ConfirmDocumentSave.UserChoice", DataIn("Yes"), 0);
          ...
        }
     }
  ...
}
And please note that this is called in the even when the Viewer has already raised the ConfirmDocumentSave prompt.
This will handle the case when your users click the "Save" button on the Viewer toolbar.

If you want to silently save the document without any user intervention please have a look at the manual section
3.3 How to save a document. In that section the following VB.NET sample is provided for saving a document:

Code: Select all

Dim nDocumentID As Integer
Dim nRes As Integer
...
Try
AxCoPDFXCview1.SaveDocument(nDocumentID, Nothing, 0, 0);
Catch ex As Exception
nRes = System.Runtime.InteropServices.Marshal.GetHRForException(ex)
End Try
Best,
Stefan