Merging 2 pdf in Delphi

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
Thoni
User
Posts: 12
Joined: Tue Aug 26, 2008 11:46 am

Merging 2 pdf in Delphi

Post by Thoni »

Hello.

I'm having problems while trying to merge 2 pdf's together.

The code i used:

Code: Select all

Var OldPDF : hPDF;
    OV     : hPDF;
    CPI    : Array of LPPXCp_ContentPlaceInfo;
in the procedure i do a

PXCp_Init(@OldPDF.....
PXCp_Init(@OV.....
PXCp_ReadDocumentW(OldPDF....
PXCp_ReadDocumentW(OV.....
PXCp_GetPagesCount(Alte....

until this the code is ok.

Then i do the following:

Code: Select all

SetLength(CPI,NumberOfPages);
for i:=0 to NumberOfPages-1 do
begin
  New(CPI[I]);
  CPI[Lauf].DestPage:=I;
  CPI[Lauf].SrcPage:=0;
  CPI[Lauf].Alignment:=CPA_HorFit or CPA_VerFit or CPA_Foreground;
end;
Err:=pxcp_placeContents(OldPDF,OV,NumberOfPages,CPI[0],0);     
OV is a pdf with only one page, that should overlay all the pages in OldPDF.
I have tried this with a pdf with 3 pages.
The resulting pdf have the overlay only at page 1.
With a OldPDF of 100 pages, the overlay are on pages 1,10,15,18 (random?)

What i am missing?
(Sorry for my bad english)
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Merging 2 pdf in Delphi

Post by Lzcat - Tracker Supp »

You are using wrong declaration for CPI variable - it must be array of PXCp_ContentPlaceInfo structures, not pointers to them.

Code: Select all

CPI    : Array of PXCp_ContentPlaceInfo;
....
SetLength(CPI,NumberOfPages);
for i:=0 to NumberOfPages-1 do
begin
  CPI[i].DestPage:=i;
  CPI[i].SrcPage:=0;
  CPI[i].Alignment:=CPA_HorFit or CPA_VerFit or CPA_Foreground;
end;
Err:=pxcp_placeContents(OldPDF,OV,NumberOfPages,@CPI[0],0);
...
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Thoni
User
Posts: 12
Joined: Tue Aug 26, 2008 11:46 am

Re: Merging 2 pdf in Delphi

Post by Thoni »

Oh.... Thanks alot.

My C is not so good, that I can read the help examples. As I saw a 'new' i thought it must be a pointer.
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Merging 2 pdf in Delphi

Post by John - Tracker Supp »

Pleased all is well.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
Post Reply