I have a C# wrapper class for merging documents. The function below takes adds the pages from one document to another.
Log from Working machine
2019/01/21 10:44:25.05 -> AddPages (a1) 0 - 562692148 - C:\Users\George Lima\AppData\Local\Temp\[BATES]-Merge.PDF
2019/01/21 10:44:25.05 -> AddPages (b1) -2081161214
2019/01/21 10:44:25.05 -> AddPages (a2) 0 - 562692552 - C:\Users\George Lima\AppData\Local\Temp\[BATES] Merge_Doc.PDF
2019/01/21 10:44:25.05 -> AddPages (b2) 0
2019/01/21 10:44:25.05 -> AddPages (c) 0
2019/01/21 10:44:25.05 -> AddPages (e) 0
2019/01/21 10:44:25.06 -> AddPages (f) 0
Log from non working machine
2019/01/21 10:42:04.74 -> AddPages (a1) 0 - 520486964 - C:\Users\John\AppData\Local\Temp\[BATES]-Merge.PDF
2019/01/21 10:42:04.74 -> AddPages (b1) -2081161214
2019/01/21 10:42:04.74 -> AddPages (a2) 0 - 520487368 - C:\Users\John\AppData\Local\Temp\[BATES] Merge_Doc.PDF
2019/01/21 10:42:04.74 -> AddPages (b2) 0
2019/01/21 10:42:04.75 -> AddPages (c) 0
2019/01/21 10:42:04.75 -> AddPages (e) -2113404927
2019/01/21 10:42:04.75 -> AddPages (f) -2113404927
Function being performed
Code: Select all
public int AddPages(string outputfile, string inputfile)
{
int retval = -99;
try
{
int file1, file2;
res = PDFXCp_Funcs.PXCp_Init(out file1, PDFXCp_Funcs.g_RegKey, PDFXCp_Funcs.g_DevCode);
log.ErrorLog("AddPages (a1) " + res.ToString() + " - " + file1 + " - " + outputfile);
retval++;
res = PDFXCp_Funcs.PXCp_ReadDocumentW(file1, outputfile, 0);
log.ErrorLog("AddPages (b1) " + res.ToString() );
retval++;
res = PDFXCp_Funcs.PXCp_Init(out file2, PDFXCp_Funcs.g_RegKey, PDFXCp_Funcs.g_DevCode);
log.ErrorLog("AddPages (a2) " + res.ToString() + " - " + file2 + " - " + inputfile);
retval++;
res = PDFXCp_Funcs.PXCp_ReadDocumentW(file2, inputfile, 0);
log.ErrorLog("AddPages (b2) " + res.ToString());
int count = 0;
res = PDFXCp_Funcs.PXCp_GetPagesCount(file2, out count);
log.ErrorLog("AddPages (c) " + res.ToString());
retval++;
if (count > 0)
{
PDFXCp_Funcs.PXCp_CopyPageRange[] pRanges = new PDFXCp_Funcs.PXCp_CopyPageRange[1];
pRanges[0].StartPage = 0;
pRanges[0].EndPage = count - 1;
pRanges[0].InsertBefore = -1;
res = PDFXCp_Funcs.PXCp_InsertPagesTo(file2, file1, pRanges, 1, 0);
log.ErrorLog("AddPages (e) " + res.ToString());
retval++;
res = PDFXCp_Funcs.PXCp_WriteDocumentW(file1, outputfile,
PDFXCp_Funcs.PXCp_CreationDisposition.PXCp_CreationDisposition_Overwrite,
(int)PDFXCp_Funcs.PXCp_WriteDocFlag.PXCp_Write_Release);
log.ErrorLog("AddPages (f) " + res.ToString());
}
PDFXCp_Funcs.PXCp_Delete(file2);
retval++;
retval = count;
}
catch
{
}
return (retval);
}