PDF-XChange Editor SDK for Developers
Moderators: PDF-XChange Support , Daniel - PDF-XChange , Chris - PDF-XChange , Sean - PDF-XChange , Paul - PDF-XChange , Vasyl - PDF-XChange , Ivan - Tracker Software , Stefan - PDF-XChange
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the
IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
jeffp
User
Posts: 926 Joined: Wed Sep 30, 2009 6:53 pm
Post
by jeffp » Sat Mar 19, 2016 1:26 am
I'm using Delphi and I've be able to get Pages.MovePages and Pages.DeletePages work. However, I can't get Pages.InsertPagesFromDocEx to work. Below is my sample code that does seem to work. I'm trying to insert the first to pages of ADoc2 insto ADoc1.
Can you give me some guidance I what I'm doing incorrectly. Both Docs have 5 pages in them.
Code: Select all
procedure InsertPagesTest;
var
AFile1, AFile2: String;
pdfCore1, pdfCore2: TPXC_Inst;
ADoc1, ADoc2: IPXC_Document;
BS: IBitSet;
AInstAUX: IAUX_Inst;
APageCount1, APageCount2: Cardinal;
begin
AFile1 := 'F:\TEMP\Numbers.pdf';
AFile2 := 'F:\TEMP\Letters.pdf';
pdfCore1 := TPXC_Inst.Create(nil);
pdfCore2 := TPXC_Inst.Create(nil);
try
pdfCore1.Init(LIC_KEY);
pdfCore2.Init(LIC_KEY);
ADoc1 := pdfCore1.OpenDocumentFromFile(PChar(AFile1), nil, nil, 0, 0);
ADoc2 := pdfCore2.OpenDocumentFromFile(PChar(AFile2), nil, nil, 0, 0);
ADoc1.Pages.Get_Count(APageCount1);
ADoc2.Pages.Get_Count(APageCount2);
AInstAUX := pdfCore2.GetExtension('AUX') as IAUX_Inst;
BS := AInstAUX.CreateBitSet(APageCount2);
BS.SetSize(APageCount2);
BS.Item[0] := True;
BS.Item[1] := True;
ADoc1.Pages.InsertPagesFromDocEx(ADoc2, APageCount1, BS, IPF_Annots_Copy + IPF_Bookmarks_CopyAll, nil);
ADoc1.WriteToFile(PChar(AFile1), nil, 0);
finally
pdfCore1.Free;
pdfCore2.Free;
end;
end;
Thanks.
--Jeff
Sasha - PDF-XChange
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Post
by Sasha - PDF-XChange » Mon Mar 21, 2016 9:08 am
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 926 Joined: Wed Sep 30, 2009 6:53 pm
Post
by jeffp » Mon Mar 21, 2016 1:50 pm
See modified code below. It's still now inserting pages. The hr variable below returns a -2147467259 not S_OK.
Again, I'm trying to insert the first two pages of AFile2 into AFile1.
Code: Select all
procedure InsertPagesTest(pdfCore: IPXC_Inst);
var
hr: HRESULT;
AFile1, AFile2: String;
ADoc1, ADoc2: IPXC_Document;
BS: IBitSet;
AInstAUX: IAUX_Inst;
APageCount1, APageCount2: Cardinal;
begin
AFile1 := 'F:\TEMP\Numbers.pdf';
AFile2 := 'F:\TEMP\Letters.pdf';
ADoc1 := pdfCore.OpenDocumentFromFile(PChar(AFile1), nil, nil, 0, 0);
ADoc2 := pdfCore.OpenDocumentFromFile(PChar(AFile2), nil, nil, 0, 0);
ADoc1.Pages.Get_Count(APageCount1);
ADoc2.Pages.Get_Count(APageCount2);
AInstAUX := pdfCore.GetExtension('AUX') as IAUX_Inst;
BS := AInstAUX.CreateBitSet(APageCount2);
BS.SetSize(APageCount2);
BS.Item[0] := True;
BS.Item[1] := True;
hr := ADoc1.Pages.InsertPagesFromDocEx(ADoc2, APageCount1, BS, IPF_Annots_Copy + IPF_Bookmarks_CopyAll, nil);
end;
Sasha - PDF-XChange
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Post
by Sasha - PDF-XChange » Mon Mar 21, 2016 3:22 pm
Hello Jeff,
We've managed to reproduce this issue - testing now.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 926 Joined: Wed Sep 30, 2009 6:53 pm
Post
by jeffp » Fri Mar 25, 2016 1:07 am
You build 6.0.317 seems to have fixed this issue.
Thanks.
--Jeff
Sasha - PDF-XChange
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Post
by Sasha - PDF-XChange » Fri Mar 25, 2016 7:21 am
Hello Jeff,
There were some changes done to the insert pages inner methods - probably that also fixed this problem.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