수학 텍스트
Contents
[
Hide
]
이 문서에서는 Aspose.Slides for Node.js via Java를 사용하여 수학 텍스트 도형을 작업하고 방정식을 서식 지정하는 방법을 보여줍니다.
수학 텍스트 추가
분수와 피타고라스 공식을 포함하는 수학 도형을 만듭니다.
function addMathText() {
let presentation = new aspose.slides.Presentation();
try {
let slide = presentation.getSlides().get_Item(0);
// 슬라이드에 수학 도형을 추가합니다.
let mathShape = slide.getShapes().addMathShape(0, 0, 720, 150);
// 수학 단락에 접근합니다.
let paragraph = mathShape.getTextFrame().getParagraphs().get_Item(0);
let textPortion = paragraph.getPortions().get_Item(0);
let mathParagraph = textPortion.getMathParagraph();
// 간단한 분수 추가: x / y.
let fraction = new aspose.slides.MathematicalText("x").divide("y");
mathParagraph.add(new aspose.slides.MathBlock(fraction));
// 방정식 추가: c² = a² + b².
let mathBlock = new aspose.slides.MathematicalText("c")
.setSuperscript("2")
.join("=")
.join(new aspose.slides.MathematicalText("a").setSuperscript("2"))
.join("+")
.join(new aspose.slides.MathematicalText("b").setSuperscript("2"));
mathParagraph.add(mathBlock);
presentation.save("math_text.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
수학 텍스트 접근
슬라이드에서 수학 단락을 포함하는 도형을 찾습니다.
function accessMathText() {
let presentation = new aspose.slides.Presentation("math_text.pptx");
try {
let slide = presentation.getSlides().get_Item(0);
// 첫 번째 수학 단락을 포함하는 도형을 찾습니다.
let mathShape = null;
for (let shapeIndex = 0; shapeIndex < slide.getShapes().size(); shapeIndex++) {
let shape = slide.getShapes().get_Item(shapeIndex);
if (java.instanceOf(shape, "com.aspose.slides.IAutoShape")) {
let autoShape = shape;
let textFrame = autoShape.getTextFrame();
if (textFrame != null) {
let hasMath = false;
for (let paragraphIndex = 0; paragraphIndex < textFrame.getParagraphs().getCount(); paragraphIndex++) {
let paragraph = textFrame.getParagraphs().get_Item(paragraphIndex);
for (let portionIndex = 0; portionIndex < paragraph.getPortions().getCount(); portionIndex++) {
let portion = paragraph.getPortions().get_Item(portionIndex);
if (java.instanceOf(portion, "com.aspose.slides.MathPortion")) {
hasMath = true;
break;
}
}
if (hasMath) break;
}
if (hasMath) {
mathShape = autoShape;
break;
}
}
}
}
if (mathShape != null) {
let paragraph = mathShape.getTextFrame().getParagraphs().get_Item(0);
let textPortion = paragraph.getPortions().get_Item(0);
let mathParagraph = textPortion.getMathParagraph();
// ...
}
} finally {
presentation.dispose();
}
}
수학 텍스트 제거
슬라이드에서 수학 도형을 삭제합니다.
function removeMathText() {
let presentation = new aspose.slides.Presentation("math_text.pptx");
try {
let slide = presentation.getSlides().get_Item(0);
// 첫 번째 도형이 수학 도형이라고 가정합니다.
let mathShape = slide.getShapes().get_Item(0);
// 수학 도형을 제거합니다.
slide.getShapes().remove(mathShape);
presentation.save("math_text_removed.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
수학 텍스트 서식 지정
수학 부분에 대한 글꼴 속성을 설정합니다.
function formatMathText() {
let presentation = new aspose.slides.Presentation("math_text.pptx");
try {
let slide = presentation.getSlides().get_Item(0);
// 첫 번째 도형이 수학 도형이라고 가정합니다.
let mathShape = slide.getShapes().get_Item(0);
let paragraph = mathShape.getTextFrame().getParagraphs().get_Item(0);
let textPortion = paragraph.getPortions().get_Item(0);
textPortion.getPortionFormat().setFontHeight(20);
presentation.save("math_text_formatted.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}