Shape
Contenuti
[
Nascondere
]Shape constructor
Crea un nuovo oggetto forma.
public Shape(DocumentBase doc, ShapeType shapeType)
Parametro | Tipo | Descrizione |
---|---|---|
doc | DocumentBase | Il documento del proprietario. |
shapeType | ShapeType | Il tipo di forma da creare. |
Osservazioni
È necessario specificare le proprietà della forma desiderate dopo aver creato una forma.
Esempi
Mostra come inserire una forma con un’immagine dal file system locale in un documento.
Document doc = new Document();
// Il costruttore pubblico della classe "Shape" creerà una forma con il tipo di markup "ShapeMarkupLanguage.Vml".
// Se è necessario creare una forma di tipo non primitivo, come SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded o DiagonalCornersRounded,
// utilizzare DocumentBuilder.InsertShape.
Shape shape = new Shape(doc, ShapeType.Image);
shape.ImageData.SetImage(ImageDir + "Windows MetaFile.wmf");
shape.Width = 100;
shape.Height = 100;
doc.FirstSection.Body.FirstParagraph.AppendChild(shape);
doc.Save(ArtifactsDir + "Image.FromFile.docx");
Mostra come creare e formattare una casella di testo.
Document doc = new Document();
// Crea una casella di testo mobile.
Shape textBox = new Shape(doc, ShapeType.TextBox);
textBox.WrapType = WrapType.None;
textBox.Height = 50;
textBox.Width = 200;
// Imposta l'allineamento orizzontale e verticale del testo all'interno della forma.
textBox.HorizontalAlignment = HorizontalAlignment.Center;
textBox.VerticalAlignment = VerticalAlignment.Top;
// Aggiunge un paragrafo alla casella di testo e aggiunge una sequenza di testo che verrà visualizzata nella casella di testo.
textBox.AppendChild(new Paragraph(doc));
Paragraph para = textBox.FirstParagraph;
para.ParagraphFormat.Alignment = ParagraphAlignment.Center;
Run run = new Run(doc);
run.Text = "Hello world!";
para.AppendChild(run);
doc.FirstSection.Body.FirstParagraph.AppendChild(textBox);
doc.Save(ArtifactsDir + "Shape.CreateTextBox.docx");
Guarda anche
- class DocumentBase
- enum ShapeType
- class Shape
- spazio dei nomi Aspose.Words.Drawing
- assemblea Aspose.Words