1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Dim newFile As String
Dim y As Single = System.Configuration.ConfigurationSettings.AppSettings("y")
Dim x As Single = System.Configuration.ConfigurationSettings.AppSettings("x")
Dim reader As PdfReader = New PdfReader(pdf_debut)
Dim size As Rectangle = reader.GetPageSizeWithRotation(1)
Dim document As Document = New Document(Size)
Dim fs As FileStream = New FileStream(newFile, FileMode.Create, FileAccess.Write)
Dim writer As PdfWriter = PdfWriter.GetInstance(Document, fs)
Document.Open()
Dim cb As PdfContentByte = writer.DirectContent()
Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
cb.SetColorFill(BaseColor.BLACK)
cb.SetFontAndSize(bf, 8)
' write the text in the pdf content
cb.BeginText()
Dim text As String = "Some random blablablabla..."
' put the alignment and coordinates here
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, text, x, y, 0)
cb.EndText()
Dim page As PdfImportedPage = writer.GetImportedPage(reader, 1)
cb.AddTemplate(page, 0, 0)
' close the streams and voil� the file should be changed :)
Document.Close()
fs.Close()
writer.Close() |
Partager