Comments (4)
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.
Not exactly. :) Sorry for not being transparent. Lets say I have a docx that I want to convert to txt:
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.
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.
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)
- Detect and trim blank page
- ZIP library isn't working as expected in the document.rb
- Replace different placeholder text in each table cell HOT 4
- Text not being inserted after bookmark HOT 4
- Replace placeholders in a paragraph HOT 6
- Can watermark be supported
- to_html only considers some styles and not others HOT 1
- Fuzzer + various crashes
- Request to remove monkeypatching on Module HOT 2
- Please cut a new gem release to include a fix HOT 2
- When a file other than docx is provided, an unexpected error is thrown. HOT 1
- accept docm file
- add revision mark (text) in paragraph text
- RFC: Ability to create a new document file HOT 1
- Exception thrown when calling to_html on file with internal hyperlinks HOT 2
- Text Replacement not working as Expected HOT 6
- How can we add a new line break between a paragraph HOT 6
- How can we add a new paragraph
- How can we add a new table HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docx.