Connecting Tech Pros Worldwide Forums | Help | Site Map

creating a word doc using javascript

Newbie
 
Join Date: Oct 2008
Posts: 29
#1: Dec 23 '08
Hi y'all

I've been trying to print a book with articles straight from the database.
Each page has 2 articles with a picture, more info and it's subarticles.
I want to have an index table and the pages should be numbered.

When they click on a button on the website, this document should be printed.
If i use for example a PDF, or send it straight to the printer, well, then I don't have the markup (page numbers, index table, sometimes only one article on one page (too much subarticles for example))

MS Word would do the markup automatically.
right now i'm 'playing' with the word ocx to obtain this.

I've been searching for the right activeX component, but can't find the perfect one.

Anybody can help me with my search? or provide other options (maybe some options I don't know about)


Thanks i advance

Tomas

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,750
#2: Dec 23 '08

re: creating a word doc using javascript


Are you using IE only? If not, I would suggest using a print stylesheet where you can control how the page is printed. See A List Apart: Articles: CSS Design: Going to Print and Print Stylesheets - css-discuss.
Newbie
 
Join Date: Oct 2008
Posts: 29
#3: Dec 23 '08

re: creating a word doc using javascript


I checked into this possibility, but it didn't seem the right thing to do because I can't know how many items can be printed on one page.
Only word formats them in pages and has a correct index table.

This explanation was quite interesting:
Paged media

But it's CSS21, and I will be only using Internet Explorer.
Some might still use ie 5.0... :(
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,750
#4: Dec 23 '08

re: creating a word doc using javascript


If you will be using only IE, look into Meadroid - an ActiveX control to control printing.
Newbie
 
Join Date: Jan 2009
Posts: 5
#5: Jan 19 '09

re: creating a word doc using javascript


you can convert word to pdf(with java):
Expand|Select|Wrap|Line Numbers
  1. import officetools.OfficeFile;
  2. FileInputStream fis = new FileInputStream(new File("test.doc"));
  3. FileOutputStream fos = new FileOutputStream(new File("test.pdf"));
  4. OfficeFile f = new OfficeFile(fis,"localhost","8100", false);
  5. f.convert(fos,"pdf");
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 4,300
#6: Jan 19 '09

re: creating a word doc using javascript


Quote:

Originally Posted by htll View Post

you can convert word to pdf(with java):

unfortunately the request was to use Javascript (that is something totally different to Java).
Newbie
 
Join Date: Jan 2009
Posts: 5
#7: Jan 19 '09

re: creating a word doc using javascript


Yes, but JavaScript takes action in the browser only, so it can not touch MS Word files.
All he can do is to convert to pdf BEFORE sending the pdf to the visitor's browser.
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 4,300
#8: Jan 19 '09

re: creating a word doc using javascript


true, maybe the best option is to use a "print" button which is a) getting the pdf and b) triggering the printing
Reply