Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to extract headers and footers #153

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Jawad79Ahmad
Copy link

@Jawad79Ahmad Jawad79Ahmad commented Jul 26, 2024

This pull request introduces the ability to fetch and parse headers/footers.
New methods, fetch_headers and fetch_footers, to the docx gem. These methods allow users to extract and read the header and footer content from DOCX files using Nokogiri for XML parsing.

Changes Made:

Added fetch_headers method:

def fetch_headers @zip.glob('word/header*.xml').map do |entry| header_xml = entry.get_input_stream.read Nokogiri::XML(header_xml) end end

This method scans the DOCX archive for header XML files (word/header*.xml), reads their content, and parses them using Nokogiri to return a list of Nokogiri XML documents representing each header.

Added footers method:

Added fetch_footers method:

def fetch_footers @zip.glob('word/footer*.xml').map do |entry| footer_xml = entry.get_input_stream.read Nokogiri::XML(footer_xml) end end

Similar to the fetch_headers method, this method scans the DOCX archive for footer XML files (word/footer*.xml), reads their content, and parses them using Nokogiri to return a list of Nokogiri XML documents representing each footer.

pzgz added a commit to pzgz/docx that referenced this pull request Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant