Here is what I ended up with.
I used Adobe LiveCycle Designer to create the PDF form.
Create a webform to capture data from user.
Used ITextSharp to write the fields to a new PDF using the form as a
template.
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.xml
Dim pdfReader As New PdfReader(pdfTemplate)
Dim pdfStamper As New PdfStamper(pdfReader, New FileStream
(newFile, FileMode.Create))
Dim pdfFormFields As AcroFields = pdfStamper.AcroFields
pdfFormFields.SetField("form1[0].#subform[0]).City[0]",
txtCityStateZip.Text)
pdfFormFields.SetField("form1[0].#subform[0].Add1[0]",
txtAdd1.Text)
pdfFormFields.SetField("form1[0].#subform[0].Job[0]",
txtJob.Text)
pdfFormFields.SetField("form1[0].#subform[0].Attention[0]",
txtBrName.Text)
pdfFormFields.SetField("form1[0].#subform[0].Date[0]",
lbldate.Text)
pdfFormFields.SetField("form1[0].#subform[0].Name[0]",
txtCustomer.Text)
If cbResubmit.Checked = True Then
pdfFormFields.SetField("form1[0].#subform[0].Resubmit[0]",
"1")
End If
pdfStamper.FormFlattening = True
then opened the PDF so the user could print
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;
filename=filename")
Dim sourceFile As FileStream = New FileStream(newFile,
FileMode.Open)
Dim FileSize As Long = sourceFile.Length
Dim getContent(FileSize - 1) As Byte '= New Byte(FileSize)
sourceFile.Read(getContent, 0, sourceFile.Length)
sourceFile.Close()
Response.BinaryWrite(getContent)
On Aug 17, 6:51 pm, Peter Smith <[email protected]> wrote:
> Okay, so, after reading it through a couple of times, I think I understand.
>
> So there's a web page minimally populated from the DB. The user enters
> in a bunch more data, and rather than saving it to the DB again, you
> just want to preserve the visual image when they click a button, on
> paper and/or in a file.
>
> Given the environment...this seems fairly easy to do in an aspx page,
> and even put in some validation.
>
> 1. Page state #1, no job number; waits for user to enter one and click a
> button.
>
> <click for postback>
>
> 2. Page state #2, job number, skeleton data retrieved; waits for user
> to enter data and click a button.
>
> <click for postback>
>
> 3. If there is any validation to do, do it, and if validation fails,
> print messages to that effect, and go back to State #2. Otherwise,
> validation passes and..
>
> 4. Page state #3, user sees page without any input fields, and perhaps
> a 'please wait'. Codebehind reads all the data from the page, putting
> it into an object, and then uses that object to create aPDFin
> memory.PDFis then sent with a specific filename to the shared
> directory, and sent to the user's printer of choice. When saving and
> printing is all done, tell the user, and either just go to Page State
> #1, or give them a 'click here to continue' button (the latter would
> be annoying after a while, but you could give them the opportunity to
> print again if there was a problem outside of program control.