当前位置: 首页>>代码示例>>Python>>正文


Python Output.setOutputType方法代码示例

本文整理汇总了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()
开发者ID:B-Rich,项目名称:pypdf2table,代码行数:84,代码来源:ExecuteConverter.py


注:本文中的Output.Output.setOutputType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。