Hello
I'm using ITextSharp Version 4.0.8.0. I create array of PDF Memory
Streams and once complete merge them into one document with page number
breaks on a master number. I was asked to add a signature to one of
the forms templates. I did that using a transparent gif and the stamper
tool in Adobe. When I fill the form out with a PdfStamper the form
looks great. When I take that filled out form and merge it using the
code below, the signature stamp disappears.
##Creation of document
Dim memoryStream As New System.IO.MemoryStream
Dim filename As String
filename = Server.MapPath("../forms/SigForm001.pdf")
Dim ds As DataSet
Dim row As DataRow
Dim drdReader As IDataReader
Dim bllForms As New BLL.bllForms
bllForms.GetDocumentData(drdReader, "1653254")
Try
Dim reader As New PdfReader(filename)
Dim n As Integer = reader.NumberOfPages
drdReader.Read
' filling in the form
Dim stamp1 As New PdfStamper(reader, memoryStream)
Dim form1 As AcroFields = stamp1.AcroFields()
With form1
.SetField("First_Name-Copy",
drdReader.Item("FirstName"))
.SetField("First_Name-Org",
drdReader.Item("FirstName"))
.SetField("Last_Name-Copy",
drdReader.Item("LastName"))
.SetField("Last_Name-Org",
drdReader.Item("LastName"))
End With
stamp1.FormFlattening = True
stamp1.SetFullCompression()
stamp1.Close()
ArrayOfFiles(0) = memoryStream
At this point if I output the memory stream to a PDF it looks great.
The Signiture stamp is there and all the filed out fields. I then call
call MergeFiles to merge all the PDFs that need to be in the one
document.
Public Function MergeFiles(ByVal sourceFiles() As MemoryStream)
As MemoryStream
Dim memoryStream As New System.IO.MemoryStream
Dim f As Integer = 0
Dim reader As New PdfReader(New
RandomAccessFileOrArray(sourceFiles(f).ToArray), Nothing)
Dim n As Integer = reader.NumberOfPages
Dim document As New
document(reader.GetPageSizeWithRotation(1))
Dim writer As PdfWriter = PdfWriter.GetInstance(document,
memoryStream)
document.Open()
Dim cb As PdfContentByte = writer.DirectContent
Dim page As PdfImportedPage
Dim rotation As Integer
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.0F, 1.0F, 0, 0,
reader.GetPageSizeWithRotation(i).Height)
Else
cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0)
End If
End While
writer.FreeReader(reader)
f += 1
If f < sourceFiles.Length Then
If sourceFiles(f) Is Nothing Then Exit While
reader = New PdfReader(New
RandomAccessFileOrArray(sourceFiles(f).ToArray), Nothing)
n = reader.NumberOfPages
End If
If f < sourceFiles.Length Then sourceFiles(f).Close()
End While
document.Close()
Return memoryStream
End Function 'MergeFiles
At this point the document loses the stamped signature.
Thanks in advance for any suggestions.
Cheers,
Mark
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php