Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how to combine pdf files into one file, in a directory I have some pdf files that I want to combine into 1 file

I use the following code:

VB
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim filePaths As String() = System.IO.Directory.GetFiles(path)
     
        For Each fileName As [String] In filePaths
            Dim targetFolder As String = path
            Dim fi As New System.IO.FileInfo(fileName)
            'fi.CopyTo(System.IO.Path.Combine(path, (fi.Name) & ".pdf"), True)
            Label1.Text = filePaths.Length
            alList.Add(fileName)
        Next
        CombineReport(alList, path)
    End Sub

    Public Shared Function CombineReport(ByVal pdfFiles As IList, ByVal pdfFile As String) As String
        Try
            Dim sb As New System.Text.StringBuilder()
            For Each o As Object In pdfFiles
                sb.Append(o.ToString())
                sb.Append(" ")
            Next
            sb.AppendFormat("cat output {0} allow printing dont_ask", pdfFile)
            System.Diagnostics.Process.Start("C:\WINDOWS\system32\pdftk", sb.ToString()).WaitForExit()
                        
            Return pdfFile
        Catch ex As Exception
            Throw ex
        End Try
    End Function
End Class


but the source code is not nothing changed, please help if anyone knows me out of this problem
Posted
Updated 16-Sep-13 17:48pm
v2
Comments
Menon Santosh 17-Sep-13 0:12am    
use itextsharp for this purpose

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900