Python Forum
Docx Convert Word Header to Body
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Docx Convert Word Header to Body
#3
I am fairly used the pdfminer and have also worked with PyPDF2 and pdfrw.

I have to extract each paragraph in the pdf, with as many data as possible: font, size, color, bold, italic etc, as much as possible. This is so later I can filter out the ones I want. Let's say I want to select all the text in this pdf that is size 16 with the Times new Roman Font, that has an rgb color of (255,255,255) and is bold etc. I have already created this part, I just have to include the headers somehow.

Pdfminer is almost good, but you can't extract the color and many other properties. Would love for it to work but there is just not enough data that you can extract from the LTTextLine and LTChar objects. The same is true with PyPDF2 and pdfrw.

Converting it to XML and HTML causes data loss thus those are not good alternatives either.

This is why docx is what I am looking for, it is easy to navigate and contains the most data in an easy to get format.

I have tried 3 methods of conversion:

1. pdf2docx pip package is slow and unreliable.
2. Calling Word in win32com is good but really slow.
3. Calling Adobe in win32com is good and also much faster as the others. This is the one I am using.

The problem is that all of them randomly create headers from the top of each page. This is what I am trying to solve. Is there no way to include the headers as part of the body text? Even if it is a way in Word for example, then it can be called and automated. Does nobody have any idea?

EDIT: I am only using non-scanned pdfs. So these things should be extractable.
Reply


Messages In This Thread
Docx Convert Word Header to Body - by CaptainCsaba - Jun-02-2021, 09:06 AM
RE: Docx Convert Word Header to Body - by Larz60+ - Jun-02-2021, 10:21 AM
RE: Docx Convert Word Header to Body - by CaptainCsaba - Jun-02-2021, 11:43 AM
RE: Docx Convert Word Header to Body - by Larz60+ - Jun-02-2021, 01:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 1,388 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Replace a text/word in docx file using Python Devan 4 4,655 Oct-17-2023, 06:03 PM
Last Post: Devan
Thumbs Up Convert word into pdf and copy table to outlook body in a prescribed format email2kmahe 1 903 Sep-22-2023, 02:33 PM
Last Post: carecavoador
  Review my code: convert a HTTP date header to a datetime object stevendaprano 1 2,265 Dec-17-2022, 12:24 AM
Last Post: snippsat
  python-docx regex: replace any word in docx text Tmagpy 4 2,478 Jun-18-2022, 09:12 AM
Last Post: Tmagpy
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,668 Aug-12-2021, 04:25 PM
Last Post: palladium
  Сombine (Merge) word documents using python-docx Lancellot 1 11,994 May-12-2021, 11:07 AM
Last Post: toothedsword
  How to use python to convert pdf to docx impact_code 3 2,793 Aug-01-2020, 01:58 PM
Last Post: Yoriz
  Write tables from Word (.docx) to Excel (.xlsx) using xlsxwriter jackie 1 3,370 May-27-2020, 11:47 PM
Last Post: mcmxl22
  Python Speech recognition, word by word AceScottie 6 16,304 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020