I've used Delphi for this sample, but the syntax is quite straightforward and it shouldn't be difficult to understand.
procedure TForm2.btnOverlayClick(Sender: TObject);
var
FileA: Integer;
FileB: Integer;
CapturedPageID: Integer;
PageHeight: Double;
PageWidth: Double;
Path: AnsiString;
begin
QP := TQuickPDF0716.Create;
try
UnlockResult := QP.UnlockKey('...'); // Insert trial or paid license key here
if UnlockResult = 1 then
begin
// You can only use the DrawCapturedPage function if the captured page is in the same
// document, so first we'll need to merge the two pages that we wish to overlay together
// into one document.
if dlgOpen.Execute then
begin
QP.LoadFromFile(dlgOpen.FileName);
FileA := QP.SelectedDocument();
end;
if dlgOpen.Execute then
begin
QP.LoadFromFile(dlgOpen.FileName);
FileB := QP.SelectedDocument();
end;
// After merging FileB is automatically deleted, leaving only FileB which is now a combination of FileA and FileB
QP.SelectDocument(FileA);
QP.MergeDocument(FileB);
// Capture the second page in the merged document
CapturedPageID := QP.CapturePage(2);
// Now select the first page and retrieve its height and width
QP.SelectDocument(FileA);
QP.SelectPage(1);
PageHeight := QP.PageHeight();
PageWidth := QP.PageWidth();
// Draw the captured page onto the currently selected page
QP.DrawCapturedPage(CapturedPageID, 0, PageHeight, PageWidth, PageHeight);
// Save the stitched file to disk
if dlgSave.Execute then
begin
Path := dlgSave.FileName;
end;
QP.SaveToFile(Path);
end;
finally
QP.Free;
end;
end;
------------
Obviously if the two pages don't have the same dimensions then you'll need to do some tinkering, but if they do, then this code should work quite well.