Merging Archive Files

Report archive files are an exact replication of the report output when it is generated. While the report itself can be dynamic in nature by accepting different data, event code, or parameters, an archive is a direct snapshot of the output and is unchanging.

One way to merge multiple outputs into a single file is to use the built-in Archive Merge Utility. This utility can be used as a stand-alone class or part of the ArchiveReader component.

Begin by either creating a new TppRAFMerge object in code or using the built-in TppRAFMerge property of the Archive Reader.  Next, add the archive files to be merged and assign the destination file.  Finally, execute the process to merge the files.

uses ppArchiv;

...
      
const
  cTestDir = '...\Demos\1. Reports\Archives\';  //Location of the demo archives
var
  lRAFMerge: TppRAFMerge;
begin

  lRAFMerge := TppRAFMerge.Create; //ppArchiveReader.MergeUtility;

  try
    lRAFMerge.DestinationFile := cTestDir + 'TestMerge.raf';

    lRAFMerge.SourceFiles.Add(cTestDir + 'dm0011.raf');
    lRAFMerge.SourceFiles.Add(cTestDir + 'dm0017.raf');
    lRAFMerge.SourceFiles.Add(cTestDir + 'dm0033.raf');

    // options
    //lRAFMerge.DeleteSourceFiles := True;
    //lRAFMerge.RenumberPages := True;


    lRAFMerge.Execute;

  finally
    lRAFMerge.Free; //Do not free MergeUtility if used
  end;

end;

Once the merged archive file is created, it is now possible to view or export it using the Archive Reader.

ppArchiveReader1.AllowPrintToFile := True;
ppArchiveReader1.ArchiveFileName := 'TestMerge.raf';
      
ppArchiveReader1.Print;

See the following example for how this can be done: MergeArchives.zip