本文整理汇总了Python中Output.Output.setOutputType方法的典型用法代码示例。如果您正苦于以下问题:Python Output.setOutputType方法的具体用法?Python Output.setOutputType怎么用?Python Output.setOutputType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Output.Output
的用法示例。
在下文中一共展示了Output.setOutputType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Output import Output [as 别名]
# 或者: from Output.Output import setOutputType [as 别名]
class ExecuteConverter:
def __init__(self):
self.__resultTuple = None
def extractTables(self, path, target):
"""
Starts the table extraction. Using only this method, nothing will be returned,
but the HTML output Files will be created in the specified output folder.
"""
try:
os.mkdir(target)
except OSError:
pass
os.chdir(target)
self.__dtdFile = open(target + "/pdf2xml.dtd", "w")
self.buildDtd()
self.__cmdLine = "pdftohtml -xml " + path
print(self.__cmdLine)
os.system(self.__cmdLine)
xmlFile = os.path.basename(path).rstrip(".pdf") + ".xml"
fileMover.moveXmlFile(path = path, target = target)
#starting the extraction
firstClassification = FirstClassification(target)
self.__resultTuple = firstClassification.run(target + "/" + xmlFile)
tableList = self.__resultTuple[0]
fontsList = self.__resultTuple[1]
path = self.__resultTuple[2]
self.__outputObj = Output(tableList, fontsList, path)
self.__outputObj.createOutput()
def getTableList(self, outputTypeObj = GetOutputStringIOList()):
"""
Return a list. The output type depends of the parameter.
The default return type is a list of stringIO's containing the content of
the generate HTML output files
"""
self.__outputObj.setOutputType(outputTypeObj)
outputFilesList = self.__outputObj.getOutputList()
return outputFilesList
def buildDtd(self):
dtd = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" + \
"<!ELEMENT pdf2xml (page+,line*,fontspec*)>\n" + \
"<!ELEMENT page (fontspec*, text*)>\n" + \
"<!ATTLIST page\n" + \
"number CDATA #REQUIRED\n" + \
"position CDATA #REQUIRED\n" + \
"top CDATA #REQUIRED\n" + \
"left CDATA #REQUIRED\n" + \
"height CDATA #REQUIRED\n" + \
"width CDATA #REQUIRED\n" + \
">\n" + \
"<!ELEMENT fontspec EMPTY>\n" + \
"<!ATTLIST fontspec\n" + \
"id CDATA #REQUIRED\n" + \
"size CDATA #REQUIRED\n" + \
"family CDATA #REQUIRED\n" + \
"color CDATA #REQUIRED\n" + \
">\n" + \
"<!ELEMENT text (#PCDATA | b | i)*>\n" + \
"<!ATTLIST text\n" + \
"top CDATA #REQUIRED\n" + \
"left CDATA #REQUIRED\n" + \
"width CDATA #REQUIRED\n" + \
"height CDATA #REQUIRED\n" + \
"font CDATA #REQUIRED\n" + \
">\n" + \
"<!ELEMENT b (#PCDATA)>\n" + \
"<!ELEMENT i (#PCDATA)>\n" + \
"<!ELEMENT line (text+)>\n" + \
"<!ATTLIST line\n" + \
"typ CDATA #REQUIRED\n" + \
"top CDATA #REQUIRED\n" + \
"left CDATA #REQUIRED\n" + \
"font CDATA #REQUIRED\n" + \
">"
self.__dtdFile.write(dtd)
self.__dtdFile.close()