Beispiel #1
0
 internal ChartRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.chart = (Chart)domObj;
   this.isInline = DocumentRelations.HasParentOfType(this.chart, typeof(Paragraph)) ||
     RenderInParagraph();
 }
Beispiel #2
0
        internal ImageRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
            : base(domObj, docRenderer)
        {
            this.image = domObj as Image;
              this.filePath = this.image.GetFilePath(this.docRenderer.WorkingDirectory);
              this.isInline = DocumentRelations.HasParentOfType(this.image, typeof(Paragraph)) ||
             RenderInParagraph();

              CalculateImageDimensions();
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the RendererBase class.
        /// </summary>
        internal RendererBase(DocumentObject domObj, RtfDocumentRenderer docRenderer)
        {
            if (enumTranslationTable == null)
            CreateEnumTranslationTable();

              this.docObject = domObj;
              this.docRenderer = docRenderer;
              if (docRenderer != null)
            this.rtfWriter = docRenderer.RtfWriter;
              this.useEffectiveValue = false;
        }
Beispiel #4
0
    static void Main()
    {
      // Create a MigraDoc document
      Document document = CreateDocument();
      document.UseCmykColor = true;

     // string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);

#if true_
      RtfDocumentRenderer renderer = new RtfDocumentRenderer();
      renderer.Render(document, "HelloWorld.rtf", null);
#endif
      
      // ----- Unicode encoding and font program embedding in MigraDoc is demonstrated here -----

      // A flag indicating whether to create a Unicode PDF or a WinAnsi PDF file.
      // This setting applies to all fonts used in the PDF document.
      // This setting has no effect on the RTF renderer.
      const bool unicode = false;

      // An enum indicating whether to embed fonts or not.
      // This setting applies to all font programs used in the document.
      // This setting has no effect on the RTF renderer.
      // (The term 'font program' is used by Adobe for a file containing a font. Technically a 'font file'
      // is a collection of small programs and each program renders the glyph of a character when executed.
      // Using a font in PDFsharp may lead to the embedding of one or more font programms, because each outline
      // (regular, bold, italic, bold+italic, ...) has its own fontprogram)
      const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

      // ----------------------------------------------------------------------------------------

      // Create a renderer for the MigraDoc document.
      PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

      // Associate the MigraDoc document with a renderer
      pdfRenderer.Document = document;

      // Layout and render document to PDF
      pdfRenderer.RenderDocument();

      // Save the document...
      const string filename = "HelloWorld.pdf";
      pdfRenderer.PdfDocument.Save(filename);
      // ...and start a viewer.
      Process.Start(filename);
    }
 internal DateFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.dateField = domObj as DateField;
 }
 internal BorderRendererBase(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
 }
 internal FormattedTextRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _formattedText = domObj as FormattedText;
 }
Beispiel #8
0
 internal BorderRendererBase(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 { }
Beispiel #9
0
 internal BordersRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.borders = domObj as Borders;
 }
Beispiel #10
0
 internal TableRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _table = domObj as Table;
 }
Beispiel #11
0
 internal HyperlinkRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.hyperlink = domObj as Hyperlink;
 }
Beispiel #12
0
 internal InfoFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _infoField = domObj as InfoField;
 }
 internal NumericFieldRendererBase(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _numericField = domObj as NumericFieldBase;
 }
 internal PageFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _pageField = domObj as PageField;
 }
Beispiel #15
0
 internal TabStopsRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.tabStops = domObj as TabStops;
 }
Beispiel #16
0
 public ListInfoRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _listInfo = domObj as ListInfo;
 }
Beispiel #17
0
 internal PageSetupRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _pageSetup = domObj as PageSetup;
 }
Beispiel #18
0
 internal FieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
 }
Beispiel #19
0
 internal RowsRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.rows = domObj as Rows;
 }
Beispiel #20
0
 internal StyleRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _style  = domObj as Style;
     _styles = DocumentRelations.GetParent(_style) as Styles;
 }
Beispiel #21
0
 internal SectionRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _section = domObj as Section;
 }
