I have a question: How do add header (and footer) in *.docx file? I use library python-docx in my django project. But it really can't add header. I found solution on stack (July 2012) with using 'win32com', but nowadays it don't work for me. Help me advice. Thank you. Have a nice day.
Add header in *.docx word file using python
745 Views Asked by user233057 At
1
There are 1 best solutions below
Related Questions in PYTHON
- Is card-swipe hardware payment system-specific?
- Extracting/Decoding name from USB Credit Card reader
- Payment Card Industry PCI Compliance for Azure PCI DSS AppServices
- Any way to accept Credit Card swipes with a reader from a non-native Web App?
- EMV: Second Generate AC Results in 6985 SW_Error Access condition not satisfied
- Magento Submit Order button not forwarding after security patch update
- How to call Vault Pay Pal Api in android
- JCB card IIN changed or updated ?
- Credit / Debit Payment without Payment Gateway
- PCI compliant hash of a credit card number
Related Questions in DJANGO
- Is card-swipe hardware payment system-specific?
- Extracting/Decoding name from USB Credit Card reader
- Payment Card Industry PCI Compliance for Azure PCI DSS AppServices
- Any way to accept Credit Card swipes with a reader from a non-native Web App?
- EMV: Second Generate AC Results in 6985 SW_Error Access condition not satisfied
- Magento Submit Order button not forwarding after security patch update
- How to call Vault Pay Pal Api in android
- JCB card IIN changed or updated ?
- Credit / Debit Payment without Payment Gateway
- PCI compliant hash of a credit card number
Related Questions in MS-WORD
- Is card-swipe hardware payment system-specific?
- Extracting/Decoding name from USB Credit Card reader
- Payment Card Industry PCI Compliance for Azure PCI DSS AppServices
- Any way to accept Credit Card swipes with a reader from a non-native Web App?
- EMV: Second Generate AC Results in 6985 SW_Error Access condition not satisfied
- Magento Submit Order button not forwarding after security patch update
- How to call Vault Pay Pal Api in android
- JCB card IIN changed or updated ?
- Credit / Debit Payment without Payment Gateway
- PCI compliant hash of a credit card number
Related Questions in DOCX
- Is card-swipe hardware payment system-specific?
- Extracting/Decoding name from USB Credit Card reader
- Payment Card Industry PCI Compliance for Azure PCI DSS AppServices
- Any way to accept Credit Card swipes with a reader from a non-native Web App?
- EMV: Second Generate AC Results in 6985 SW_Error Access condition not satisfied
- Magento Submit Order button not forwarding after security patch update
- How to call Vault Pay Pal Api in android
- JCB card IIN changed or updated ?
- Credit / Debit Payment without Payment Gateway
- PCI compliant hash of a credit card number
Related Questions in WIN32COM
- Is card-swipe hardware payment system-specific?
- Extracting/Decoding name from USB Credit Card reader
- Payment Card Industry PCI Compliance for Azure PCI DSS AppServices
- Any way to accept Credit Card swipes with a reader from a non-native Web App?
- EMV: Second Generate AC Results in 6985 SW_Error Access condition not satisfied
- Magento Submit Order button not forwarding after security patch update
- How to call Vault Pay Pal Api in android
- JCB card IIN changed or updated ?
- Credit / Debit Payment without Payment Gateway
- PCI compliant hash of a credit card number
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Courtest of edi9999 I think the best way you can take is looking at python-docx to see how it manages the files. Docx is a zipped format (Docx Tag Wiki):
The
.docx
format is a zipped file that contains the following folders:A library like docx-python extracts at first the docx, so you could find it in the python docx: I have found it for you: https://github.com/mikemaccana/python-docx/blob/master/docx.py#L65
You can get the xmlcontent of 'word/document.xml' which is the main content of the docx, change it either using docx-python (which I recommend to you, docx-python seems to be able to add many different elements. If you want to copy the content of an other word document at the beginning of the document, you could probably try to copy the content of the document.xml to your document.xml, but It will probably give you some errors, specially if you use Images or non-text content.
To add a header or a footer, you will have to create a file
word/header1.xml
or aword/footer1.xml
You could just copy the header1.xml content of a file you created, this should work.Hope this helps