Giter Site home page Giter Site logo

Order of paragraphs and tables about docx HOT 4 OPEN

Prigin avatar Prigin commented on June 12, 2024
Order of paragraphs and tables

from docx.

Comments (4)

satoryu avatar satoryu commented on June 12, 2024

You mean that at the latest version of this gem Document#paragraphs returns paragraphs in wrong order, right?
Could you give us a docx file to reproduce this behavior if you have?
The file would help us to investigate what happens.

Thanks

from docx.

Prigin avatar Prigin commented on June 12, 2024

Not exactly. :) Sorry for not being transparent. Lets say I have a docx that I want to convert to txt:

image

I need to know place of each element(paragraphs and tables). How to get the same order of elements they have in DOCX? Or maybe they already have that method(which returns order number from doc). I cant actually find it :(

from docx.

aunghtain avatar aunghtain commented on June 12, 2024

I was able to do this as followed. I'm using private vars/methods, but if they open up more APIs in the future, we won't have to.

    doc = Docx::Document.open(file)
    doc.instance_variable_get("@doc").xpath('//w:document//w:body').children.each do |c|
      if c.name == 'p' # paragraph
        p = doc.send(:parse_paragraph_from, c)      
      elsif c.name = 'tbl' # table
        t = doc.send(:parse_table_from, c)  
      else # other types?
      end
    end

from docx.

aunghtain avatar aunghtain commented on June 12, 2024

if u just want text, u don't need to parse them as paragraph/table. u can just get as "c.content"

from docx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.