>This client wants to merge pdf files.
>There database-related logic in the algorithm that determines what files from what folders should be combined.
>I found one open source tool that claims to be able to do it, but there is no documentation and before I dive into it, I'm wondering if anyone has any better ideas?
>Thanks
If the tool is iTextsharper it definitely can do it. Google around and you'll find code on how to do it. If you get stuck let me know and I can show you my vb code. I am using iTextsharper to programmtically fill out 40 or so PDF forms and merge them into one big PDF. Not difficult at all to hook up.
(found it faster than I thought I would. this is the routine I am using to join the PDFs. i pass in the name of the masterPDF I want to create and an array of the names of the PDFs to be merged )_
Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.Collections.Generic
Public NotInheritable Class PDFJoiner
Public Shared Sub JoinPDFs(ByVal Masterpdf As String, ByVal sourcefiles As String())
Dim f As Integer = 0
Dim pword As Byte()
pword = Base.Utility.StrToByteArray("jellopudding")
Dim reader As New PdfReader(sourcefiles(0), pword)
Dim n As Integer = reader.NumberOfPages
Dim document As New Document(reader.GetPageSizeWithRotation(1))
Dim writer As PdfWriter = PdfWriter.GetInstance(document, New FileStream(Masterpdf, FileMode.Create))
document.Open()
Dim cb As PdfContentByte = writer.DirectContent
Dim page As PdfImportedPage
Dim rotation As Integer
f = 1
While f < sourcefiles.Length
Dim i As Integer = 0
While i < n
i += 1
document.SetPageSize(reader.GetPageSizeWithRotation(i))
document.NewPage()
page = writer.GetImportedPage(reader, i)
rotation = reader.GetPageRotation(i)
If rotation = 90 Or rotation = 270 Then
cb.AddTemplate(page, 0, -1, 1, 0, 0, reader.GetPageSizeWithRotation(i).Height)
Else
cb.AddTemplate(page, 1, 0, 0, 1, 0, 0)
End If
End While
System.Diagnostics.Debug.WriteLine("Processed document " & f & " - " & sourcefiles(f))
f += 1
If f < sourcefiles.Length Then
reader = New PdfReader(sourcefiles(f), pword)
n = reader.NumberOfPages
System.Diagnostics.Debug.WriteLine("There are " & n & " pages in the original file.")
End If
End While
document.Close()
End Sub
End Class
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.