core

Core Classes for hwpapi
C:\Users\freed\.pyenv\pyenv-win\versions\3.10.1\lib\site-packages\fastcore\docscrape.py:225: UserWarning: Unknown section Attributes
  else: warn(msg)
C:\Users\freed\.pyenv\pyenv-win\versions\3.10.1\lib\site-packages\fastcore\docscrape.py:225: UserWarning: Unknown section Methods
  else: warn(msg)
C:\Users\freed\.pyenv\pyenv-win\versions\3.10.1\lib\site-packages\fastcore\docscrape.py:225: UserWarning: Unknown section Examples
  else: warn(msg)

source

Engine

 Engine (hwp_object=None)

Engine class to encapsulate the Hancom Office Hwp object.

This class provides an interface to interact with the Hancom Office Hwp application, facilitating actions and operations within the Hwp environment.

Type Default Details
hwp_object NoneType None The Hwp object to be encapsulated by the Engine. If not provided,
it defaults to creating a new Hwp object using “HWPFrame.HwpObject”.
C:\Users\freed\.pyenv\pyenv-win\versions\3.10.1\lib\site-packages\fastcore\docscrape.py:225: UserWarning: Unknown section Notes
  else: warn(msg)

source

Engines

 Engines (dll_path=None)

A collection manager for multiple Engine instances.

This class manages multiple Engine instances, providing methods to access and iterate over them. It is useful for handling multiple Hancom Office Hwp objects.

Type Default Details
dll_path NoneType None Path to a DLL file, if required for initialization.

source

Apps

 Apps ()

A collection of all app <App> objects.


source

App

 App (new_app=False, is_visible=True, dll_path=None, engine=None)

App 클래스는 한컴오피스의 한/글 프로그램과 상호작용하기 위한 인터페이스를 제공합니다.

이 클래스는 한/글 프로그램의 COM 객체와의 연동을 관리하고, 해당 객체에 대한 작업을 수행하는 메서드들을 포함합니다.


source

App.reload

 App.reload (app:__main__.App, new_app=False, dll_path=None)

Reloads the App instance with a new HWPFrame.HwpObject and resets its visibility and DLL path.

This function is designed to reinitialize the app object’s API with a new instance of the HWPFrame.HwpObject. It also checks and registers the specified DLL file if provided.

Type Default Details
app App The App instance to be reloaded.
new_app bool False
dll_path NoneType None The path to the DLL file to be checked and registered. If None, no DLL registration is performed.

source

App.set_visible

 App.set_visible (app:__main__.App, is_visible=True, window_i=0)

Sets the visibility of the Hancom Office Hwp program window.

This function is used to show or hide the window of the Hancom Office Hwp program based on the is_visible parameter. The window_i parameter specifies the index of the window to be shown or hidden.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
is_visible bool True A boolean value indicating the visibility of the program window.
If True, the window is made visible. If False, it is hidden. Default is True.
window_i int 0 The index of the window to be modified. Default is 0.

source

App.get_filepath

 App.get_filepath (app:__main__.App)

Retrieves the file path of the currently open Hancom Office Hwp document.

This function accesses the active document in the Hancom Office Hwp program linked to the App instance and returns its full file path.

Type Details
app App The App instance associated with the Hancom Office Hwp program.
Returns str The full file path of the currently active Hancom Office Hwp document.

source

App.create_action

 App.create_action (app:__main__.App, action_key:str, pset_key=None)

Creates and returns an instance of the _Action class.

This function generates a new _Action instance associated with the given app and action_key. The action_key specifies the type of action to be created for the application.

Type Default Details
app App The application object for which the action is being created.
action_key str The key representing the specific action to be created.
pset_key NoneType None
Returns **_Action** An instance of the _Action class initialized with the provided application object and action key.

source

App.create_parameterset

 App.create_parameterset (app:__main__.App, action_key:str)

Creates and returns a parameter set for a specific action within the application.

This function utilizes the _action_info dictionary to look up the parameter set information for the given action key. If the parameter set information exists for the specified action key, it creates and returns the corresponding parameter set object.

Type Details
app App The application object for which the parameter set is being created.
action_key str The key of the action for which the parameter set is being created.
Returns HParameterSet object or None The parameter set object for the specified action key.
If there is no parameter set information for the given action key, None is returned.

source

App.open

 App.open (app:__main__.App, path:str)

Opens a file in the Hancom Office Hwp program using the provided file path.

This function first converts the provided file path to an absolute path using the get_absolute_path function. It then opens the file in the Hancom Office Hwp program using the api.Open method and returns the absolute path of the opened file.

Type Details
app App The App instance associated with the Hancom Office Hwp program.
path str The file path of the document to be opened.
Returns str The absolute path of the file that has been opened.

source

App.get_hwnd

 App.get_hwnd (app:__main__.App)

Retrieves the window handle (HWND) of the active window in the Hancom Office Hwp program.

This function accesses the active window in the Hancom Office Hwp program linked to the App instance and returns its window handle. The window handle can be used in scenarios where direct manipulation or interaction with the window at the OS level is required.

Type Details
app App The App instance associated with the Hancom Office Hwp program.
Returns int The window handle (HWND) of the active Hancom Office Hwp window.

source

App.save

 App.save (app:__main__.App, path=None)

Saves the current document in the Hancom Office Hwp program.

If a path is provided, the document is saved to that location in the appropriate format based on the file extension. Supported formats include HWP, PDF, HWPML2X (HWPX), and PNG. If no path is provided, the document is saved in its current location.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
path NoneType None The file path where the document will be saved. If None, the document is saved in its current location.
Returns str The file path where the document has been saved.

source

App.save_block

 App.save_block (app:__main__.App, path:pathlib.Path)

Saves a block of content in the Hancom Office Hwp program and returns the file path.

This function saves a specified block from the Hancom Office Hwp program to a file in a given format. The format is determined by the file extension. Supported formats include HWP, PDF, HWPML2X (HWPX), and PNG. It returns the file path if the save operation is successful or None if it fails.

Type Details
app App The application object where the action will be performed.
path Path The file path where the block will be saved.
Returns Path or None The path to the saved file if the save operation is successful, or None if it fails.

source

App.close

 App.close (app:__main__.App)

Closes the currently open document in the Hancom Office Hwp program.

This function triggers the ‘FileClose’ command within the Hancom Office Hwp program to close the current document. It’s useful for programmatically managing documents within the application.

Type Details
app App The App instance associated with the Hancom Office Hwp program.

source

App.quit

 App.quit (app:__main__.App)

Terminates the Hancom Office Hwp program instance associated with the App.

This function invokes the ‘FileQuit’ command within the Hancom Office Hwp program to close the application. It’s useful for programmatically controlling the lifecycle of the application.

Type Details
app App The App instance associated with the Hancom Office Hwp program.

source

App.get_font_list

 App.get_font_list (app:__main__.App)

Retrieves the list of fonts that used in the documnents from the current application.

This method accesses the font list in the Hancom Office Hwp program linked to the App instance. It extracts fonts that used and return in list for further use or analysis.

Type Details
app App The application object from which the character shape settings will be retrieved.
Returns List return font list that used in the hwp document.

source

App.get_charshape

 App.get_charshape (app:__main__.App)

Retrieves the character shape settings from the current application.

This method accesses the character shape settings in the Hancom Office Hwp program linked to the App instance. It extracts these settings and encapsulates them in a CharShape object for further use or analysis.

Type Details
app App The application object from which the character shape settings will be retrieved.
Returns CharShape An object representing the character shape settings of the application.

source

App.set_charshape

 App.set_charshape (app:__main__.App,
                    charshape:hwpapi.dataclasses.CharShape=None, **kwargs)

Sets the character shape in the current paragraph of the Hancom Office Hwp application using the provided CharShape.

If charshape is None, a default instance of CharShape is created. The function can also accept additional keyword arguments (kwargs), which are assigned as properties of charshape. This modified charshape is then used to change the current paragraph shape in the Hancom Office Hwp document.

