|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
How to fill a PDF form for multiple users?I have the following code from sample I've seen somewhere and it's working but there is a concern.
protected void Button1_Click(object sender, EventArgs e) { string formFile = Server.MapPath("~/PDF/" + "formPrintable_src.pdf"); string newFile = Server.MapPath("~/PDF/" + "formPrintable_out.pdf"); PdfReader reader = new PdfReader(formFile); PdfStamper stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Create)); AcroFields fields = stamper.AcroFields; //gather controls information //set form fields fields.SetField("TextField1", TextBox1.Text); fields.SetField("TextField2", TextBox2.Text); if (cblGender.SelectedValue == "Male") { fields.SetField("chbMale", "1"); } else if (cblGender.SelectedValue == "Female") { fields.SetField("chbFemale", "1"); } //set document info Hashtable info = new Hashtable(); info["Title"] = "Modified Form"; info["Auther"] = "Dolly"; info["Creator"] = "My Web App"; stamper.MoreInfo = info; //flatten form fields and closed document stamper.FormFlattening = true; stamper.Close(); } The concern is, if multiple users are filling the form at the same time and saving them, I'm afraid that whoever saves last will overwrite the previous version since there is only one _out.pdf file on the server. Is there a better way to implement this so that multiple users can fill out the form and each person will have their own unique pdf file to download or print? |
|
|
Re: How to fill a PDF form for multiple users?Create a temporary file with a random name or create the file in memory.
This is not really about iTextSharp. Paulo ----- Original Message ----- From: "ljCharlie" <ljCharlie@...> To: <itextsharp-questions@...> Sent: Wednesday, May 14, 2008 4:38 PM Subject: [itextsharp-questions] How to fill a PDF form for multiple users? > > I have the following code from sample I've seen somewhere and it's working > but there is a concern. > > protected void Button1_Click(object sender, EventArgs e) > { > string formFile = Server.MapPath("~/PDF/" + > "formPrintable_src.pdf"); > string newFile = Server.MapPath("~/PDF/" + > "formPrintable_out.pdf"); > > PdfReader reader = new PdfReader(formFile); > PdfStamper stamper = new PdfStamper(reader, new FileStream(newFile, > FileMode.Create)); > AcroFields fields = stamper.AcroFields; > > //gather controls information > > //set form fields > fields.SetField("TextField1", TextBox1.Text); > fields.SetField("TextField2", TextBox2.Text); > if (cblGender.SelectedValue == "Male") > { > fields.SetField("chbMale", "1"); > } > else if (cblGender.SelectedValue == "Female") > { > fields.SetField("chbFemale", "1"); > } > > //set document info > Hashtable info = new Hashtable(); > info["Title"] = "Modified Form"; > info["Auther"] = "Dolly"; > info["Creator"] = "My Web App"; > stamper.MoreInfo = info; > > //flatten form fields and closed document > stamper.FormFlattening = true; > stamper.Close(); > } > > The concern is, if multiple users are filling the form at the same time > and > saving them, I'm afraid that whoever saves last will overwrite the > previous > version since there is only one _out.pdf file on the server. Is there a > better way to implement this so that multiple users can fill out the form > and each person will have their own unique pdf file to download or print? ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ itextsharp-questions mailing list itextsharp-questions@... https://lists.sourceforge.net/lists/listinfo/itextsharp-questions |
|
|
Re: How to fill a PDF form for multiple users?Yes, this is not a iTextsharp issue; however, the method that iTextsharp uses does not work in asp.net or C# environment. It has been almost three months and no one in the asp.net forum is able to help me create a temporary file. The way I understand it is that the temporary out file that itextsharp uses will have to be exactly the same as the formPrintable_src.pdf (source) file for it to work. So I'm not sure how is that going to be done in C# or asp.net. Again, you're right it's not itextsharp issue but since no in asp.net is able to help me, perhaps there are other alternatives itextsharp would be able accomplish the same goal without requiring two source and out file. Let's say, is it possible for itextsharp to use just the source file to fill all the information and then prompt for the user to save the PDF file as as a new file name on the client's machine?
Many thanks in advance! By the way, here's the thread I post about this issue in asp.net forum. http://forums.asp.net/t/1262298.aspx Charlie
|
| Free Forum Powered by Nabble | Forum Help |