public void AddPictureFromFile() { var whale_Location = string.Format("{0}\\{1}.{2}", IMAGE_PATH, WHALE_IMAGE_NAME, WHALE_IMAGE_EXTENSION); var image = _document.AddPicture(whale_Location, "The whale"); Assert.NotNull(image); Assert.True(_document.Paragraphs.Count == 1, "Image not added to the document"); var document_image = _document.Paragraphs[0] as Picture; Assert.True(document_image.Text == "The whale", "Image title is not correct"); Assert.Same(image, _document.Paragraphs[0]); }
private Picture AddPictureFromFile(TextDocument document, string title) { //Add an image with filepath var title_location = string.Format("{0}\\{1}.{2}", IMAGE_PATH, TITLE_IMAGE_NAME, IMAGE_EXTENSION); return(document.AddPicture(title_location, title)); }
private void AddAllContentToDocument(TextDocument document) { AddPictureFromFile(document, "The Title Page"); //Create a paragraph with a header var p = document.AddNamedParagraph("Introduction", SonnetIntroduction(), 1, "1"); p.SetParagraphType("Introdcution"); //Create a paragraph with a header var p1 = document.AddNamedParagraph("Sonnet 1", Sonnet1(), 1, "1"); p1.SetParagraphType("Sonnet"); //Create a paragraph with a header on the level 0. var p0 = document.AddParagraph("Other sonnets", "Other sonnets from Shakespeare", 0); //Now we create a second pargraph as a sub paragraph of the previous one. //As the paragraphs are added sequentialy this paragraph will be directly added after p1 and because the paragraph level is 2 //it will become a subparagraph. var subOfP1 = document.AddNamedParagraph("Sonnet II", Sonnet2(), 2, "2"); subOfP1.SetParagraphType("Sonnet"); //Now we add only a header var header = document.AddParagraph("Sonnet III", string.Empty, 1); //Now add a paragraph with only text var text = document.AddParagraph("The text for sonnet III", 1); //You can also change the text of the paragraph. text.Text = Sonnet3(); //Some basic text styles can also be performed. var styledParagraph = document.AddNamedParagraph("Commentary", CommentarySonnet3(), 1, "4"); styledParagraph.SetParagraphType("Commentary"); AddLinearTableToDocument(document, "Table 1"); AddTableWithDifferentNumberOfColumnsPerRowToDocument(document, "Table 2"); AddTableWithNoColumnDefinitionToDocument(document, "Table 3"); //Add a numbered list AddNumberedList(document, "Name"); //Add the same list but then as a bullet list AddBulletList(document, "Name"); //Add an image AddPictureFromStream(document, "Shakespeare"); //Add an image without a title var picture3 = document.AddPicture(_shakespeareFixtures.Shakespeare, string.Empty); }
private Picture AddPictureFromStream(TextDocument document, string title) { return(document.AddPicture(_shakespeareFixtures.Shakespeare, title)); }