Note that there are some explanatory texts on larger screens.

plurals
  1. POITextSharp include all pages from the input file
    primarykey
    data
    text
    <p>I used the following code by using itextsharp library to add text to a pdf.(got the code from link <a href="https://stackoverflow.com/questions/3992617/itextsharp-insert-text-to-an-existing-pdf">ITextSharp insert text to an existing pdf</a></p> <pre><code> Dim reader As New PdfReader(oldFile) Dim size As iTextSharp.text.Rectangle = reader.GetPageSizeWithRotation(1) Dim document As New iTextSharp.text.Document(size) ' open the writer Dim fs As New FileStream(newFile, FileMode.Create, FileAccess.Write) Dim writer As PdfWriter = PdfWriter.GetInstance(document, fs) document.Open() ' the pdf content Dim cb As PdfContentByte = writer.DirectContent ' select the font properties Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.ZAPFDINGBATS, BaseFont.CP1252, BaseFont.NOT_EMBEDDED) 'cb.SetColorFill(GrayColor.DARK_GRAY) cb.SetFontAndSize(bf, 8) cb.BeginText() Dim Text As String = "l" ' put the alignment and coordinates here cb.ShowTextAligned(2, Text, 84, 729, 0) cb.EndText() Dim bf1 As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED) cb.SetFontAndSize(bf1, 8) cb.BeginText() Dim text1 As String = "Navaneeth A" cb.ShowTextAligned(1, text1, 65, 690, 0) cb.EndText() ' create the new page and add it to the pdf 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() reader.Close() </code></pre> <p>Now the problem is source pdf has about 5 pages.But the output file generated by this code has only first page. So How can i include all pages of source file in output file? Source pdf link is <a href="http://law.incometaxindia.gov.in/DITTaxmann/IncomeTaxRules/PDF/Ay-2012-2013/SAHAJ2012_14.pdf" rel="nofollow noreferrer">http://law.incometaxindia.gov.in/DITTaxmann/IncomeTaxRules/PDF/Ay-2012-2013/SAHAJ2012_14.pdf</a></p> <hr> <pre><code> Dim reader As New PdfReader(oldFile) Using ms = New MemoryStream() Dim stamper As New PdfStamper(reader, ms) 'Using stamper 'As New PdfStamper(reader, ms) stamper.RotateContents = False Dim canvas As PdfContentByte = stamper.GetOverContent(1) ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, New Phrase("Hello people!"), 36, 540, 0) 'End Using Dim result As Byte() = ms.ToArray() File.WriteAllBytes(newFile, result) System.Diagnostics.Process.Start(newFile) End Using </code></pre> <p>I did the following changes,but its not working.result file was just a 1kb file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload