### Example 53: Setting Overall Numbering Start Values Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Shows how to set the starting number for pages and tables within a section's properties. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") section = document.sections[0] section.properties.set_begin_numbering(page=1, table=1) ``` -------------------------------- ### Example 55: Adjusting Header Numbering Start Values Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Demonstrates how to set the starting page and table numbers for the first header, if headers exist. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") if document.headers: document.headers[0].set_begin_numbering(page=1, table=1) ``` -------------------------------- ### Example 41: Listing Header Paths Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Shows how to get and print a list of all header paths within the HWPX package. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") print(document.package.header_paths()) ``` -------------------------------- ### Example 43: Listing Package Part Names Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Shows how to get and print a list of all part names within the HWPX package. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") print(document.package.part_names()) ``` -------------------------------- ### Example 54: Reading Header Numbering Start Values Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Illustrates how to access and print the starting page and table numbers for the first header, if headers exist. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") if document.headers: begin = document.headers[0].begin_numbering print(begin.page, begin.table) ``` -------------------------------- ### Example 40: Listing Section Part Names Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Demonstrates how to retrieve and print the part names for all sections in the document. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") print([section.part_name for section in document.sections]) ``` -------------------------------- ### Example 47: Adding a New Part Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Shows how to add a new part to the HWPX package with specified content. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") document.package.set_part("META-INF/notes.txt", "Generated with python-hwpx") ``` -------------------------------- ### Example 44: Checking Header Part Byte Length Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Illustrates how to get the byte length of a header part by retrieving its data. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") header_paths = document.package.header_paths() if header_paths: data = document.package.get_part(header_paths[0]) print("header bytes:", len(data)) ``` -------------------------------- ### Example 46: Modifying version.xml Attributes Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Demonstrates how to get the XML object for 'version.xml', modify an attribute, and then save it back. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") version_xml = document.package.get_xml("version.xml") version_xml.set("writer", "python-hwpx") document.package.set_xml("version.xml", version_xml) ``` -------------------------------- ### Example 48: Listing Character Style IDs Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Demonstrates how to iterate through and print all available character style IDs. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") for style_id in sorted(document.char_properties.keys()): print("style:", style_id) ``` -------------------------------- ### Example 39: Changing Control Attributes Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Illustrates how to add a control and then set one of its attributes, like 'dirty'. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") control = document.add_control(section=document.sections[0], control_type="LINE") control.set_attribute("dirty", "false") ``` -------------------------------- ### Development Environment Setup and Testing Source: https://github.com/airmang/python-hwpx/blob/main/README.md Commands to clone the repository, install development dependencies, and run tests. ```bash git clone https://github.com/airmang/python-hwpx.git cd python-hwpx pip install -e ".[dev]" pytest ``` -------------------------------- ### hwpx-skill Source: https://github.com/airmang/python-hwpx/blob/main/shared/hwpx/HWPX_STACK_OPERATING_PLAN.md Commands to install dependencies and run example scripts for the hwpx-skill project. ```bash cd /path/to/hwpx-skill python -m pip install -U python-hwpx lxml python scripts/text_extract.py python scripts/zip_replace_all.py --replace "{키}=값" ``` -------------------------------- ### Example 45: Reading version.xml Text Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Shows how to retrieve the text content of the 'version.xml' file and print its first line. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") version_text = document.package.get_text("version.xml") print(version_text.splitlines()[0]) ``` -------------------------------- ### Example 22: Delete memos matching criteria Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Iterates through all memos and removes those whose text starts with '임시'. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") for memo in list(document.memos): if memo.text.startswith("임시"): document.remove_memo(memo) ``` -------------------------------- ### Example 35: Checking Table Row and Column Count Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Shows how to open a document, add a table, and then print the number of rows and columns. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") section = document.sections[0] table = document.add_table(rows=4, cols=2, section=section) print(table.row_count, table.column_count) ``` -------------------------------- ### Example 34: Adjusting Cell Width Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Demonstrates how to open an HWPX document, add a table, select a cell, and set its width. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") section = document.sections[0] table = document.add_table(rows=2, cols=2, section=section) cell = table.cell(1, 0) cell.set_size(width=7200) ``` -------------------------------- ### Example 49: Querying Character Style Details Source: https://github.com/airmang/python-hwpx/blob/main/docs/usage.md Shows how to ensure a run style (e.g., bold) and then retrieve and print its text color and underline type. ```python from hwpx import HwpxDocument document = HwpxDocument.open("my-document.hwpx") style_id = document.ensure_run_style(bold=True) style = document.char_property(style_id) if style: print(style.text_color(), style.underline_type()) ```