예제 #1
0
    def __init__(self):
        dataDir = Settings.dataDir + "programming_documents/"

        # Load the document.
        doc = Document(dataDir + "tableDoc.doc")

        # Get the first table in the document.
        firstTable = doc.getChild(NodeType.TABLE, 0, True)

        # We will split the table at the third row (inclusive).
        row = firstTable.getRows().get(2)

        # Create a new container for the split table.
        table = firstTable.deepClone(False)

        # Insert the container after the original.
        firstTable.getParentNode().insertAfter(table, firstTable)

        # Add a buffer paragraph to ensure the tables stay apart.
        firstTable.getParentNode().insertAfter(Paragraph(doc), firstTable)

        currentRow = ""

        while currentRow != row:
            currentRow = firstTable.getLastRow()
            table.prependChild(currentRow)

        doc.save(dataDir + "SplitTable.doc")

        print "Done."
    def __init__(self):
        dataDir = Settings.dataDir + 'programming_documents/'

        # Load the document.
        doc = Document(dataDir + "tableDoc.doc")

        # Get the first table in the document.
        firstTable = doc.getChild(NodeType.TABLE, 0, True)

        # We will split the table at the third row (inclusive).
        row = firstTable.getRows().get(2)

        # Create a new container for the split table.
        table = firstTable.deepClone(False)

        # Insert the container after the original.
        firstTable.getParentNode().insertAfter(table, firstTable)

        # Add a buffer paragraph to ensure the tables stay apart.
        firstTable.getParentNode().insertAfter(Paragraph(doc), firstTable)

        currentRow = ''

        while (currentRow != row):
            currentRow = firstTable.getLastRow()
            table.prependChild(currentRow)

        doc.save(dataDir + "SplitTable.doc")

        print "Done."
    def __init__(self):
        self.dataDir = Settings.dataDir + 'rendering_printing/'

        # Load the documents which store the shapes we want to render.
        doc = Document(self.dataDir + "TestFile.doc")
        doc2 = Document(self.dataDir + "TestFile.docx")

        # Retrieve the target shape from the document. In our sample document this is the first shape.
        shape = doc.getChild(NodeType.SHAPE, 0, True)
        drawingML = doc2.getChild(NodeType.SHAPE, 0, True)

        # Test rendering of different types of nodes.
        self.render_shape_to_disk(shape)
        self.render_shape_to_stream(shape)
        self.render_shape_to_graphics(shape)
        self.render_drawingml_to_disk(drawingML)
        self.find_shape_sizes(shape)
예제 #4
0
    def __init__(self):
        self.dataDir = Settings.dataDir + 'rendering_printing/'
            
        # Load the documents which store the shapes we want to render.
        doc = Document(self.dataDir + "TestFile.doc")
        doc2 = Document(self.dataDir + "TestFile.docx")

        # Retrieve the target shape from the document. In our sample document this is the first shape.
        shape = doc.getChild(NodeType.SHAPE, 0, True)
        drawingML = doc2.getChild(NodeType.SHAPE, 0, True)

        # Test rendering of different types of nodes.
        self.render_shape_to_disk(shape)
        self.render_shape_to_stream(shape)
        self.render_shape_to_graphics(shape)
        self.render_drawingml_to_disk(drawingML)
        self.find_shape_sizes(shape)
예제 #5
0
    def __init__(self):
        dataDir = Settings.dataDir + 'programming_documents/'
        
        # Load the document.
        doc = Document(dataDir + "tableDoc.doc")
        
        # Get the first and second table in the document.
        # The rows from the second table will be appended to the end of the first table.
        firstTable = doc.getChild(NodeType.TABLE, 0, True)
        secondTable = doc.getChild(NodeType.TABLE, 1, True)

        # Append all rows from the current table to the next.
        # Due to the design of tables even tables with different cell count and widths can be joined into one table.
        while (secondTable.hasChildNodes()) :
            firstTable.getRows().add(secondTable.getFirstRow())

        # Remove the empty table container.
        secondTable.remove()

        doc.save(dataDir + "JoinTables.doc")

        print "Done."
    def __init__(self):
        dataDir = Settings.dataDir + 'programming_documents/'

        # Load the document.
        doc = Document(dataDir + "tableDoc.doc")

        # Get the first and second table in the document.
        # The rows from the second table will be appended to the end of the first table.
        firstTable = doc.getChild(NodeType.TABLE, 0, True)
        secondTable = doc.getChild(NodeType.TABLE, 1, True)

        # Append all rows from the current table to the next.
        # Due to the design of tables even tables with different cell count and widths can be joined into one table.
        while (secondTable.hasChildNodes()):
            firstTable.getRows().add(secondTable.getFirstRow())

        # Remove the empty table container.
        secondTable.remove()

        doc.save(dataDir + "JoinTables.doc")

        print "Done."