Código vb:
Ver original
Dim ms As New System.IO.MemoryStream() Dim mod01 As New PdfReader(Server.MapPath("~/Mod01.pdf")) Dim stp01 As New PdfStamper(mod01, ms) With stp01.AcroFields .SetField("txtCodSolicitud", String.Format("{0:yyyyMMdd}{1}", Now, Session.SessionID.ToUpper)) ....... End With stp01.FormFlattening = True Dim mod02 As New PdfReader(Server.MapPath("~/Mod02.pdf")) Dim stp02 As New PdfStamper(mod02, ms) With stp02.AcroFields .SetField("txtNum", Me.ddlNum.SelectedValue) ........ End With stp02.FormFlattening = True Dim doc As New Document() Dim copia As New PdfCopy(doc, ms) doc.SetPageSize(PageSize.A4) doc.Open() copia.Open() Dim page As PdfImportedPage Dim n As Integer For n = 1 To mod01.NumberOfPages page = copia.GetImportedPage(mod01, n) copia.AddPage(page) Next For n = 1 To mod02.NumberOfPages page = copia.GetImportedPage(mod02, n) copia.AddPage(page) Next copia.Close() doc.Close() 'Se envía al cliente Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.AddHeader("Content-Disposition", "attachment;filename=Combinado.pdf") Response.BinaryWrite(ms.ToArray()) Response.End()
Gracias y un saludo.