Aspose.Words.Examples.CSharp.Programming_Documents.Working_with_Images.AddImageToEachPage.AddImageToPage C# (CSharp) Метод

AddImageToPage() публичный статический Метод

Adds an image to a page using the supplied paragraph.
public static AddImageToPage ( Paragraph para, int page, String dataDir ) : void
para Paragraph The paragraph to an an image to.
page int The page number the paragraph appears on.
dataDir String
Результат void
        public static void AddImageToPage(Paragraph para, int page, String dataDir)
        {
            Document doc = (Document)para.Document;

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.MoveTo(para);

            // Add a logo to the top left of the page. The image is placed infront of all other text.
            Shape shape = builder.InsertImage(dataDir + "Aspose Logo.png", RelativeHorizontalPosition.Page, 60,
                RelativeVerticalPosition.Page, 60, -1, -1, WrapType.None);

            // Add a textbox next to the image which contains some text consisting of the page number. 
            Shape textBox = new Shape(doc, ShapeType.TextBox);

            // We want a floating shape relative to the page.
            textBox.WrapType = WrapType.None;
            textBox.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
            textBox.RelativeVerticalPosition = RelativeVerticalPosition.Page;

            // Set the textbox position.
            textBox.Height = 30;
            textBox.Width = 200;
            textBox.Left = 150;
            textBox.Top = 80;

            // Add the textbox and set text.
            textBox.AppendChild(new Paragraph(doc));
            builder.InsertNode(textBox);
            builder.MoveTo(textBox.FirstChild);
            builder.Writeln("This is a custom note for page " + page);
        }
    }
AddImageToEachPage