Torna al Thread
If IO.File.Exists(Me.Server.MapPath("~/Pro/" & Date.Today.Year & "/" & ListBox1.SelectedValue & ".jpg")) Then
Dim documento As Document = New Document(iTextSharp.text.PageSize.A4, 1, 0, 0, 0)
PdfWriter.GetInstance(documento, New IO.FileStream(Me.Server.MapPath("~/Pro/" & Date.Today.Year & "/" & ListBox1.SelectedValue & ".pdf"), IO.FileMode.Create))
documento.AddTitle("Protocollo")
documento.AddAuthor("autore")
documento.AddCreator("Data Protocollo")
documento.AddSubject("File di protocollo")
documento.AddProducer()
documento.Open()
Dim Paragraph As Paragraph = New Paragraph("TIMES_ROMAN", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.TIMES_ROMAN, iTextSharp.text.BaseColor.LIGHT_GRAY))
documento.Add(New Paragraph(" Copia Conforme all'originale"))
Dim img As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Me.Server.MapPath("~/Pro/" & Date.Today.Year & "/" & ListBox1.SelectedValue & ".jpg"))
img.ScalePercent(48)
documento.Add(img)
For i As Integer = 1 To 20
If IO.File.Exists(Me.Server.MapPath("~/Pro/" & Date.Today.Year & "/" & ListBox1.SelectedValue & "_" & i & ".jpg")) Then
Paragraph = New Paragraph("TIMES_ROMAN", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.TIMES_ROMAN, iTextSharp.text.BaseColor.LIGHT_GRAY))
documento.Add(New Paragraph(" Copia Conforme all'originale"))
img = iTextSharp.text.Image.GetInstance(Me.Server.MapPath("~/Pro/" & Date.Today.Year & "/" & ListBox1.SelectedValue & "_" & i & ".jpg"))
img.ScalePercent(48)
documento.Add(img)
End If
Next
documento.Close()
Response.Expires = -1
Dim strPath As String
strPath = Me.Server.MapPath("~/Pro/" & Date.Today.Year & "/" & ListBox1.SelectedValue & ".pdf")
Dim File = New IO.FileInfo(strPath)
If File.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=""" & "Protocollo " & File.Name & """")
Response.AddHeader("Content-Length", File.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.TransmitFile(strPath)
Response.End()
Else
Response.Write("File non trovato.")
End If
End If