Type Default Details
app App The App object. It is used to access the Hancom Office Hwp application.
charshape CharShape None The CharShape object to be used for setting character shapes in Hancom Office Hwp. The default is None.
kwargs
Returns bool A boolean value indicating the success of the set_charshape operation.

source

App.get_parashape

 App.get_parashape (app:__main__.App)

Retrieves the paragraph shape settings from the current application.

This method accesses the paragraph shape settings in the Hancom Office Hwp program linked to the App instance. It extracts these settings and encapsulates them in a ParaShape object for further use or analysis.

Type Details
app App The application object from which the paragraph shape settings will be retrieved.
Returns ParaShape An object representing the paragraph shape settings of the application.

source

App.set_parashape

 App.set_parashape (app:__main__.App,
                    parashape:hwpapi.dataclasses.ParaShape=None, **kwargs)

Sets the paragraph shape in the Hancom Office Hwp application using the provided ParaShape.

If parashape is None, a default instance of ParaShape is created. The function can also accept additional keyword arguments (kwargs), which are assigned as properties of parashape. This modified parashape is then used to change the current paragraph shape in the Hancom Office Hwp document.

Type Default Details
app App The App object, used to access the Hancom Office Hwp application.
parashape ParaShape None The ParaShape object to be used for setting paragraph shapes in Hancom Office Hwp. Defaults to None.
kwargs
Returns bool A boolean value indicating the success of the set_parashape operation.

source

App.insert_text

 App.insert_text (app:__main__.App, text:str,
                  charshape:hwpapi.dataclasses.CharShape=None, **kwargs)

Inserts text into the Hancom Office Hwp document with specified character shape settings.

This function inserts the given text into the document associated with the App instance. It allows for optional character shape settings through a CharShape object. Additional character shape attributes can be specified via keyword arguments.

Type Default Details
app App The App object associated with the Hancom Office Hwp program.
text str The text to be inserted into the document.
charshape CharShape None An optional CharShape object to specify the character shape settings for the inserted text. Defaults to None.
kwargs

scan

 scan (app:__main__.App, option=<MaskOption.All: 5>, selection=False,
       scan_spos=<ScanStartPosition.Document: 112>,
       scan_epos=<ScanEndPosition.Document: 7>, spara=None, spos=None,
       epara=None, epos=None, scan_direction=<ScanDirection.Forward: 0>)

source

ScanDirection

 ScanDirection (value, names=None, module=None, qualname=None, type=None,
                start=1)

An enumeration.


source

ScanEndPosition

 ScanEndPosition (value, names=None, module=None, qualname=None,
                  type=None, start=1)

An enumeration.


source

ScanStartPosition

 ScanStartPosition (value, names=None, module=None, qualname=None,
                    type=None, start=1)

An enumeration.


source

MaskOption

 MaskOption (value, names=None, module=None, qualname=None, type=None,
             start=1)

An enumeration.


source

move_to_line

 move_to_line (app:__main__.App, text)

인자로 전달한 텍스트가 있는 줄의 시작지점으로 이동합니다.


source

App.move

 App.move (app:__main__.App, key=<MoveId.ScanPos: 201>, para=None,
           pos=None)

Moves the caret position based on the specified key.

Type Default Details
app App The App object associated with the Hancom Office Hwp program.
key MoveId MoveId.ScanPos The movement option, as defined in the MoveId Enum. Defaults to MoveId.ScanPos.
para NoneType None The paragraph number to move to, if applicable. Defaults to None.
pos NoneType None The position within the paragraph to move to, if applicable. Defaults to None.
Returns bool True if the movement was successful, False otherwise.

source

MoveId

 MoveId (value, names=None, module=None, qualname=None, type=None,
         start=1)

An enumeration.


source

App.setup_page

 App.setup_page (app:__main__.App, top=20, bottom=10, right=20, left=20,
                 header=15, footer=5, gutter=0)

Sets up the page layout for the document in the Hancom Office Hwp application.

This function configures the page margins, header, footer, and gutter (binding margin) sizes. Measurements are in millimeters and are converted to the application’s internal unit system.

