Example #1
0
        public void DrawTextBoxTest()
        {
            TextDocument textdocument = new TextDocument();

            textdocument.New();
            Paragraph   pOuter       = ParagraphBuilder.CreateStandardTextParagraph(textdocument);
            DrawTextBox drawTextBox  = new DrawTextBox(textdocument);
            Frame       frameTextBox = new Frame(textdocument, "fr_txt_box");

            frameTextBox.DrawName = "fr_txt_box";
            frameTextBox.ZIndex   = "0";
            //			Paragraph pTextBox				= ParagraphBuilder.CreateStandardTextParagraph(textdocument);
            //			pTextBox.StyleName				= "Illustration";
            Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument);

            p.StyleName = "Illustration";
            Frame frame = new Frame(textdocument, "frame1",
                                    "graphic1", new DiskFile(_imagefile));

            frame.ZIndex = "1";
            p.Content.Add(frame);
            p.TextContent.Add(new SimpleText(textdocument, "Illustration"));
            drawTextBox.Content.Add(p);

            frameTextBox.SvgWidth = frame.SvgWidth;
            drawTextBox.MinWidth  = frame.SvgWidth;
            drawTextBox.MinHeight = frame.SvgHeight;
            frameTextBox.Content.Add(drawTextBox);
            pOuter.Content.Add(frameTextBox);
            textdocument.Content.Add(pOuter);
            using (IPackageWriter writer = new OnDiskPackageWriter())
            {
                textdocument.Save(AARunMeFirstAndOnce.outPutFolder + "drawTextbox.odt", new OpenDocumentTextExporter(writer));
            }
        }
Example #2
0
        public void DrawTextBox()
        {
            //New TextDocument
            TextDocument textdocument = new TextDocument();

            textdocument.New();
            //Standard Paragraph
            Paragraph paragraphOuter = new Paragraph(textdocument, ParentStyles.Standard.ToString());
            //Create Frame for DrawTextBox
            Frame frameOuter = new Frame(textdocument, "frame1");
            //Create DrawTextBox
            DrawTextBox drawTextBox = new DrawTextBox(textdocument);
            //Create a paragraph for the drawing frame
            Paragraph paragraphInner = new Paragraph(textdocument, ParentStyles.Standard.ToString());
            //Create the frame with the Illustration resp. Graphic
            Frame frameIllustration = new Frame(textdocument, "frame2", "graphic1", new DiskFile(_imagefile));

            //Add Illustration frame to the inner Paragraph
            paragraphInner.Content.Add(frameIllustration);
            //Add inner Paragraph to the DrawTextBox
            drawTextBox.Content.Add(paragraphInner);
            //Add the DrawTextBox to the outer Frame
            frameOuter.Content.Add(drawTextBox);
            //Add the outer Frame to the outer Paragraph
            paragraphOuter.Content.Add(frameOuter);
            //Add the outer Paragraph to the TextDocument
            textdocument.Content.Add(paragraphOuter);
            //Save the document
            using (IPackageWriter writer = new OnDiskPackageWriter())
            {
                textdocument.Save(_framefile2, new OpenDocumentTextExporter(writer));
            }
        }
Example #3
0
        /// <summary>
        /// Gets the picture in OOXMLFormat
        /// </summary>
        /// <param name="doc">The document to add the image to</param>
        /// <param name="index">The index of the image in the list of pargraphs.
        /// This is used for generating an identifier for the image</param>
        /// <param name="imageCount">The number of images in the document.
        ///  This is needed for the caption number</param>
        /// <returns>Picture in OOXML Document</returns>
        public List <AODL.Document.Content.IContent> GetODFParagraph(AODL.Document.TextDocuments.TextDocument doc, int index, ref int imageCount)
        {
            //Create a string with the filename to use.
            //This is the given filename or a temp file if there is only an image.
            string tempFileName = _filePath;

            if (string.IsNullOrEmpty(tempFileName))
            {
                //If there is only an image and not a filepath create a tempfile.
                string dir = string.Format("{0}\\DocumentGenerator", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                tempFileName = string.Format("{0}\\Image{1}.jpg", dir, index);
                _image.Save(tempFileName);
            }

            //Create the main paragraph.
            AODL.Document.Content.Text.Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(doc);
            if (!string.IsNullOrEmpty(_text))
            {
                //Draw the text box for the label
                var drawTextBox  = new DrawTextBox(doc);
                var frameTextBox = new AODL.Document.Content.Draw.Frame(doc, "fr_txt_box")
                {
                    DrawName = "fr_txt_box", ZIndex = "0"
                };
                //Create the paragraph for the image
                var pInner = ParagraphBuilder.CreateStandardTextParagraph(doc);
                pInner.StyleName = "Illustration";
                //Create the image frame
                var frame = new AODL.Document.Content.Draw.Frame(doc, "frame1", string.Format("graphic{0}", index), tempFileName)
                {
                    ZIndex = "1"
                };
                //Add the frame.
                pInner.Content.Add(frame);
                //Add the title
                pInner.TextContent.Add(new SimpleText(doc, _text));
                //Draw the text and image in the box.
                drawTextBox.Content.Add(pInner);
                frameTextBox.SvgWidth = frame.SvgWidth;
                drawTextBox.MinWidth  = frame.SvgWidth;
                drawTextBox.MinHeight = frame.SvgHeight;
                frameTextBox.Content.Add(drawTextBox);
                p.Content.Add(frameTextBox);
            }
            else
            {
                //Create a frame with the image.
                var frame = new AODL.Document.Content.Draw.Frame(doc, "Frame1", string.Format("graphic{0}", index), tempFileName);
                p.Content.Add(frame);
            }

            //Finally delete image file if it is a temp file.
            //if (tempFileName != _filePath) File.Delete(tempFileName);

            return(new List <AODL.Document.Content.IContent> {
                p
            });
        }