프레젠테이션에서 찾기 및 바꾸기
Contents
[
Hide
]
다음은 따라야 할 단계입니다:
- 프레젠테이션을 엽니다.
- 텍스트를 검색합니다.
- 텍스트를 교체합니다.
- 프레젠테이션을 작성합니다.
string FilePath = @"..\..\..\Sample Files\";
//프레젠테이션을 엽니다
Presentation pres = new Presentation(FilePath + "Find and Replace.pptx");
//프레젠테이션의 모든 텍스트 상자를 가져옵니다
ITextFrame[] tb = SlideUtil.GetAllTextBoxes(pres.Slides[0]);
for (int i = 0; i < tb.Length; i++)
foreach (Paragraph para in tb[i].Paragraphs)
foreach (Portion port in para.Portions)
//교체할 텍스트를 찾습니다
if (port.Text.Contains(strToFind))
//기존 텍스트를 새 텍스트로 교체합니다
{
string str = port.Text;
int idx = str.IndexOf(strToFind);
string strStartText = str.Substring(0, idx);
string strEndText = str.Substring(idx + strToFind.Length, str.Length - 1 - (idx + strToFind.Length - 1));
port.Text = strStartText + strToReplaceWith + strEndText;
}
pres.Save(FilePath + "Find and Replace.pptx",Aspose.Slides.Export.SaveFormat.Pptx);