Type Default Details
app App app
top int 20 Top margin in millimeters
bottom int 10 Bottom margin in millimeters
right int 20 Right margin in millimeters
left int 20 Left margin in millimeters
header int 15 Header length in millimeters
footer int 5 Footer length in millimeters
gutter int 0 Gutter length (binding margin) in millimeters
Returns bool True if the page setup was successful, False otherwise.

source

App.insert_picture

 App.insert_picture (app:__main__.App, fpath, width=None, height=None,
                     size_option=<SizeOption.RealSize: 0>, reverse=False,
                     watermark=False, effect=<Effect.RealPicture: 0>)

Inserts a picture into the document with specified size and effect options.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
fpath str File path of the picture to be inserted.
width NoneType None Width of the picture, if None, determined by size option. Defaults to None.
height NoneType None Height of the picture, if None, determined by size option. Defaults to None.
size_option SizeOption SizeOption.RealSize The sizing option for the picture, defined in SizeOption Enum. Defaults to SizeOption.RealSize.
reverse bool False If true, the image is reversed. Defaults to False.
watermark bool False If true, the image is treated as a watermark. Defaults to False.
effect Effect Effect.RealPicture The visual effect for the picture, defined in Effect Enum. Defaults to Effect.RealPicture.
Returns bool True if the picture was inserted successfully, False otherwise.

source

Effect

 Effect (value, names=None, module=None, qualname=None, type=None,
         start=1)

An enumeration.


source

SizeOption

 SizeOption (value, names=None, module=None, qualname=None, type=None,
             start=1)

An enumeration.


source

App.select_text

 App.select_text (app:__main__.App, option=<SelectionOption.Line:
                  ('MoveLineBegin', 'MoveSelLineEnd')>)

Selects text in the document based on the specified option.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
option SelectionOption SelectionOption.Line The text unit to be selected. Options are defined in SelectionOption Enum. Default is SelectionOption.Line.
Returns tuple A tuple containing the results of the begin and end move actions (both boolean).

source

SelectionOption

 SelectionOption (value, names=None, module=None, qualname=None,
                  type=None, start=1)

An enumeration.


source

App.get_selected_text

 App.get_selected_text (app:__main__.App)

Retrieves text from the currently selected area in the Hancom Office Hwp document.

This function scans the selected text in the document and returns it as a string. It’s particularly useful for operations involving the currently highlighted or selected text segment.

Type Details
app App The App instance associated with the Hancom Office Hwp program.
Returns str The text from the currently selected area in the document.

source

App.get_text

 App.get_text (app:__main__.App, spos=<ScanStartPosition.Line: 32>,
               epos=<ScanEndPosition.Line: 2>)

Retrieves text from the document based on specified start and end positions.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
spos ScanStartPosition ScanStartPosition.Line The start position for text retrieval. Default is ScanStartPosition.Line.
epos ScanEndPosition ScanEndPosition.Line The end position for text retrieval. Default is ScanEndPosition.Line.
Returns str The retrieved text from the specified start to end positions.

source

ScanEndPosition

 ScanEndPosition (value, names=None, module=None, qualname=None,
                  type=None, start=1)

An enumeration.


source

ScanStartPosition

 ScanStartPosition (value, names=None, module=None, qualname=None,
                    type=None, start=1)

An enumeration.


source

Direction

 Direction (value, names=None, module=None, qualname=None, type=None,
            start=1)

An enumeration.


source

App.find_text

 App.find_text (app:__main__.App, text='',
                charshape:hwpapi.dataclasses.CharShape=<CharShape:
                hangul_font=None, latin_font=None, text_color=None,
                fontsize=None, bold=None, italic=None, super_script=None,
                sub_script=None, offset=None, spacing=None, ratio=None,
                shade_color=None, shadow_color=None, shadow_offset_x=None,
                shadow_offset_y=None, strike_out_type=None,
                strike_out_color=None, underline_type=None,
                underline_shape=None, underline_color=None,
                out_line_type=None>, ignore_message=True,
                direction=<Direction.Forward: 0>, match_case=False,
                all_word_forms=False, several_words=False,
                use_wild_cards=False, whole_word_only=False,
                replace_mode=False, ignore_find_string=False,
                ignore_replace_string=False, find_style='',
                replace_style='', find_jaso=False, find_reg_exp=False,
                find_type=False)

