Knowledge Base - How to merge two PDFs? (Windows)

The following example, shows how to merge the src.pdf to the end of dst.pdf:

Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;

            StorageFile srcFile = await localFolder.GetFileAsync("src.pdf");

            StorageFile dstFile = await localFolder.GetFileAsync("dst.pdf");

 

            IRandomAccessStream stream1 = await srcFile.OpenAsync(FileAccessMode.ReadWrite);

            IRandomAccessStream stream2 = await dstFile.OpenAsync(FileAccessMode.ReadWrite);

 

            if (stream1 != null && stream2 != null) {

                PDFDoc docSrc = new PDFDoc();

                PDFDoc docDst = new PDFDoc();

 

                docSrc.Open(stream1, "");

                docDst.Open(stream2, "");

                docDst.SetCahce(localFolder.Path + "/cache.dat");

 

                PDFImportCtx ctx = docDst.ImportStart(docSrc);

 

                int dstno = docDst.PageCount;

                int srccnt = docSrc.PageCount;

                int srcno = 0;

                while (srcno < srccnt) {

                    docDst.ImportPage(ctx, srcno, dstno);

                    dstno++;

                    srcno++;

                }

                docSrc.Close();

                docDst.Save();

                docDst.Close();

            }

Applies To

RadaeePDF SDK for Windows 10

Details

Created : 2016-12-09 08:21:19, Last Modified : 2017-05-09 10:49:20