

<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Freely fill PDF form with the help of iText or iTextSharp</title>
	<atom:link href="http://blog.rubypdf.com/2007/08/01/freely-fill-pdf-form-with-the-help-of-itext-or-itextsharp/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rubypdf.com/2007/08/01/freely-fill-pdf-form-with-the-help-of-itext-or-itextsharp/</link>
	<description>PDF &#38; Marketing</description>
	<lastBuildDate>Tue, 27 Dec 2011 14:41:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: manojitc</title>
		<link>http://blog.rubypdf.com/2007/08/01/freely-fill-pdf-form-with-the-help-of-itext-or-itextsharp/comment-page-1/#comment-14285</link>
		<dc:creator>manojitc</dc:creator>
		<pubDate>Tue, 19 Jul 2011 07:01:12 +0000</pubDate>
		<guid isPermaLink="false">/2007/08/01/freely-fill-pdf-form-with-the-help-of-itext-or-itextsharp#comment-14285</guid>
		<description>we can fil any pdf using the following code.
The FillCell() fuction has few parameters which embed the text in the specified co-ordinate.
I am using  the edit function to stamp text in the existing Doc.pdf. 


public void EditPDF()
    {

        try
        {
            PdfReader reader = new PdfReader(Path.Combine(Server.MapPath(&quot;~/pdf&quot;), &quot;Doc.pdf&quot;));
           string sPdfName = Path.Combine(Server.MapPath(&quot;~/pdf&quot;), &quot;Doc221.pdf&quot;);
            //int n = reader.GetPageSize();

            PdfStamper stamp = new PdfStamper(reader, new FileStream(
                           sPdfName, FileMode.Create));

            PdfContentByte over;
            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);


            over = stamp.GetOverContent(1);
            //over = stamp.getUnderContent(i); 
            /*Image img = Image.getInstance(&quot;Blank.JPG&quot;); 
            img.setAbsolutePosition(170, 279); 
            over.addImage(img); 
            */
            over.BeginText();
            //over.setFontAndSize(bf, 18); 
            //over.setTextMatrix(30, 30); 
            //over.showText(&quot;page &quot; + i); 



            over.SetFontAndSize(bf, 10);
            FillCell(over, &quot;xyzabc&quot;, 280F, 692F);
            
            over.EndText();

            stamp.Close();
            reader.Close();
            return;
            
        }
        catch (Exception e)
        {
            //e.printStackTrace();
        }

    } 

    public void FillCell(PdfContentByte over,String sText,float x,float y) 
        { 
                try 
                { 

                        //System.out.println(sText.length()); 

                        float fx=x;; 
                                over.ShowTextAligned(1, sText, fx  , y, 0f);
                                return;
                        
                } 
                catch(Exception e) 
                { 
                        //e.printStackTrace(); 
                } 



        }</description>
		<content:encoded><![CDATA[<p>we can fil any pdf using the following code.<br />
The FillCell() fuction has few parameters which embed the text in the specified co-ordinate.<br />
I am using  the edit function to stamp text in the existing Doc.pdf. </p>
<p>public void EditPDF()<br />
    {</p>
<p>        try<br />
        {<br />
            PdfReader reader = new PdfReader(Path.Combine(Server.MapPath(&#8220;~/pdf&#8221;), &#8220;Doc.pdf&#8221;));<br />
           string sPdfName = Path.Combine(Server.MapPath(&#8220;~/pdf&#8221;), &#8220;Doc221.pdf&#8221;);<br />
            //int n = reader.GetPageSize();</p>
<p>            PdfStamper stamp = new PdfStamper(reader, new FileStream(<br />
                           sPdfName, FileMode.Create));</p>
<p>            PdfContentByte over;<br />
            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);</p>
<p>            over = stamp.GetOverContent(1);<br />
            //over = stamp.getUnderContent(i);<br />
            /*Image img = Image.getInstance(&#8220;Blank.JPG&#8221;);<br />
            img.setAbsolutePosition(170, 279);<br />
            over.addImage(img);<br />
            */<br />
            over.BeginText();<br />
            //over.setFontAndSize(bf, 18);<br />
            //over.setTextMatrix(30, 30);<br />
            //over.showText(&#8220;page &#8221; + i); </p>
<p>            over.SetFontAndSize(bf, 10);<br />
            FillCell(over, &#8220;xyzabc&#8221;, 280F, 692F);</p>
<p>            over.EndText();</p>
<p>            stamp.Close();<br />
            reader.Close();<br />
            return;</p>
<p>        }<br />
        catch (Exception e)<br />
        {<br />
            //e.printStackTrace();<br />
        }</p>
<p>    } </p>
<p>    public void FillCell(PdfContentByte over,String sText,float x,float y)<br />
        {<br />
                try<br />
                { </p>
<p>                        //System.out.println(sText.length()); </p>
<p>                        float fx=x;;<br />
                                over.ShowTextAligned(1, sText, fx  , y, 0f);<br />
                                return;</p>
<p>                }<br />
                catch(Exception e)<br />
                {<br />
                        //e.printStackTrace();<br />
                } </p>
<p>        }</p>
]]></content:encoded>
	</item>
</channel>
</rss>

