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.
SaveAttachment and DeleteAttachment Request
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 923
- Joined: Wed Sep 30, 2009 6:53 pm
-
- Site Admin
- Posts: 7371
- Joined: Wed Mar 25, 2009 10:37 pm
Re: SaveAttachment and DeleteAttachment Request
Hi Jeff,
sorry - it appears this post was overlooked. I've asked one of the dev team to take a look.
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
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
-
- User
- Posts: 923
- Joined: Wed Sep 30, 2009 6:53 pm
Re: SaveAttachment and DeleteAttachment Request
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.
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.
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: SaveAttachment and DeleteAttachment Request
Hi, jeffp.
In the next build (190) you will be able to use next routines:
Best
Regards.
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");
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 923
- Joined: Wed Sep 30, 2009 6:53 pm
Re: SaveAttachment and DeleteAttachment Request
Perfect. As my son, would say, "You Rock!".
Thanks again.
Thanks again.
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: SaveAttachment and DeleteAttachment Request

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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 923
- Joined: Wed Sep 30, 2009 6:53 pm
Re: SaveAttachment and DeleteAttachment Request
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.
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.
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: SaveAttachment and DeleteAttachment Request
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.
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 923
- Joined: Wed Sep 30, 2009 6:53 pm
Re: SaveAttachment and DeleteAttachment Request
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.
I'll wait for the next build to test.
Thanks again.
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: SaveAttachment and DeleteAttachment Request
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.