ApiExamples.DocumentHelper.CreateTemplateDocumentWithDrawObjects C# (CSharp) Method

CreateTemplateDocumentWithDrawObjects() static private method

Create new document with textbox shape and some query
static private CreateTemplateDocumentWithDrawObjects ( string templateText, ShapeType shapeType ) : Document
templateText string
shapeType ShapeType
return Document
        internal static Document CreateTemplateDocumentWithDrawObjects(string templateText, ShapeType shapeType)
        {
            Document doc = new Document();

            // Create textbox shape.
            Shape shape = new Shape(doc, shapeType);
            shape.Width = 431.5;
            shape.Height = 346.35;

            Paragraph paragraph = new Paragraph(doc);
            paragraph.AppendChild(new Run(doc, templateText));

            // Insert paragraph into the textbox.
            shape.AppendChild(paragraph);

            // Insert textbox into the document.
            doc.FirstSection.Body.FirstParagraph.AppendChild(shape);

            return doc;
        }

Usage Example

Beispiel #1
0
        public void StretchImagefitSize()
        {
            Document doc =
                DocumentHelper.CreateTemplateDocumentWithDrawObjects("<<image [src.ImageStream] -fitSize>>",
                                                                     ShapeType.TextBox);

            ImageTestClass imageStream = new ImageTestBuilder()
                                         .WithImageStream(new FileStream(mImage, FileMode.Open, FileAccess.Read)).Build();

            BuildReport(doc, imageStream, "src", ReportBuildOptions.None);

            doc = DocumentHelper.SaveOpen(doc);

            NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);

            foreach (Shape shape in shapes.OfType <Shape>())
            {
                // Assert that the image is really insert in textbox
                Assert.IsNotNull(shape.Fill.ImageBytes);

                // Assert that height is changed and width is changed
                Assert.AreNotEqual(346.35, shape.Height);
                Assert.AreNotEqual(431.5, shape.Width);
            }
        }
All Usage Examples Of ApiExamples.DocumentHelper::CreateTemplateDocumentWithDrawObjects