Beispiel #22
0
 internal RowsRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _rows = domObj as Rows;
 }
 public BookmarkFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.bookmark = domObj as BookmarkField;
 }
Beispiel #24
0
 internal BarcodeRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _barcode = domObj as Barcode;
 }
Beispiel #25
0
 internal ShadingRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.shading = domObj as Shading;
   this.isCellShading = !(DocumentRelations.GetParent(shading) is ParagraphFormat);
 }
Beispiel #26
0
 internal TabStopsRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _tabStops = domObj as TabStops;
 }
Beispiel #27
0
 internal FontRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _font = domObj as Font;
 }
 internal NumPagesFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.numPagesField = domObj as NumPagesField;
 }
 internal SectionPagesFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _sectionPagesField = domObj as SectionPagesField;
 }
Beispiel #30
0
 internal ShapeRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _shape = domObj as Shape;
 }
Beispiel #31
0
 internal StyleRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.style = domObj as Style;
   this.styles = DocumentRelations.GetParent(this.style) as Styles;
 }
Beispiel #32
0
 internal FontRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _font = domObj as Font;
 }
Beispiel #33
0
 internal SectionRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.section = domObj as Section;
 }
Beispiel #34
0
 internal HeaderFooterRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _headerFooter = domObj as HeaderFooter;
 }
 public ListInfoOverrideRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.listInfo = domObj as ListInfo;
 }
Beispiel #36
0
 internal DateFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _dateField = domObj as DateField;
 }
Beispiel #37
0
 public BorderRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.border = domObj as Border;
 }
 public ListInfoOverrideRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.listInfo = domObj as ListInfo;
 }
Beispiel #39
0
 internal ShapeRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.shape = domObj as Shape;
 }
 internal TabStopRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _tabStop = domObj as TabStop;
 }
Beispiel #41
0
 public ParagraphRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _paragraph = domObj as Paragraph;
 }
 internal CellFormatRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.cell = domObj as Cell;
 }
Beispiel #43
0
 internal CellRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _cell = domObj as Cell;
 }
Beispiel #44
0
 public ParagraphRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.paragraph = domObj as Paragraph;
 }
Beispiel #45
0
 /// <summary>
 ///   Creates a new instance of the CharacterRenderer class.
 /// </summary>
 internal CharacterRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _character = domObj as Character;
 }
        /// <summary>
        /// Dynamically creates a renderer for the given document object.
        /// </summary>
        internal static RendererBase CreateRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
        {
            switch (domObj.GetType().Name)
            {
            case "Style":
                return(new StyleRenderer(domObj, docRenderer));

            case "ParagraphFormat":
                return(new ParagraphFormatRenderer(domObj, docRenderer));

            case "Font":
                return(new FontRenderer(domObj, docRenderer));

            case "Borders":
                return(new BordersRenderer(domObj, docRenderer));

            case "Border":
                return(new BorderRenderer(domObj, docRenderer));

            case "TabStops":
                return(new TabStopsRenderer(domObj, docRenderer));

            case "TabStop":
                return(new TabStopRenderer(domObj, docRenderer));

            case "Section":
                return(new SectionRenderer(domObj, docRenderer));

            case "PageSetup":
                return(new PageSetupRenderer(domObj, docRenderer));

            case "Paragraph":
                return(new ParagraphRenderer(domObj, docRenderer));

            case "Text":
                return(new TextRenderer(domObj, docRenderer));

            case "FormattedText":
                return(new FormattedTextRenderer(domObj, docRenderer));

            case "Character":
                return(new CharacterRenderer(domObj, docRenderer));

            //Fields start
            case "BookmarkField":
                return(new BookmarkFieldRenderer(domObj, docRenderer));

            case "PageField":
                return(new PageFieldRenderer(domObj, docRenderer));

            case "PageRefField":
                return(new PageRefFieldRenderer(domObj, docRenderer));

            case "NumPagesField":
                return(new NumPagesFieldRenderer(domObj, docRenderer));

            case "SectionField":
                return(new SectionFieldRenderer(domObj, docRenderer));

            case "SectionPagesField":
                return(new SectionPagesFieldRenderer(domObj, docRenderer));

            case "InfoField":
                return(new InfoFieldRenderer(domObj, docRenderer));

            case "DateField":
                return(new DateFieldRenderer(domObj, docRenderer));

            //Fields end
            case "Hyperlink":
                return(new HyperlinkRenderer(domObj, docRenderer));

            case "Footnote":
                return(new FootnoteRenderer(domObj, docRenderer));

            case "ListInfo":
                return(new ListInfoRenderer(domObj, docRenderer));

            case "Image":
                return(new ImageRenderer(domObj, docRenderer));

            case "TextFrame":
                return(new TextFrameRenderer(domObj, docRenderer));

            case "Chart":
                return(new ChartRenderer(domObj, docRenderer));

            case "HeadersFooters":
                return(new HeadersFootersRenderer(domObj, docRenderer));

            case "HeaderFooter":
                return(new HeaderFooterRenderer(domObj, docRenderer));

            case "PageBreak":
                return(new PageBreakRenderer(domObj, docRenderer));

            //Table
            case "Table":
                return(new TableRenderer(domObj, docRenderer));

            case "Row":
                return(new RowRenderer(domObj, docRenderer));

            case "Cell":
                return(new CellRenderer(domObj, docRenderer));
                //Table end
            }
            return(null);
        }
