I want some help to generate a report in PDF/Doc(MS Word) format . I’m not able to find any module to generated report in doc, except “docx” which I’m not able to comprehend. Actually my actual task is to generate the report in Doc only, but as I’m not able to find a module to work on it, I opt for PDF. I’m using “Report Lab” module, but I’m finding some limitation in that. It write anything based on co-ordinate system. The problem I’m facing with that the report is usually a string, whose length is not limited, so sometime it goes beyond the canvas( Pdf Page). Also there is not functionality I guess to do format font with Bold, Italics and Underline.

If you know any module to generate report in PDF or Doc, please let me know. My requirement is:

Able to add an image at an header.
Change fonts and other properties, like Bold, Italics, and Underline
Able to draw basic shape like line
Write string, as a statement, as we are able to do with able to write into txt file using python(not on co-ordinate system basis)

Recommended Answers

All 2 Replies

For working directly through Word application, you could use pywin32 extensions:

# from: http://win32com.goermezer.de/content/view/173/192/
# install pywin32 from
# http://sourceforge.net/projects/pywin32/files/pywin32/
# reference for the [Word Object Model](http://msdn.microsoft.com/en-us/library/bb244515.aspx)
import win32com.client

wordapp = win32com.client.Dispatch("Word.Application") # Create new Word Object
wordapp.Visible = 0 # Word Application should`t be visible
worddoc = wordapp.Documents.Add() # Create new Document Object
worddoc.PageSetup.Orientation = 1 # Make some Setup to the Document:
worddoc.PageSetup.LeftMargin = 20
worddoc.PageSetup.TopMargin = 20
worddoc.PageSetup.BottomMargin = 20
worddoc.PageSetup.RightMargin = 20
worddoc.Content.Font.Size = 11
worddoc.Content.Paragraphs.TabStops.Add (100)
worddoc.Content.Text = "Hello, I am a text!"
worddoc.Close() # Close the Word Document (a save-Dialog pops up)
wordapp.Quit() # Close the Word Application

Thanks man, that is really helpful:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.