Forum Moderators: open

Message Too Old, No Replies

Brainstorming ideas for printing multiple Word documents from ASP.NET

Creating Word documents on-the-fly using bookmarks and I need to print them

         

bhonda

2:12 pm on Jun 6, 2006 (gmt 0)

10+ Year Member



Hey guys...

Been presented with a task, and I don't really know where to start, so I was hoping you lot could throw some ideas about that I could experiment with.

Basically, I have a number of Microsoft Word templates, with Bookmarks defined in them. I also have an ASP.NET site that, at the moment, populates the bookmarks of the selected template and prints it out.

This is ok, but not great. I need some way to preview the document before printing it, and maybe even allow the user to fine-tune the document (correct any mistakes, etc). The user needs to then choose whether or not to print, and choose where to print to (ie, which network printer)

The server I'm working on has Word and PDF capabilities, on a local Intranet.

Has anyone had experience with this, or got any helpful suggestions? I'm not really looking for a specific implementation here, but rather a broad range of ideas that I can investigate. Only then will I start a new thread begging for help!

Cheers guys - appreciate anything you have!

B

TheNige

8:19 pm on Jun 8, 2006 (gmt 0)

10+ Year Member



Well, basically if you generate the initial document for them and then stream it to the user's browser it will prompt them to open it. They can then view and edit the document, which is their own copy of it, and then print it to where ever they want using the standard print dialog in Word.

If you wanted their changes to be saved back to the server then that would be a lot more tricky.

oxbaker

8:44 pm on Jun 8, 2006 (gmt 0)

10+ Year Member



if your going to allow edits to word docs, you need a version control system. and thats expensive to buy and complicated to build. I suggest looking at things your company may already have. like sharePoint? That would fit the bill for this nicely.

hth,
mcm

bhonda

3:52 pm on Jun 12, 2006 (gmt 0)

10+ Year Member



Cheers guys,

Finished tweaking my solution last Friday - I've ended up using the Microsoft Office Document Printer to produce the document, then the user is prompted to save the document, then they can print it, or leave it.

Not actually put this live yet, but works pretty well!

Cheers for the advice,

B

bhonda

11:04 am on Jun 15, 2006 (gmt 0)

10+ Year Member



...Ok....changed my mind!

I'm now going with the whole streaming to the browser thang.

Basically, the code I'm using is as follows....(where doc is the contents of the document to be printed, as a string)


Response.ContentType = "application/msword";
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] b = enc.GetBytes(doc); /* doc is the contents of the document to be displayed */
MemoryStream imgData = new MemoryStream(b,true);
Byte[] LogoOuput = imgData.ToArray();
Response.AddHeader("Content-Disposition", inline;filename=Report");
Response.OutputStream.Write(LogoOuput,0,LogoOuput.Length);
Response.End();

Rather easy!

B