Skip to content

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

1 participant