Beispiel #47
0
 internal PageBreakRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
 }
Beispiel #48
0
 internal SectionPagesFieldRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _sectionPagesField = domObj as SectionPagesField;
 }
Beispiel #49
0
 internal TextRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
   this.text = domObj as Text;
 }
Beispiel #50
0
 /// <summary>
 ///   Creates a new instance of the CharacterRenderer class.
 /// </summary>
 internal CharacterRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _character = domObj as Character;
 }
 internal StyleAndFormatRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
   : base(domObj, docRenderer)
 {
 }
Beispiel #52
0
 internal TextRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.text = domObj as Text;
 }
 internal HeadersFootersRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _headersFooters = domObj as HeadersFooters;
 }
Beispiel #54
0
 public FootnoteRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _footnote = domObj as Footnote;
 }
 /// <summary>
 /// Initializes a new instance of the Paragraph Renderer class.
 /// </summary>
 internal ParagraphFormatRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _format = domObj as ParagraphFormat;
 }
 internal HyperlinkRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     _hyperlink = domObj as Hyperlink;
 }
Beispiel #57
0
        /// <summary>
        /// Write the summary report to the specified writer.
        /// </summary>
        /// <param name="dataStore">The data store to write a summary report from</param>
        /// <param name="simulationName">The simulation name to produce a summary report for</param>
        /// <param name="writer">Text writer to write to</param>
        /// <param name="apsimSummaryImageFileName">The file name for the logo. Can be null</param>
        /// <param name="outtype">Indicates the format to be produced</param>
        public static void WriteReport(
            DataStore dataStore,
            string simulationName,
            TextWriter writer,
            string apsimSummaryImageFileName,
            OutputType outtype)
        {
            Document document = null;
            RtfDocumentRenderer renderer = null;

            if (outtype == OutputType.html)
            {
                writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                writer.WriteLine("<html>");
                writer.WriteLine("<head>");
                writer.WriteLine("<meta content='text/html; charset=UTF-8; http-equiv='content-type'>");
                writer.WriteLine("<style>");
                writer.WriteLine("h2 { color:darkblue; } ");
                writer.WriteLine("h3 { color:darkblue; } ");
                writer.WriteLine("table { border:1px solid black; border-collapse:collapse; width:100%; table-layout:fixed; text-align:left; }");
                writer.WriteLine("table.headered {text-align:right; }");
                writer.WriteLine("tr.total { color:darkorange; font-weight:bold; }");
                writer.WriteLine("table.headered td.col1 { text-align:left; font-weight:bold; }");
                writer.WriteLine("td { border:1px solid; }");
                writer.WriteLine("th { border:1px solid; text-align:right; background-color: palegoldenrod}");
                writer.WriteLine("th.col1 { text-align:left; }");
                writer.WriteLine("</style>");
                writer.WriteLine("</head>");
                writer.WriteLine("<body>");
            }
            else if (outtype == OutputType.rtf)
            {
                document = new Document();
                renderer = new RtfDocumentRenderer();

                // Get the predefined style Normal.
                Style style = document.Styles["Normal"];

                // Because all styles are derived from Normal, the next line changes the
                // font of the whole document. Or, more exactly, it changes the font of
                // all styles and paragraphs that do not redefine the font.
                style.Font.Name = "Arial";

                // Heading1 to Heading9 are predefined styles with an outline level. An outline level
                // other than OutlineLevel.BodyText automatically creates the outline (or bookmarks)
                // in PDF.
                style = document.Styles["Heading2"];
                style.Font.Size = 14;
                style.Font.Bold = true;
                style.Font.Color = Colors.DarkBlue;
                style.ParagraphFormat.PageBreakBefore = false;
                style.ParagraphFormat.SpaceAfter = 3;
                style.ParagraphFormat.SpaceBefore = 16;

                style = document.Styles["Heading3"];
                style.Font.Size = 12;
                style.Font.Bold = true;
                style.Font.Color = Colors.DarkBlue;
                style.ParagraphFormat.SpaceBefore = 10;
                style.ParagraphFormat.SpaceAfter = 2;

                // Create a new style called Monospace based on style Normal
                style = document.Styles.AddStyle("Monospace", "Normal");
                System.Drawing.FontFamily monoFamily = new System.Drawing.FontFamily(System.Drawing.Text.GenericFontFamilies.Monospace);
                style.Font.Name = monoFamily.Name;
                Section section = document.AddSection();
            }

            // Get the initial conditions table.
            DataTable initialConditionsTable = dataStore.GetData(simulationName, "InitialConditions");
            if (initialConditionsTable != null)
            {
                // Convert the 'InitialConditions' table in the DataStore to a series of
                // DataTables for each model.
                List<DataTable> tables = new List<DataTable>();
                ConvertInitialConditionsToTables(initialConditionsTable, tables);

                // Now write all tables to our report.
                for (int i = 0; i < tables.Count; i += 2)
                {
                    // Only write something to the summary file if we have something to write.
                    if (tables[i].Rows.Count > 0 || tables[i + 1].Rows.Count > 0)
                    {
                        string heading = tables[i].TableName;
                        WriteHeading(writer, heading, outtype, document);

                        // Write the manager script.
                        if (tables[i].Rows.Count == 1 && tables[i].Rows[0][0].ToString() == "Script code: ")
                        {
                            WriteScript(writer, tables[i].Rows[0], outtype, document);
                        }
                        else
                        {
                            // Write the properties table if we have any properties.
                            if (tables[i].Rows.Count > 0)
                            {
                                WriteTable(writer, tables[i], outtype, "PropertyTable", document);
                            }

                            // Write the general data table if we have any data.
                            if (tables[i + 1].Rows.Count > 0)
                            {
                                WriteTable(writer, tables[i + 1], outtype, "ApsimTable", document);
                            }
                        }

                        if (outtype == OutputType.html)
                            writer.WriteLine("<br/>");
                    }
                }
            }

            // Write out all messages.
            WriteHeading(writer, "Simulation log:", outtype, document);
            DataTable messageTable = GetMessageTable(dataStore, simulationName);
            WriteMessageTable(writer, messageTable, outtype, false, "MessageTable", document);

            if (outtype == OutputType.html)
            {
                writer.WriteLine("</body>");
                writer.WriteLine("</html>");
            }
            else if (outtype == OutputType.rtf)
            {
                string rtf = renderer.RenderToString(document, Path.GetTempPath());
                writer.Write(rtf);
            }
        }
Beispiel #58
0
 internal PageBreakRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
 }
Beispiel #59
0
    /// <summary>
    /// Creates a RTF file from the current document.
    /// </summary>
    private void miRtf_Click(object sender, System.EventArgs e)
    {
      RtfDocumentRenderer rtf = new RtfDocumentRenderer();
      rtf.Render(this.pagePreview.Document, "test.rtf", null);

      Process.Start("test.rtf");
    }
 public BorderRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.border = domObj as Border;
 }