이 간단한 예는 **C#**을 사용하여 PPTX에서 텍스트를 취소선으로 지우는 방법을 수반합니다. 여기에는 필요한 리소스에 대한 정보, 단계별 절차 및 **C#**을 사용하여 PPTX 텍스트를 삭제하는 작업 샘플 코드가 포함됩니다. 샘플 프레젠테이션 만들기, 자동 모양 추가, 텍스트를 추가하여 텍스트 프레임 만들기, 텍스트 강조하기 등 프로세스 세부 정보를 공유합니다.
C#을 사용하여 PPTX에서 텍스트를 취소하는 단계
- PPTX에서 텍스트를 취소선으로 지우기 위해 Aspose.Slides for .NET를 추가하도록 환경을 구성합니다.
- Presentation 클래스의 인스턴스를 사용하여 비어 있는 기본 프레젠테이션을 만들고 첫 번째 슬라이드에 액세스
- Rectangle 유형의 자동 모양을 만들고 그 안에 샘플 텍스트 프레임을 추가합니다.
- 텍스트 프레임 안에 텍스트의 일부를 추가하고 TextStrikethroughType 열거자를 사용하여 이중선 취소선을 설정합니다.
- 텍스트 프레임 안에 텍스트의 두 번째 부분을 추가하고 TextStrikethroughType 열거자를 사용하여 한 줄 취소선을 설정합니다.
- PPTX의 텍스트에 취소선이 있는 프레젠테이션 저장
앞서 언급한 단계는 *C#*을 사용하여 Presentation에서 텍스트를 취소선으로 지우는 방법을 설명합니다. 모든 필수 클래스, 메서드 및 속성이 지정되고 잘 정의된 순서로 사용되어 원하는 출력을 얻습니다. Presentation 클래스는 빈 파일을 만들거나 기존 PPTX 파일을 로드하는 데 사용되고 ShapeCollection 클래스는 자동 모양을 추가하는 데 사용됩니다. PPTX 슬라이드에서 TextStrikethroughType 열거자는 선택한 텍스트 부분에 필요한 취소선 유형을 설정하는 데 사용됩니다.
C#을 사용하여 PPTX에서 텍스트를 취소하는 코드
using System; | |
using System.Drawing; | |
using Aspose.Slides; | |
using Aspose.Slides.Export; | |
namespace TestSlides | |
{ | |
public class StrikeThroughText | |
{ | |
public static void StrikeText() | |
{ | |
String path = @"/Users/KnowledgeBase/TestData/"; | |
//Setting the API linence | |
License SlidesLicense = new License(); | |
SlidesLicense.SetLicense(path + "Conholdate.Total.Product.Family.lic"); | |
//Instantiate a Presentation class object to create a presentation | |
using (Presentation presentation = new Presentation()) | |
{ | |
//Insert a Blank empty slide inside the presentation | |
ISlide slide = presentation.Slides.AddEmptySlide(presentation.LayoutSlides.GetByType(SlideLayoutType.Blank)); | |
//Add a new autoshape of the Rectangle type | |
IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 120, 300, 300); | |
// Filling the shape with no fill color | |
autoShape.FillFormat.FillType = FillType.NoFill; | |
//Add the text frame inside the autoshape | |
ITextFrame textFrame = autoShape.AddTextFrame("This is sample strikethrough text"); | |
// Set the textual properties on the portion | |
IPortionFormat portionFormat = textFrame.Paragraphs[0].Portions[0].PortionFormat; | |
portionFormat.FillFormat.FillType = FillType.Solid; | |
portionFormat.FillFormat.SolidFillColor.Color = Color.Red; | |
//Strikethrough with a double line | |
portionFormat.StrikethroughType = TextStrikethroughType.Double; | |
//Add a second line of text inside the shape | |
IPortion secondPortion = new Portion("Second text line "); | |
textFrame.Paragraphs[0].Portions.Add(secondPortion); | |
portionFormat = secondPortion.PortionFormat; | |
portionFormat.FillFormat.FillType = FillType.Solid; | |
portionFormat.FillFormat.SolidFillColor.Color = Color.Blue; | |
//Strikethrouh with a single line | |
portionFormat.StrikethroughType = TextStrikethroughType.Single; | |
// Save the presentation with strikethrough text on the disk | |
presentation.Save(path + "StrikethroughText.pptx", SaveFormat.Pptx); | |
} | |
} | |
} | |
} |
위의 예는 C#*을 사용하여 PPT에서 *취소선 텍스트를 보여줍니다. Presentation 클래스 개체를 사용하여 빈 기본 프레젠테이션을 만들고 Presentation.Slides 속성을 사용하여 슬라이드 모음에서 첫 번째 기본 슬라이드에 액세스합니다. Rectangle 유형의 자동 모양이 만들어지고 그 안에 텍스트가 추가됩니다. 마지막으로 TextStrikethroughType 열거자를 사용하여 필요한 텍스트 눈금이 설정되고 취소선 텍스트가 있는 프레젠테이션이 디스크에 저장됩니다.
이 튜토리얼에서는 *C#*을 사용하여 프레젠테이션 텍스트를 삭제하는 방법을 안내했습니다. 프레젠테이션 내에서 슬라이드를 병합하는 과정을 알아보려면 C#에서 슬라이드를 병합하는 방법의 도움말을 참조하세요.