Searches for the specified text in the document with various options.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
text str The text string to search for.
charshape CharShape <CharShape: hangul_font=None, latin_font=None, text_color=None, fontsize=None, bold=None, italic=None, super_script=None, sub_script=None, offset=None, spacing=None, ratio=None, shade_color=None, shadow_color=None, shadow_offset_x=None, shadow_offset_y=None, strike_out_type=None, strike_out_color=None, underline_type=None, underline_shape=None, underline_color=None, out_line_type=None>
ignore_message bool True 메시지 무시 여부
direction Direction Direction.Forward 찾을 방향
match_case bool False 대소문자 구분
all_word_forms bool False 문자열 결합
several_words bool False 여러 단어 찾기
use_wild_cards bool False 아무개 문자
whole_word_only bool False 온전한 낱말
replace_mode bool False 찾아 바꾸기 모드
ignore_find_string bool False 찾을 문자열 무시
ignore_replace_string bool False 바꿀 문자열 무시
find_style str 찾을 스타일
replace_style str
find_jaso bool False 자소로 찾기
find_reg_exp bool False 정규표현식으로 찾기
find_type bool False 다시 찾기를 할 때 마지막으로 실한 찾기를 할 경우 True, 찾아가기를 할경우 False
Returns bool True if the text was found, False otherwise.

source

App.replace_all

 App.replace_all (app:__main__.App, old_text='', new_text='',
                  old_charshape=<CharShape: hangul_font=None,
                  latin_font=None, text_color=None, fontsize=None,
                  bold=None, italic=None, super_script=None,
                  sub_script=None, offset=None, spacing=None, ratio=None,
                  shade_color=None, shadow_color=None,
                  shadow_offset_x=None, shadow_offset_y=None,
                  strike_out_type=None, strike_out_color=None,
                  underline_type=None, underline_shape=None,
                  underline_color=None, out_line_type=None>,
                  new_charshape=<CharShape: hangul_font=None,
                  latin_font=None, text_color=None, fontsize=None,
                  bold=None, italic=None, super_script=None,
                  sub_script=None, offset=None, spacing=None, ratio=None,
                  shade_color=None, shadow_color=None,
                  shadow_offset_x=None, shadow_offset_y=None,
                  strike_out_type=None, strike_out_color=None,
                  underline_type=None, underline_shape=None,
                  underline_color=None, out_line_type=None>,
                  ignore_message=True, direction=<Direction.All: 2>,
                  match_case=False, all_word_forms=False,
                  several_words=False, use_wild_cards=False,
                  whole_word_only=False, auto_spell=True,
                  replace_mode=True, ignore_find_string=False,
                  ignore_replace_string=False, find_style='',
                  replace_style='', find_jaso=False, find_reg_exp=False,
                  find_type=True)

Replaces all occurrences of a specified text with new text in the document.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
old_text str The text string to be replaced.
new_text str The new text string to replace with.
old_charshape CharShape <CharShape: hangul_font=None, latin_font=None, text_color=None, fontsize=None, bold=None, italic=None, super_script=None, sub_script=None, offset=None, spacing=None, ratio=None, shade_color=None, shadow_color=None, shadow_offset_x=None, shadow_offset_y=None, strike_out_type=None, strike_out_color=None, underline_type=None, underline_shape=None, underline_color=None, out_line_type=None>
new_charshape CharShape <CharShape: hangul_font=None, latin_font=None, text_color=None, fontsize=None, bold=None, italic=None, super_script=None, sub_script=None, offset=None, spacing=None, ratio=None, shade_color=None, shadow_color=None, shadow_offset_x=None, shadow_offset_y=None, strike_out_type=None, strike_out_color=None, underline_type=None, underline_shape=None, underline_color=None, out_line_type=None>
ignore_message bool True 메시지 무시 여부
direction Direction Direction.All 찾을 방향
match_case bool False 대소문자 구분
all_word_forms bool False 문자열 결합
several_words bool False 여러 단어 찾기
use_wild_cards bool False 아무개 문자
whole_word_only bool False 온전한 낱말
auto_spell bool True 토시 자동 교정
replace_mode bool True 찾아 바꾸기 모드
ignore_find_string bool False 찾을 문자열 무시
ignore_replace_string bool False 바꿀 문자열 무시
find_style str 찾을 스타일
replace_style str 바꿀 스타일
find_jaso bool False 자소로 찾기
find_reg_exp bool False 정규표현식으로 찾기
find_type bool True 다시 찾기를 할 때 마지막으로 실한 찾기를 할 경우 True, 찾아가기를 할경우 False
Returns bool True if the replace operation was successful, False otherwise.

