Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My requirement is

1. Want to insert a multi-line text in existing pdf.
2. If iam having more than 1 pdf, how it is possible to insert text in more than 1 pdf.

I have given my code, Here iam getting as single line text in pdf output even after adding vbnewline in coding. Not as multi-line,How is it possbile ?
and also about multi-page insert text. Kindly provide me a solution from below code
VB
 Public Function pdfwrite()
    Dim newFile As String = "D:\Temp\new.pdf"
    Dim oldfile as string = "D:\Temp\old.pdf"
    Dim reader As New PdfReader(oldfile)
    Dim size As Rectangle = reader.GetPageSizeWithRotation(1)
    Dim Document As 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.DARK_GRAY)
    cb.SetFontAndSize(bf, 8)
    cb.BeginText()
    stext = " Section:Similar • type :Feature • support:60000 •  count:127 • " & vbNewLine & "Size:544.02" & vbNewLine & "ID:807"
    cb.ShowTextAligned(1, stext, 320, 80, 0)
    cb.EndText()
    Dim page As PdfImportedPage = writer.GetImportedPage(reader, 1)
    cb.AddTemplate(page, 0, 0)
    Document.Close()
    Fs.Close()
    writer.Close()
    reader.Close()
    Return 0
End Function
Posted
Updated 18-Nov-15 21:55pm
v2
Comments
JPRASAD89 24-Jan-18 10:21am    
pl.send me code full code ,... i need to add some text on first page of every pdf ,, help me ..
thank u

1 solution

I am not sure that PDF writers take account of newline characters. Looking at http://itextpdf.com/examples/iia.php?id=246[^] I think you need to add each line part separately.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900