5

I want to use "OLE automation" (or whatever it's called now) to generate a Word document.

I assume that it's possible to perform the following programmatically:

Set page size (height, width, margin vals)
Set font type/name, style, and size
Add page numbering
Add pages
Insert page breaks

What I'm not sure of is if I need to have MS Word on my system to do this (to have the necessary DLLs, perhaps)? I use Open Office (I like it, and it's free), but I reckon controlling the creation of docs programmatically is probably easier/better documented for MS Word than it is for Open Office and/or Libre Office - that's why I'm strongly considering making this "rendezvous with Redmond."

This question is tangentially related to this one

If Google Docs is a possibility here, I'd be willing to have a "meeting with Mountain View" but I know nothing about that file format or whether it can be "automated" etc.

I need to end up with something that I can either convert to a PDF file or a DOCX file. Open Office can open DOCX and convert files to PDF, but I don't know about Google Docs.

Community
  • 1
  • 1
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

4 Answers4

7

I've found https://docx.codeplex.com/ to be very useful in dynamically building docx documents.

Chris W
  • 1,792
  • 15
  • 32
2

Yes, it is possible. Check this link: http://www.microsoft.com/en-us/download/details.aspx?id=30425 this is a library for open xml documents (*.docx, *.xlsx and powerpoint files)

Davecz
  • 1,199
  • 3
  • 19
  • 43
1

yes you can Use Openxml , also with openXml you can create Excel Pdf and ...

Check This out

Pouya Samie
  • 3,718
  • 1
  • 21
  • 34
  • Thanks; based on the blog post here: http://cathalscorner.blogspot.com/2010/06/cathal-why-did-you-create-docx.html (accessible from the link in the accepted answer), DocX seems the simplest solution. – B. Clay Shannon-B. Crow Raven Dec 24 '13 at 16:47
1

You can use this library to generate document by template: https://github.com/StasClick/DocumentGenerator

'DocumentGenerator' can generate one leaflet, multiple leaflets in one document or registers.

Stas BZ
  • 1,184
  • 1
  • 17
  • 36
  • It looks intriguing, but I wish it showed an example of what it actually produces; its' hard for me to visualize what it's doing. e.g., is the first call referencing an existing document, or creating a new one. The code is so minimal, it's difficult to imagine it doing much... – B. Clay Shannon-B. Crow Raven Apr 01 '16 at 14:53