Click here to Skip to main content
11,926,805 members (53,296 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET PDF Forms
I need to create a ASP.NET page that needs to get information from the user using ASP.NET text fields, CheckBox and RadioButton and fill-it to PDF fields. the PDF file is a contract for buy.

I need a way in which can take the information filled by the user, and fill it to the PDF, and make it available for the user to download, and the save PDF file in database after fill it.

I have already PDF file with some fields in PDF should be filled by user, the user who use this page will fill some textbox(s) and there are checkBox(s) & RadioBoutton(s), foe example, in ASP page he fill his full name and submit , the page will appear a link contain the pdf file and in the field for the name we will found the name that he typed in asp page. I hope my idea is clear to all,

I hope find answer, thanks for your Efforts all : )

this is the file that I want to filling it by ASP page c# code:

Posted 12-Jan-13 22:42pm
Edited 14-Jan-13 19:05pm
Plyswthsqurles 13-Jan-13 3:48am
What have you tried? Can you provide a code snippet or something to show that you've at least given it a shot?

Take a look at either itextsharp or PDFsharp for PDF manipulation...this imo will be the easiest way to go about doing what you need.
Member 8729465 13-Jan-13 4:00am
sorry I dont have a code snippet, my question about filling pdf forms by C#
how can I do that ?!
I dont want to create pdf file , I want filling already file created.

I hope find answer

thanx all

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


u can write to existing PDF by using iTextSharp. I have worked on the problem you have mentioned. so go with these posts

Creating PDF documents with iTextSharp[^]

Creating PDF Tables using C# (.NET 2.0) and iTextSharp[^]
Member 8729465 13-Jan-13 4:09am
thanx for your efforts, I am sorry but I need to fill fields in pdf not create new one.
I have a pdf file with many text fields and checkbox,

how can I fill it auto by C# ?
Faisalabadians 13-Jan-13 4:12am
links are given you to see how to write to PDF. once you know the API of iTextSharp you can write to your existing field. if you still can do any thing, give me PDF file, i will show you little code for doing that.
Member 8729465 13-Jan-13 4:52am
how can I send to you the file ?
Faisalabadians 13-Jan-13 9:10am
you can upload file in your question.
Member 8729465 13-Jan-13 9:17am
I uploaded it in Question
Faisalabadians 13-Jan-13 9:22am
ok, let me install VS and iTextSharp and PDF as i have installed fresh window
Simple Developer 13-Jan-13 9:23am
Ok , I will wait you :)
Faisalabadians 13-Jan-13 9:25am
i will definitely send you this 14-01-2013 in morning according to PST. sorry for extra wait
Simple Developer 15-Jan-13 0:04am
I am still wait any one to help me :(
Faisalabadians 15-Jan-13 1:30am
hi, I have prepared example for you, but don't know how to upload it in answer :(
Simple Developer 17-Jan-13 13:40pm
thank you for your reply,
upload it in any site, as WINRAR file and put the link,
thank for your efforts.
Simple Developer 17-Jan-13 13:42pm
thank you for your reply, upload it in any site, as WINRAR file and put the link, thank for your efforts.
Faisalabadians 18-Jan-13 5:24am
use itextsharp.dll and itextsharp.pdfa.dll to use this code.

string ReportPath = Application.StartupPath.ToString() + @"\File.pdf";
string SavingPath = Application.StartupPath.ToString() + @"\FileAfterStamped.pdf";

PdfReader PDFReader = new PdfReader(new FileStream(ReportPath, FileMode.Open, FileAccess.Read));
PdfStamper PDFStamper = new PdfStamper(PDFReader, new FileStream(SavingPath, FileMode.Create));
PdfContentByte PDFContentByte = PDFStamper.GetOverContent(1);

BaseFont ReportFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
PDFContentByte.SetFontAndSize(ReportFont, 10);

PDFContentByte.SetTextMatrix(242.91f, 748.89f);

PDFContentByte.SetTextMatrix(330.30f, 748.89f);

Simple Developer 18-Jan-13 9:02am
thank you so much for your helping,
please I needs to explain this code for me ,
so, how the information in the textbox will be filling in the pdf file?
I understand from code that will open pdf file and read it
and then ?
sorry for asking again and again, but I need to learn.
Simple Developer 18-Jan-13 9:15am
what the reference should be used for this "StartupPath"
Faisalabadians 21-Jan-13 0:49am
PdfContentByte PDFContentByte = PDFStamper.GetOverContent(1); << means go to page 1 in the pdf file

BaseFont ReportFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); << create font

PDFContentByte.SetFontAndSize(ReportFont, 10); << use created font with specified text size i.e 10

PDFContentByte.SetTextMatrix(242.91f, 748.89f); << x, y pixels of the page where you want to write.

PDFContentByte.ShowText("iTextSharp"); << the text you want to be appear
Simple Developer 21-Jan-13 8:17am
thank you so much :),
I accept this solution and it is useful for my problem.
Faisalabadians 21-Jan-13 8:51am
thanks but this should meet your requirements... the same thing I did some days ago
Simple Developer 21-Jan-13 9:56am
if I have any question else about this problem in future, can I ask you here again ?
Faisalabadians 21-Jan-13 10:31am
sure... you can
Simple Developer 22-Jan-13 6:38am
I have a Question please,
how can I create like the file I attached to you,
Because it secured, how can create like it ?
Faisalabadians 22-Jan-13 7:08am
not know as worked on files which were not password protected.. you can see this >>

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100