Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

merging of pdf using aspose.pdf 3.9.0

$
0
0
Hi Team,

i am using aspose.pdf 3.9.0 and i cannot upgrade as my integration team is not allowing.
using 3.9 i want to merge two pdf and get single pdf output.
can you please correct my code.
Public Function MergePDFs(ByVal TempPDFs() As String, ByVal MergedPDFName As String, ByVal DeleteTempFiles As Boolean) As String
        Dim myPDF As Aspose.Pdf.Pdf
        Dim myPDF_1 As New Aspose.Pdf.Pdf

        Try
            For TempInd As Int32 = 0 To TempPDFs.Length - 1
                Dim TempIOStr As System.IO.FileStream
                Dim TempPDF As Aspose.Pdf.Pdf
                Dim TempSec As Aspose.Pdf.Section

                TempIOStr = New System.IO.FileStream(TempPDFs(TempInd), FileMode.Open)
                TempPDF = New Aspose.Pdf.Pdf(TempIOStr)
                TempSec = New Aspose.Pdf.Section(TempPDF)

                myPDF_1.Sections.Add(TempSec)

            Next

            If File.Exists(MergedPDFName) Then File.Delete(MergedPDFName)
            myPDF_1.Close()
            myPDF_1.Save(MergedPDFName)

            If DeleteTempFiles = True Then
                For TempInd As Int32 = 0 To TempPDFs.Length - 1
                    If File.Exists(TempPDFs(TempInd)) Then File.Delete(TempPDFs(TempInd))
                Next
            End If

            myPDF = Nothing

        Catch ex As Exception
            MergedPDFName = "Error: " & ex.Message
        End Try

        Return MergedPDFName
    End Function


Viewing all articles
Browse latest Browse all 3131

Trending Articles