java - How to print docx and pdf? -


i can print using txt file printer, however, when change docx or pdf many undefined characters cannot understood @ all. guys have ideas on how solve this.

the code used.

import system import javax.print import java.io java.lang import thread  filestream = java.io.bufferedinputstream(java.io.fileinputstream("c:/geeks.txt"))  psinformat = javax.print.docflavor.input_stream.autosense  mydoc = javax.print.simpledoc(filestream,psinformat,none)  aset = javax.print.attribute.hashprintrequestattributeset() aset.add(javax.print.attribute.standard.copies(2))  services = javax.print.printservicelookup.lookupdefaultprintservice()  job = services.createprintjob()  job.print(mydoc, none)  thread.sleep(20000)  filestream.close() 

.docx files have far more formatting , nonsense going on text file. open 1 using notepad , you'll see i'm talking about.

because of this, you'll need use dedicated library read docx file, such https://pypi.python.org/pypi/docx/0.2.4

this library provides nice way extract text docx file:

example-extracttext.py 'some word file.docx' 'new file.txt'


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -