AutofitType

Свойство TextFrameFormat.AutofitType

Возвращает или устанавливает режим авторазмера текста. Чтение/запись TextAutofitType.

public TextAutofitType AutofitType { get; set; }

Примеры

Следующий пример кода показывает, как изменить размер фигуры, чтобы она соответствовала тексту в презентации PowerPoint.

[C#]
 using (Presentation pres = new Presentation())
{
    ISlide slide = pres.Slides[0];
    IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 30, 30, 350, 100);
    Portion portion = new Portion("lorem ipsum...");
    portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
    portion.PortionFormat.FillFormat.FillType = FillType.Solid;
    autoShape.TextFrame.Paragraphs[0].Portions.Add(portion);
    ITextFrameFormat textFrameFormat = autoShape.TextFrame.TextFrameFormat;
    textFrameFormat.AutofitType = TextAutofitType.Shape;
    pres.Save("Output-presentation.pptx", SaveFormat.Pptx);
}

Следующий пример кода показывает, как уменьшить текст при переполнении.

[C#]
using (Presentation pres = new Presentation())
{
    ISlide slide = pres.Slides[0];
    IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 30, 30, 350, 100);
    Portion portion = new Portion("lorem ipsum...");
    portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;
    portion.PortionFormat.FillFormat.FillType = FillType.Solid;
    autoShape.TextFrame.Paragraphs[0].Portions.Add(portion);
    ITextFrameFormat textFrameFormat = autoShape.TextFrame.TextFrameFormat;
    textFrameFormat.AutofitType = TextAutofitType.Normal;
    pres.Save("Output-presentation.pptx", SaveFormat.Pptx);
}

См. также