# C# 쪽 테두리 그리기 문의 드립니다

**URL:** <https://forum.developer.hancom.com/t/c/1327>\
**Category:** 한글 오토메이션\
**Created:** [2월 14, 2024, 2:26오전 UTC](https://forum.developer.hancom.com/t/c/1327 "2024-02-14T02:26:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FDZ\_pK](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@FDZ\_pK](https://forum.developer.hancom.com/u/FDZ_pK)\
**Post date:** [2월 14, 2024, 2:26오전 UTC](https://forum.developer.hancom.com/t/c/1327/1 "2024-02-14T02:26:10Z")

</div>

쪽 테두리를 그어야 하는데, 스크립트를 보고 해봐도 도저히 안나오네요… (초보 개발자입니다ㅠㅠ)  
CreateItemSet이나 SetID, ItemID 설정이 필요할 것 같은데 도와주세요…

// 테두리변경  
var pageline = (HWPCONTROLLib.DHwpAction)BHwpCtrl.CreateAction(“PageBorder”);  
var pageline\_st = (HWPCONTROLLib.DHwpParameterSet)pageline.CreateSet();  
pageline.GetDefault(pageline\_st);  
pageline\_st.SetItem(“ApplyToPageBorderFill”, 3);  
var pageline\_st0 = (HWPCONTROLLib.DHwpParameterSet)pageline\_st.CreateItemSet(“itemid”, “setid”);  
pageline\_st0.SetItem(“BorderTypeLeft”, 3);  
pageline\_st0.SetItem(“BorderTypeRight”, 3);  
pageline\_st0.SetItem(“BorderTypeTop”, 3);  
pageline\_st0.SetItem(“BorderTypeBottom”, 3);  
pageline\_st0.SetItem(“BorderWidthLeft”, 10);  
pageline\_st0.SetItem(“BorderWidthRight”, 10);  
pageline\_st0.SetItem(“BorderWidthTop”, 10);  
pageline\_st0.SetItem(“BorderWidthBottom”, 10);  
pageline.Execute(pageline\_st);

---

<div class="post-metadata">

**Author:** ![user16](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/user16/32/785_2.png) [@user16](https://forum.developer.hancom.com/u/user16)\
**Post date:** [2월 14, 2024, 4:00오전 UTC](https://forum.developer.hancom.com/t/c/1327/2 "2024-02-14T04:00:17Z")

</div>

5번 라인의 **“itemid”** 을 \*\*“PageBorderFillBoth”\*\*로,  
**“setid”** 를 \*\*“PageBorderFill”\*\*이라고 바꾸고 실행해보시면 될 것 같네요.

```auto
var pageline = (HWPCONTROLLib.DHwpAction)BHwpCtrl.CreateAction("PageBorder");
var pageline_st = (HWPCONTROLLib.DHwpParameterSet)pageline.CreateSet();
pageline.GetDefault(pageline_st);
pageline_st.SetItem("ApplyToPageBorderFill", 3);
var pageline_st0 = (HWPCONTROLLib.DHwpParameterSet)pageline_st.CreateItemSet("PageBorderFillBoth", "PageBorderFill");
pageline_st0.SetItem("BorderTypeLeft", 3);
pageline_st0.SetItem("BorderTypeRight", 3);
pageline_st0.SetItem("BorderTypeTop", 3);
pageline_st0.SetItem("BorderTypeBottom", 3);
pageline_st0.SetItem("BorderWidthLeft", 10);
pageline_st0.SetItem("BorderWidthRight", 10);
pageline_st0.SetItem("BorderWidthTop", 10);
pageline_st0.SetItem("BorderWidthBottom", 10);
pageline.Execute(pageline_st);

```

![녹화_2024_02_14_12_34_25_641](https://us1.discourse-cdn.com/flex016/uploads/hancom_dev_forum/original/1X/4503b8119d9efb6bc8520c5112dd7857267331bf.gif)

========

아이템셋이 필요한 액션의 경우  
공식문서 “액션테이블” 및 "파라미터셋 테이블"을 참고하는 방법을  
간략히 알려드리겠습니다.

# 1.

액션테이블에서 "쪽 테두리"를 검색하면  
Action ID: “PageBorder”, ParameterSet ID: “SecDef” 라고 정의되어 있습니다.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/hancom_dev_forum/original/1X/ee65968f60395a2dc087931fa0e06bff6e95b1d0.png)

Action ID 문자열 정보를 바탕으로  
`pageline = CreateAction("PageBorder")`과,  
`pageline_st = pageline.CreateSet()` 코드를 작성합니다.

> 파라미터셋 아이디인 "SecDef"는 pageline.SetID나 pageline\_st.SetID를 조회해보셔도  
> 확인할 수 있습니다.

# 2.

pset의 SetID인 "SecDef"를 파라미터셋 테이블에서 찾아봅니다. (102번이네요.)  
해당 표 안에 찾아보면 양쪽 쪽 테두리와 배경을 정의할 수 있는  
아이템 아이디가 "PageBorderFillBoth"이라고 나옵니다.  
(이 "PageBorderFillBoth"이 CreateItemSet의 첫 번째 인수인 ItemID입니다.)

그리고 서브타입은 "PageBorderFill"이라는 정보도 얻었습니다. (얘가 SetID가 됩니다.)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/hancom_dev_forum/original/1X/0456bf7131597ef6ce2aa1c7dd707a90a40086a8.png)

# 3.

다시 서브타입 문자열인 PageBorderFill을 파라미터셋 테이블에서 검색해봅니다.(86번)

필요한 아이템아이디는 참고하셔도 되는데,  
찾아보니 테두리를 그리는 직접적인 아이템이 보이지 않습니다.  
근데 설명란에 "PageBorderFill의 아이템들 이외에 BorderFill의 아이템들을 사용할 수 있다."라네요.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/hancom_dev_forum/original/1X/c311aab4dc2ad4f5b92079efd10c89e318e71fdb.png)

# 4.

그래서, BorderFill을 다시 찾습니다. (5번)  
여기 우리가 원하던 아이템(테두리 종류와 두께)들이 있네요.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/hancom_dev_forum/original/1X/9a54749e2263576aeb12b3accad4f5846e3f9509.png)

# 5.

위 정보 등을 바탕으로 아래 코드를 완성합니다. (아래는 파이썬 코드입니다.)

```auto
pageline = hwp.CreateAction("PageBorder")
pageline_st = pageline.CreateSet()
pageline.GetDefault(pageline_st)
pageline_st.SetItem("ApplyToPageBorderFill", 3)
pageline_st0 = pageline_st.CreateItemSet("PageBorderFillBoth", "PageBorderFill")
pageline_st0.SetItem("BorderTypeLeft", hwp.HwpLineType("Solid"))
pageline_st0.SetItem("BorderTypeRight", hwp.HwpLineType("Solid"))
pageline_st0.SetItem("BorderTypeTop", hwp.HwpLineType("Solid"))
pageline_st0.SetItem("BorderTypeBottom", hwp.HwpLineType("Solid"))
pageline_st0.SetItem("BorderWidthLeft", hwp.HwpLineWidth("1.0mm"))
pageline_st0.SetItem("BorderWidthRight", hwp.HwpLineWidth("1.0mm"))
pageline_st0.SetItem("BorderWidthTop", hwp.HwpLineWidth("1.0mm"))
pageline.Execute(pageline_st)

```

끝.

참고로, CreateAction 대신 스크립트매크로를 쓰시는 게 더 편할 수도 있어요.  
(저는 스크립트매크로 문법을 훨씬 선호하는 편입니다.. C#에도 적용이 될 것 같은데요.)

스크립트매크로는 아래와 같고,

```jscript
function OnScriptMacro_중국어1성()
{
	HAction.GetDefault("PageBorder", HParameterSet.HSecDef.HSet);
	with (HParameterSet.HSecDef)
	{
		PageBorderFillBoth.BorderTypeLeft = HwpLineType("Solid");
		PageBorderFillBoth.BorderTypeRight = HwpLineType("Solid");
		PageBorderFillBoth.BorderTypeTop = HwpLineType("Solid");
		PageBorderFillBoth.BorderTypeBottom = HwpLineType("Solid");
		PageBorderFillBoth.BorderWidthLeft = HwpLineWidth("1.0mm");
		PageBorderFillBoth.BorderWidthRight = HwpLineWidth("1.0mm");
		PageBorderFillBoth.BorderWidthTop = HwpLineWidth("1.0mm");
		PageBorderFillBoth.BorderWidthBottom = HwpLineWidth("1.0mm");
		HSet.SetItem("ApplyToPageBorderFill", 3);
	}
	HAction.Execute("PageBorder", HParameterSet.HSecDef.HSet);
}

```

이를 함수로 변환하면 아래와 같습니다.  
큰 차이가 없기도 하고, IDE에서 자동완성도 잘 지원해줍니다.

```python
def page_border():
    pset = hwp.HParameterSet.HSecDef
    hwp.HAction.GetDefault("PageBorder", pset.HSet)
    pset.PageBorderFillBoth.BorderTypeLeft = hwp.HwpLineType("Solid")
    pset.PageBorderFillBoth.BorderTypeRight = hwp.HwpLineType("Solid")
    pset.PageBorderFillBoth.BorderTypeTop = hwp.HwpLineType("Solid")
    pset.PageBorderFillBoth.BorderTypeBottom = hwp.HwpLineType("Solid")
    pset.PageBorderFillBoth.BorderWidthLeft = hwp.HwpLineWidth("1.0mm")
    pset.PageBorderFillBoth.BorderWidthRight = hwp.HwpLineWidth("1.0mm")
    pset.PageBorderFillBoth.BorderWidthTop = hwp.HwpLineWidth("1.0mm")
    pset.PageBorderFillBoth.BorderWidthBottom = hwp.HwpLineWidth("1.0mm")
    pset.HSet.SetItem("ApplyToPageBorderFill", 3)
    hwp.HAction.Execute("PageBorder", pset.HSet)

```

어때요? 스크립트 매크로를 활용해서  
이렇게 문서를 찾는 수고를 줄이기도 합니다.

도움이 되었기를 바랍니다.  
행복한 하루 되세요!^^
