SaveAttachment and DeleteAttachment Request

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

SaveAttachment and DeleteAttachment Request

Post by jeffp »

I see that I can now add an attachement to a PDF programmatically in the SDK via the "AddAttachment" method. Would it be too much trouble to add "SaveAttachment" and "DeleteAttachment" methods? SaveAttachment would just need to take the Name of the attachment and a FilePath to which the attachment should be saved.

I need a way to get the attachment out of the PDF. Maybe there is already something there that I haven't seen.

Thanks.
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7371
Joined: Wed Mar 25, 2009 10:37 pm

Re: SaveAttachment and DeleteAttachment Request

Post by Paul - PDF-XChange »

Hi Jeff,

sorry - it appears this post was overlooked. I've asked one of the dev team to take a look.
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: SaveAttachment and DeleteAttachment Request

Post by jeffp »

In the absence of a SaveAttachment call in the ViewerAX, I've tried to use "this.exportDataObject" with your RunJavaScript call. The problem is trying to pass a filename where you want the attachment to be saved. exportDataObject allows you to pass a filename but is very picky on the locations and file extentions it allows. If passed but not allowed, you get the SaveAs dialog poping up which I don't want.

As such, I thought that with a SaveAttachment call in the ViewerAX, you could make it work with any filename I pass.

In my case, I am adding a saving an .xml file as an attachment and it appears that from a saving standpoint, it's not allowed.

Alternatively, could you hook up "this.getDataObjectContents" and then I could have it return the content of my .xml file which is what I care about.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: SaveAttachment and DeleteAttachment Request

Post by Vasyl - PDF-XChange »

Hi, jeffp.

In the next build (190) you will be able to use next routines:

Code: Select all

ctrl.DoDocumentVerb(docID, "", "GetAttachmentsCount", dataIn(<empty>), out dataOut);
ctrl.DoDocumentVerb(docID, "", "GetAttachmentName", dataIn(<ZeroBasedIndex>), out dataOut);
ctrl.DoDocumentVerb(docID, "", "GetAttachmentDesc", dataIn(<ZeroBasedIndex>), out dataOut);
ctrl.DoDocumentVerb(docID, "", "GetAttachmentSize", dataIn(<ZeroBasedIndex>), out dataOut);
ctrl.DoDocumentVerb(docID, "", "GetAttachmentModDate", dataIn(<ZeroBasedIndex>), out dataOut);
ctrl.DoDocumentVerb(docID, "", "SaveAttachment", dataIn(<NameOrZeroBasedIndex>, <DestinationFileNameOrStream>));
ctrl.DoDocumentVerb(docID, "", "DeleteAttachment", dataIn(<NameOrZeroBasedIndex>));
ctrl.DoDocumentVerb(docID, "", "DeleteAllAttachments");
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.
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: SaveAttachment and DeleteAttachment Request

Post by jeffp »

Perfect. As my son, would say, "You Rock!".

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

Re: SaveAttachment and DeleteAttachment Request

Post by Vasyl - PDF-XChange »

:D
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: SaveAttachment and DeleteAttachment Request

Post by jeffp »

Are these new attachment procedures in build 190? I'm working with this build and can't get the SaveAttachment procedure to work.

Here's my code and attached is a PDF that contains the attachment.

Code: Select all

procedure TPDFViewerAX.SaveAttachment(ADocID: Integer; AName, AFileName: String);
var
  ADataIn, ADataOut: OLEVariant;
  vArr: array of OLEVariant;
begin
  AName := 'FileCenterForm.xml';
  AFileName := 'c:\test.xml';

  if not IsValidDocID(ADocID) then exit;

  try
    SetLength(vArr, 2);
    vArr[0] := AName;
    vArr[1] := AFileName;
    ADataIn := vArr;
    FControl.DoDocumentVerb(ADocID, '', 'SaveAttachment', ADataIn, ADataOut, PXCVA_NoUI);
  except
    msgbox('error');
  end;
end;

You do not have the required permissions to view the files attached to this post.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: SaveAttachment and DeleteAttachment Request

Post by Vasyl - PDF-XChange »

Hi, jeffp.

Bug is confirmed. The previous sample description:
ctrl.DoDocumentVerb(docID, "", "SaveAttachment", dataIn(<NameOrZeroBasedIndex>, <DestinationFileNameOrStream>));
- is some incorrect because you cannot pass the name of attachment to the parameter <NameOrZeroBasedIndex>,
- currently you can pass the <ZeroBasedIndex> of the attachment only (you may find the needed attachment by GetAttachmentsCount()/GetAttachmentName(<index>)).
Use it as temporary workaround. We will support names in this input argument in the next build. Thanks for your report.

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.
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: SaveAttachment and DeleteAttachment Request

Post by jeffp »

Also, make sure you check GetAttachmentDesc and GetAttachmentSize. I think they suffer from the same issue.

I'll wait for the next build to test.

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

Re: SaveAttachment and DeleteAttachment Request

Post by Vasyl - PDF-XChange »

Ok. Thanks.
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.