Create PDF or image file from Intranet Client Side

7 views
Skip to first unread message

kathy30

unread,
Aug 4, 2009, 3:42:34 PM8/4/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I'm creating a universal form document that pulls from a database &
also allows user to enter or change information.
When complete they want to push the print button, automatically save
to a server directory as a PDF or image of the screen they just
entered and print to default printer.

I tried using ABCPDF but this will only allow the server side page to
be saved. I need the data they entered.

Thanks,

Peter Smith

unread,
Aug 12, 2009, 11:26:23 AM8/12/09
to DotNetDe...@googlegroups.com
Vagueness everywhere.

So, 'intranet' and 'client' and 'server'. A network is involved. Is
this web-based or forms-based? Or something else?

'want to push the print button'..where? What 'print button'? In an
app? On a page? From a browser menu? The print screen key combo on the
keyboard? What?

Without more clarity, I'd suggest you use a PDF printer to print the
screen image, and then have your app upload/copy to a server
directory. If you can share the drive, even better, just 'print pdf to
file' from the client machine to the shared server directory.

I'd probably use ActivePDF or Snagit, depending on where you're
putting the screen data and where it's coming from. Snagit can have a
profile configured to even respond to the print screen
button...capture a scrolling window to a PDF and ftp it to your
server.

kathy30

unread,
Aug 12, 2009, 1:29:07 PM8/12/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Peter, it is using our company intranet, web-base page that pulls data
from database once the user enters a job number.
They can then fill in other fields and I give them a button to print &
save this page(all behind the scenes). I want to create the file
location in code so the user can not mess it up. This would be save on
a shared directory for later reference. This has to be the page on
the user screen not the page on the server.

Hope this is more information and thanks in advance.

Peter Smith

unread,
Aug 17, 2009, 7:51:43 PM8/17/09
to DotNetDe...@googlegroups.com
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 a PDF in
memory. PDF is 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.

kathy30

unread,
Aug 26, 2009, 4:43:13 PM8/26/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
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 <psmith.w...@gmail.com> 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

Peter Smith

unread,
Aug 27, 2009, 12:32:50 PM8/27/09
to dotnetde...@googlegroups.com
Looks good. :) Now I'll get back to figuring out some way to
automatically/programmically add fields to an existing PDF based on
just filling up big empty boxes with text fields.

It's SO annoying to do by hand.

Reply all
Reply to author
Forward
0 new messages