Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- ' Creamos una lista de archivos para concatenar
- Dim Lista As New List(Of String)
- ' Identificamos los documentos que queremos unir
- Dim sFile1 As String = “C:\Users\Lap\Documents\Visual Studio 2015\Projects\PDF\Cotizacion.pdf”
- Dim sFile2 As String = “C:\Users\Lap\Documents\Visual Studio 2015\Projects\PDF\Cotizacion.pdf”
- ' Los añadimos a la lista
- Lista.Add(sFile1)
- Lista.Add(sFile2)
- ' Nombre del documento resultante
- Dim sFileJoin As String = “C:\Users\Lap\Documents\Visual Studio 2015\Projects\PDF\\DocumentoJoin.pdf”
- Dim Doc As New Document()
- Try
- Dim fs As New FileStream(sFileJoin, FileMode.Create, FileAccess.Write, FileShare.None)
- Dim copy As New PdfCopy(Doc, fs)
- Doc.Open()
- Dim Rd As PdfReader
- Dim n As Integer 'Número de páginas de cada pdf
- For Each file In Lista
- Rd = New PdfReader(file)
- n = Rd.NumberOfPages
- Dim page As Integer = 0
- Do While page < n
- page += 1
- copy.AddPage(copy.GetImportedPage(Rd, page))
- Loop
- copy.FreeReader(Rd)
- Rd.Close()
- Next
- Catch ex As Exception
- MsgBox(ex.Message, vbExclamation, “Error uniendo los pdf”)
- Finally
- ' Cerramos el documento
- Doc.Close()
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement