inserting a file

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

joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

inserting a file

Post by joeitaliano »

hello

i like to know how to insert a file into a PDF file that i have open

basically the same functionality to that in the reader for insert a PDF file

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

Re: inserting a file

Post by Vasyl - PDF-XChange »

Hi, joe.

1. If you want to add pages from other document to the opened - look to SDK help file:
Reference/Named Items/Objects/Documents/<Item>/<Methods>/InsertPages
Reference/Named Items/Objects/Operations/InsertPages

2. If you want to simple attach any existing file to the opened document:
Reference/Named Items/Objects/Documents/<Item>/<Methods>/AddAttachment
see also https://forum.pdf-xchange.com/ ... =36&t=9328 - these new features still undocumented but it will be described in the next build...

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.
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: inserting a file

Post by joeitaliano »

hi vasyl

i appreciate your help

i have looked at the manual and am struggling with it so i am sincerely trying

we don't want to attach a file but simply grab another PDF file and just append to the end of the one that is opened

i will try again and see if i can make this work

if you have some magic code then please do send to me

many thanks again and have a happy new year and all the best

joe
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: inserting a file

Post by Stefan - PDF-XChange »

Hello Joe,

This seems like you need the
2.2.2.11.4 InsertPages function - allows you to specify a file (external or already loaded in the Viewer), and a range of pages to be inserted to the current document.

Best,
Stefan
joeitaliano
User
Posts: 89
Joined: Wed Dec 29, 2010 8:50 am

Re: inserting a file

Post by joeitaliano »

hello

i am still not able to get the insertpages to work

i have tried many different ways and am at a lost

please don't take what i am about to say as critisim. the package is great

i think what you should do for the next release is to improve the fulldemo source to also include other features that the SDK supports

the demo is titled fulldemo which it is not. i have made progress mainly by studying this code but there no insertpages/deletepages function

my problem now is that hRes4 it is returning -2112674026 "No permissions for current action"

CComBSTR bsName1(L"InsertPages");
CComVariant vDataOut1;
CComVariant vDataIn1(L"1,1,\"1\",1,\"c:\\\",0,0");
HRESULT hRes4 = m_spView->DoDocumentVerb(nActiveDocID, NULL, bsName1, vDataIn1, &vDataOut1, 0);
BSTR res;
m_spView->GetTextFromResult(hRes4, &res);

then i get hRes4 returns -2112673932 "Specified document is not found"

CComBSTR bsName(L"InsertDocumentPages");
CComVariant vDataOut;
CComVariant vDataIn(L"x.pdf");
hRes4 = m_spView->DoDocumentVerb(nActiveDocID, NULL, bsName, vDataIn, &vDataOut, 0);
m_spView->GetTextFromResult(hRes4, &res);

so i am at a lost and your help would be appreciated

have a happy new year

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

Re: inserting a file

Post by Vasyl - PDF-XChange »

Hi, joeitaliano.
my problem now is that hRes4 it is returning -2112674026 "No permissions for current action"
The PDF document can be secured and some operations with document can be inaccessible, such as commenting, insert/delete/move pages, copying text/content, exporting data etc. (see official Adobe PDF Reference). Look also to SDK help file [Reference/NamedItems/Objects/Documents/Item/Methods/IsOperationGranted].
CComBSTR bsName1(L"InsertPages");
CComVariant vDataOut1;
CComVariant vDataIn1(L"1,1,\"1\",1,\"c:\\\",0,0");
HRESULT hRes4 = m_spView->DoDocumentVerb(nActiveDocID, NULL, bsName1, vDataIn1, &vDataOut1, 0);
BSTR res;
m_spView->GetTextFromResult(hRes4, &res);
then i get hRes4 returns -2112673932 "Specified document is not found"
Your code is wrong. Correct is:

Code: Select all

// setup options for 'InsertPages' operation before call:
m_spView->SetProperty("Operations.InsertPages.RangeType", "Exact");
m_spView->SetProperty("Operations.InsertPages.RangeText", "1, 3"); // pages from source
m_spView->SetProperty("Operations.InsertPages.FromExternal", 1);
m_spView->SetProperty("Operations.InsertPages.File", "c:\\source.pdf"); // specify source document
m_spView->SetProperty("Operations.InsertPages.InsertBefore", 0); // insert new pages form source to begin of destination document
// call 'InsertPages'
CComBSTR bsOp(L"InsertPages");
CComVariant vStub;
HRESULT hr = m_spView->DoDocumentVerb(nDestDocID, NULL, bsOp, vStub, NULL, PXCVA_NoUI);
- see in manual:
[Reference/Named Items/Objects/Documents/<Item>/<Methods>/InsertPages]
[Reference/Named Items/Objects/Operations/InsertPages]

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.