source

App.insert_file

 App.insert_file (app:__main__.App, fpath, keep_charshape=False,
                  keep_parashape=False, keep_section=False,
                  keep_style=False)

Inserts the contents of a specified file into the current document.

This function inserts the contents of another file into the current document at the cursor’s position. It provides options to retain various formatting attributes of the inserted content.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
fpath str The file path of the document to be inserted.
keep_charshape bool False If True, retains the original character shapes from the inserted file. Defaults to False.
keep_parashape bool False If True, retains the original paragraph shapes from the inserted file. Defaults to False.
keep_section bool False If True, retains the original section formatting from the inserted file. Defaults to False.
keep_style bool False If True, retains the original styles from the inserted file. Defaults to False.
Returns bool True if the file was inserted successfully, False otherwise.

source

App.set_cell_border

 App.set_cell_border (app:__main__.App, top=None, right=None, left=None,
                      bottom=None, horizontal=None, vertical=None,
                      top_width=<Thickness.NULL: None>,
                      right_width=<Thickness.NULL: None>,
                      left_width=<Thickness.NULL: None>,
                      bottom_width=<Thickness.NULL: None>,
                      horizontal_width=<Thickness.NULL: None>,
                      vertical_width=<Thickness.NULL: None>,
                      top_color=None, bottom_color=None, left_color=None,
                      right_color=None, horizontal_color=None,
                      vertical_color=None)

Sets the border properties for cells in a table within a Hancom Office Hwp document.

This function customizes the border types, widths, and colors for different sides of the cells. It allows for detailed customization of cell appearance in tables.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
top NoneType None
right NoneType None
left NoneType None
bottom NoneType None
horizontal NoneType None
vertical NoneType None
top_width Thickness Thickness.NULL
right_width Thickness Thickness.NULL
left_width Thickness Thickness.NULL
bottom_width Thickness Thickness.NULL
horizontal_width Thickness Thickness.NULL
vertical_width Thickness Thickness.NULL
top_color NoneType None
bottom_color NoneType None
left_color NoneType None
right_color NoneType None
horizontal_color NoneType None
vertical_color NoneType None
Returns bool True if the border settings were successfully applied, False otherwise.

source

Thickness

 Thickness (value, names=None, module=None, qualname=None, type=None,
            start=1)

An enumeration.


source

App.set_cell_color

 App.set_cell_color (app:__main__.App, bg_color=None,
                     hatch_color='#000000', hatch_style=6, alpha=None)

Sets the background color and hatch style for cells in a Hancom Office Hwp document.

This function allows customization of the cell background, including color and hatching pattern, providing options to set transparency and hatch color.

Type Default Details
app App The App instance associated with the Hancom Office Hwp program.
bg_color NoneType None Hexadecimal color code for the cell background (e.g., “#RRGGBB”). If not specified, the background is not changed.
hatch_color str #000000 Hexadecimal color code for the hatching. Default is black (“#000000”).
hatch_style int 6 Style of the hatching pattern. Default is 6.
alpha NoneType None Alpha value for the background color’s transparency (0-255). If not specified, transparency is not changed.
Returns bool True if the cell color settings were applied successfully, False otherwise.