Merges different PDF documents into single PDF in memory

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfVision (in SautinSoft.PdfVision.dll) Version:


 C#  Visual Basic 
public byte[] MergePDFStreamArrayToPDFStream(
	List<byte[]> pdfList
Public Function MergePDFStreamArrayToPDFStream ( _
	pdfList As List(Of Byte()) _
) As Byte()


List<(Of <(array< Byte >[]()[]>)>)
List which contains PDF documents as array of bytes

Return Value

Single PDF document as byte array - in case of merging successfully
null - in case of merging failed


CopyHow to merge PDF in memory in C#
using System;
using System.IO;
using System.Collections.Generic;

namespace Sample
    class Test

        static void Main(string[] args)

            // Merge PDF in memory
            SautinSoft.PdfVision v = new SautinSoft.PdfVision();

            //v.Serial = "XXXXXXXXXXXXXXX";

            // merge two PDF files
            string[] inpFiles = new string[] { @"..\..\simple text.pdf", @"..\..\table.pdf" };

            FileInfo singlePdf = new FileInfo("single.pdf");

            List<byte[]> inpFilesByte = new List<byte[]>();

            // Fill the pdfBytesList.
            foreach (string inpFile in inpFiles)

            byte[] pdfBytes = v.MergePDFStreamArrayToPDFStream(inpFilesByte);

            if (pdfBytes != null)
                File.WriteAllBytes(singlePdf.FullName, pdfBytes);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(singlePdf.FullName) { UseShellExecute = true });
CopyHow to merge PDF in memory in VB.Net
Imports System
Imports System.IO
Imports System.Collections.Generic

Namespace Sample
    Friend Class Test

        Shared Sub Main(ByVal args() As String)

            ' Merge PDF in memory
            Dim v As New SautinSoft.PdfVision()

            'v.Serial = "XXXXXXXXXXXXXXX"

            ' merge two PDF files
            Dim inpFiles() As String = { "..\..\simple text.pdf", "..\..\table.pdf" }

            Dim singlePdf As New FileInfo("single.pdf")

            Dim inpFilesByte As New List(Of Byte())()

            ' Fill the pdfBytesList.
            For Each inpFile As String In inpFiles
            Next inpFile

            Dim pdfBytes() As Byte = v.MergePDFStreamArrayToPDFStream(inpFilesByte)

            If pdfBytes IsNot Nothing Then
                File.WriteAllBytes(singlePdf.FullName, pdfBytes)
                System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(singlePdf.FullName) With {.UseShellExecute = True})
            End If
        End Sub
    End Class
End Namespace

See Also