Click here to Skip to main content
Rate this: bad
good
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:
File
 

 

 

 

 
...
Posted 12-Jan-13 22:42pm
Edited 14-Jan-13 19:05pm
v6
Comments
Plyswthsqurles at 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 at 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
good
Please Sign up or sign in to vote.

Solution 1

HI
 
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[^]
  Permalink  
Comments
Member 8729465 at 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 at 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 at 13-Jan-13 4:52am
   
how can I send to you the file ?
Faisalabadians at 13-Jan-13 9:10am
   
you can upload file in your question.
Member 8729465 at 13-Jan-13 9:17am
   
I uploaded it in Question
Faisalabadians at 13-Jan-13 9:22am
   
ok, let me install VS and iTextSharp and PDF as i have installed fresh window
Simple Developer at 13-Jan-13 9:23am
   
Ok , I will wait you :)
Faisalabadians at 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 at 15-Jan-13 0:04am
   
I am still wait any one to help me :(
Faisalabadians at 15-Jan-13 1:30am
   
hi, I have prepared example for you, but don't know how to upload it in answer :(
Simple Developer at 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 at 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 at 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);

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

PDFContentByte.SetTextMatrix(242.91f, 748.89f);
PDFContentByte.ShowText("iTextSharp");
 
PDFContentByte.SetTextMatrix(330.30f, 748.89f);
PDFContentByte.ShowText("C#.Net");
 

 
PDFContentByte.EndText();
PDFStamper.Close();
Simple Developer at 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 at 18-Jan-13 9:15am
   
what the reference should be used for this "StartupPath"
Faisalabadians at 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 at 21-Jan-13 8:17am
   
thank you so much :),
I accept this solution and it is useful for my problem.
Faisalabadians at 21-Jan-13 8:51am
   
thanks but this should meet your requirements... the same thing I did some days ago
Simple Developer at 21-Jan-13 9:56am
   
if I have any question else about this problem in future, can I ask you here again ?
Faisalabadians at 21-Jan-13 10:31am
   
sure... you can
Simple Developer at 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 at 22-Jan-13 7:08am
   
not know as worked on files which were not password protected.. you can see this >> http://www.rowellbelen.com/content/unlocking-password-protected-pdf-using-itext-library

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 DamithSL 165
4 Tomas Takac 144
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2014
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