private void defineDocumentStyles()
        {
            //Change the normal style on the document
            MigraDoc.DocumentObjectModel.Style documentStyle = serviceSheetDoc.Styles["Normal"];
            documentStyle.Font.Name = "Verdana";
            documentStyle.Font.Size = 10;

            //Create a style for the section headers
            MigraDoc.DocumentObjectModel.Style sectionHeaderStyle = serviceSheetDoc.Styles.AddStyle("sectionHeader", "Normal");
            sectionHeaderStyle.Font.Size = 10;
            sectionHeaderStyle.Font.Bold = true;

            MigraDoc.DocumentObjectModel.Style timesheetHeaderStyle = serviceSheetDoc.Styles.AddStyle("timesheetHeader", "Normal");
            timesheetHeaderStyle.Font.Size = 18;

            MigraDoc.DocumentObjectModel.Style allCapsFirstLetterStyle = serviceSheetDoc.Styles.AddStyle("allCapsFirstLetter", "Normal");
            allCapsFirstLetterStyle.Font.Size = 11;
            allCapsFirstLetterStyle.Font.Bold = true;

            MigraDoc.DocumentObjectModel.Style allCapsNextLetterStyle = serviceSheetDoc.Styles.AddStyle("allCapsNextLetter", "Normal");
            allCapsNextLetterStyle.Font.Size = 9;
            allCapsNextLetterStyle.Font.Bold = true;

            MigraDoc.DocumentObjectModel.Style footerStyle = serviceSheetDoc.Styles.AddStyle("footerStyle", "Normal");
            footerStyle.Font.Size  = 6;
            footerStyle.Font.Name  = "Arial";
            footerStyle.Font.Color = headerGrey;

            //Document header is different for page 1
            serviceSheetDoc.DefaultPageSetup.DifferentFirstPageHeaderFooter = true;
        }
Esempio n. 2
0
        void DefineStyles()
        {
            // Get the predefined style Normal.
            MigraDoc.DocumentObjectModel.Style style = this.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 = "Calibri";

            style = this.document.Styles[StyleNames.Header];
            style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);

            style = this.document.Styles[StyleNames.Footer];
            style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);

            // Create a new style called Table based on style Normal
            style           = this.document.Styles.AddStyle("Table", "Normal");
            style.Font.Name = "Calibri";
            style.Font.Name = "Calibri";
            style.Font.Size = 11;

            // Create a new style called Reference based on style Normal
            style = this.document.Styles.AddStyle("Reference", "Normal");
            style.ParagraphFormat.SpaceBefore = "5mm";
            style.ParagraphFormat.SpaceAfter  = "5mm";
            style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right);
        }
        public static void DefineStyles(Document document)
        {
            // Get the predefined style Normal.
            MigraDoc.DocumentObjectModel.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 = "Times New Roman";

            // 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["Heading1"];
            style.Font.Name  = "Tahoma";
            style.Font.Size  = 14;
            style.Font.Bold  = true;
            style.Font.Color = Colors.DarkBlue;
            style.ParagraphFormat.PageBreakBefore = true;
            style.ParagraphFormat.SpaceAfter      = 6;

            style           = document.Styles["Heading2"];
            style.Font.Size = 12;
            style.Font.Bold = true;
            style.ParagraphFormat.PageBreakBefore = false;
            style.ParagraphFormat.SpaceBefore     = 6;
            style.ParagraphFormat.SpaceAfter      = 6;

            style             = document.Styles["Heading3"];
            style.Font.Size   = 10;
            style.Font.Bold   = true;
            style.Font.Italic = true;
            style.ParagraphFormat.SpaceBefore = 6;
            style.ParagraphFormat.SpaceAfter  = 3;

            style = document.Styles[StyleNames.Header];
            style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);

            style = document.Styles[StyleNames.Footer];
            style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);

            // Create a new style called TextBox based on style Normal
            style = document.Styles.AddStyle("TextBox", "Normal");
            style.ParagraphFormat.Alignment        = ParagraphAlignment.Justify;
            style.ParagraphFormat.Borders.Width    = 2.5;
            style.ParagraphFormat.Borders.Distance = "3pt";
            style.ParagraphFormat.Shading.Color    = Colors.SkyBlue;

            // Create a new style called TOC based on style Normal
            style = document.Styles.AddStyle("TOC", "Normal");
            style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right, TabLeader.Dots);
            style.ParagraphFormat.Font.Color = Colors.Blue;
        }
Esempio n. 4
0
        private void DefineStyles()
        {
            MigraDoc.DocumentObjectModel.Style style = Pdf.Styles["Normal"];
            style.Font.Name = "Calibri";

            style           = Pdf.Styles.AddStyle("H1-20", "Normal");
            style.Font.Size = 20;
            style.Font.Bold = true;

            style            = Pdf.Styles.AddStyle("H1-20-Red", "H1-20");
            style.Font.Color = Colors.Red;

            style            = Pdf.Styles.AddStyle("H1-20-Green", "H1-20");
            style.Font.Color = Colors.Green;

            style           = Pdf.Styles.AddStyle("H2-8", "Normal");
            style.Font.Size = 8;

            style = Pdf.Styles.AddStyle("H2-8-Blue", "H2-8");
            style.ParagraphFormat.Font.Color = Colors.Blue;

            style           = Pdf.Styles.AddStyle("H2-8B", "H2-8");
            style.Font.Bold = true;

            style           = Pdf.Styles.AddStyle("H2-9", "Normal");
            style.Font.Size = 9;

            style            = Pdf.Styles.AddStyle("H2-9-Grey", "H2-9");
            style.Font.Color = Colors.Gray;

            style           = Pdf.Styles.AddStyle("H2-9B", "H2-9");
            style.Font.Bold = true;

            style = Pdf.Styles.AddStyle("H2-9B-Inverse", "H2-9B");
            style.ParagraphFormat.Font.Color = Colors.White;

            style            = Pdf.Styles.AddStyle("H2-9B-Color", "H2-9B");
            style.Font.Color = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);

            style           = Pdf.Styles.AddStyle("H2-10", "Normal");
            style.Font.Size = 10;

            style            = Pdf.Styles.AddStyle("H2-10-Red", "H2-10");
            style.Font.Color = Colors.Red;

            style           = Pdf.Styles.AddStyle("H2-10B", "H2-10");
            style.Font.Bold = true;

            style            = Pdf.Styles.AddStyle("H2-10B-Color", "H2-10B");
            style.Font.Color = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);
        }
Esempio n. 5
0
 /// <summary>
 /// Ensures that base styles are visited first.
 /// </summary>
 void VisitStyle(Dictionary<Style, object> visitedStyles, Style style, DocumentObjectVisitor visitor, bool visitChildren)
 {
     if (!visitedStyles.ContainsKey(style))
     {
         Style baseStyle = style.GetBaseStyle();
         if (baseStyle != null && !visitedStyles.ContainsKey(baseStyle)) //baseStyle != ""
             VisitStyle(visitedStyles, baseStyle, visitor, visitChildren);
         ((IVisitable)style).AcceptVisitor(visitor, visitChildren);
         visitedStyles.Add(style, null);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Initialize the built-in styles.
        /// </summary>
        internal void SetupStyles()
        {
            Style style;

            // First standard style.
            style = new Style(Style.DefaultParagraphFontName, null);
            style.IsReadOnly = true;
            style._styleType.Value = (int)StyleType.Character;
            style._buildIn.Value = true;
            Add(style);

            // Normal 'Standard' (Paragraph Style).
            style = new Style(Style.DefaultParagraphName, null);
            style._styleType.Value = (int)StyleType.Paragraph;
            style._buildIn.Value = true;
            style.Font.Name = "Arial";  // Not "Verdana" anymore.
            style.Font.Size = 10;
            style.Font.Bold = false;
            style.Font.Italic = false;
            style.Font.Underline = Underline.None;
            style.Font.Color = Colors.Black;
            style.Font.Subscript = false;
            style.Font.Superscript = false;
            style.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            style.ParagraphFormat.FirstLineIndent = 0;
            style.ParagraphFormat.LeftIndent = 0;
            style.ParagraphFormat.RightIndent = 0;
            style.ParagraphFormat.KeepTogether = false;
            style.ParagraphFormat.KeepWithNext = false;
            style.ParagraphFormat.SpaceBefore = 0;
            style.ParagraphFormat.SpaceAfter = 0;
            style.ParagraphFormat.LineSpacing = 10;
            style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Single;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.BodyText;
            style.ParagraphFormat.PageBreakBefore = false;
            style.ParagraphFormat.WidowControl = true;
            Add(style);

            // Heading1 'Überschrift 1' (Paragraph Style).
            style = new Style(StyleNames.Heading1, StyleNames.Normal);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1;
            Add(style);

            // Heading2 'Überschrift 2' (Paragraph Style).
            style = new Style(StyleNames.Heading2, StyleNames.Heading1);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level2;
            Add(style);

            // Heading3 'Überschrift 3' (Paragraph Style).
            style = new Style(StyleNames.Heading3, StyleNames.Heading2);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level3;
            Add(style);

            // Heading4 'Überschrift 4' (Paragraph Style).
            style = new Style(StyleNames.Heading4, StyleNames.Heading3);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level4;
            Add(style);

            // Heading5 'Überschrift 5' (Paragraph Style).
            style = new Style(StyleNames.Heading5, StyleNames.Heading4);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level5;
            Add(style);

            // Heading6 'Überschrift 6' (Paragraph Style).
            style = new Style(StyleNames.Heading6, StyleNames.Heading5);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level6;
            Add(style);

            // Heading7 'Überschrift 7' (Paragraph Style).
            style = new Style(StyleNames.Heading7, StyleNames.Heading6);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level7;
            Add(style);

            // Heading8 'Überschrift 8' (Paragraph Style).
            style = new Style(StyleNames.Heading8, StyleNames.Heading7);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level8;
            Add(style);

            // Heading9 'Überschrift 9' (Paragraph Style).
            style = new Style(StyleNames.Heading9, StyleNames.Heading8);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level9;
            Add(style);

            // List 'Liste' (Paragraph Style).
            style = new Style(StyleNames.List, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // Footnote 'Fußnote' (Paragraph Style).
            style = new Style(StyleNames.Footnote, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // Header 'Kopfzeile' (Paragraph Style).
            style = new Style(StyleNames.Header, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // -33: Footer 'Fußzeile' (Paragraph Style).
            style = new Style(StyleNames.Footer, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // Hyperlink 'Hyperlink' (Character Style).
            style = new Style(StyleNames.Hyperlink, StyleNames.DefaultParagraphFont);
            style._buildIn.Value = true;
            Add(style);

            // InvalidStyleName 'Ungültiger Formatvorlagenname' (Paragraph Style).
            style = new Style(StyleNames.InvalidStyleName, StyleNames.Normal);
            style._buildIn.Value = true;
            style.Font.Bold = true;
            style.Font.Underline = Underline.Dash;
            style.Font.Color = new Color(0xFF00FF00);
            Add(style);
        }
Esempio n. 7
0
        /// <summary>
        /// Adds a new style to the styles collection.
        /// </summary>
        /// <param name="name">Name of the style.</param>
        /// <param name="baseStyleName">Name of the base style.</param>
        public Style AddStyle(string name, string baseStyleName)
        {
            if (name == null || baseStyleName == null)
                throw new ArgumentNullException(name == null ? "name" : "baseStyleName");
            if (name == "" || baseStyleName == "")
                throw new ArgumentException(name == "" ? "name" : "baseStyleName");

            Style style = new Style();
            style._name.Value = name;
            style._baseStyle.Value = baseStyleName;
            Add(style);
            // Add(style) may add a clone of style, therefore we return the style by name.
            return this[name];
        }
Esempio n. 8
0
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Work Order";
        doc.Info.Subject = "Order No:" + oModOrder.GetSetorderno;
        doc.Info.Author  = "B.I.O.App System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "1cm";   //20

        MigraDoc.DocumentObjectModel.Style style = doc.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 = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put Capital Digital logo in the header
        string logo_lima = Server.MapPath("~/images/logo_CD_bgBLUE_BLACK_310x98.png");

        MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
        image.Height             = "1cm";
        image.LockAspectRatio    = true;
        image.RelativeVertical   = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top              = ShapePosition.Top;
        image.Left             = ShapePosition.Right;
        image.WrapFormat.Style = WrapStyle.Through;

        // Put CD logo in the header
        string logo_mod = Server.MapPath("~/images/logo_versi_4.png");

        MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
        image2.Height             = "1.5cm";
        image2.LockAspectRatio    = true;
        image2.RelativeVertical   = RelativeVertical.Line;
        image2.RelativeHorizontal = RelativeHorizontal.Margin;
        image2.Top              = ShapePosition.Top;
        image2.Left             = ShapePosition.Left;
        image2.WrapFormat.Style = WrapStyle.Through;

        // Create Header
        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("WORK ORDER FORM");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("8cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("3cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible  = false;
        rowTop.Borders.Right.Visible = false;
        rowTop.Borders.Top.Visible   = false;
        //rowTop.Borders.Bottom.Visible = false;
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph();
        rowTop.Cells[2].AddParagraph();


        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("From:");
        rowTop.Cells[0].AddParagraph("CAPITAL DIGITAL");
        rowTop.Cells[0].AddParagraph("NO. 1, JALAN BUNGA RAYA 1, LANGKAWI MALL");
        rowTop.Cells[0].AddParagraph("07000 KUAH, LANGKAWI");
        rowTop.Cells[0].AddParagraph("KEDAH DARUL AMAN");
        rowTop.Cells[0].AddParagraph("www.capitaldigital.com.my");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 5;
        rowTop.Cells[1].AddParagraph("Order No");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Date");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderdate);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Type");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetordertype);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Sales Office");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": CAPITAL DIGITAL LANGKAWI");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Sales Person");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": HAZZARUL ANAS");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Contact No");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": +6017-552 4447");
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("");
        rowTop.Cells[0].MergeRight             = 2;
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("To: ");
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpaddress);
        rowTop.Cells[0].AddParagraph("Contact: " + oModOrder.GetSetbpcontact);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Support: ");
        rowTop.Cells[1].AddParagraph("HAZZARUL ANAS HALIM");
        rowTop.Cells[1].AddParagraph("SALES & SUPPORT");
        rowTop.Cells[1].AddParagraph("Contact: +6017-552 4447");
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeRight             = 1;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("0.5cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("4cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("NO.");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[1].AddParagraph("ITEM NO");
        row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[2].AddParagraph("DESCRIPTION");
        row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[3].AddParagraph("UNIT PRICE");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[4].AddParagraph("DISCOUNT");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[5].AddParagraph("QTY");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[6].AddParagraph("PRICE");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[7].AddParagraph("TAX");
        row.Cells[7].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[7].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[8].AddParagraph("TOTAL");
        row.Cells[8].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[8].VerticalAlignment = VerticalAlignment.Bottom;

        for (int i = 0; i < lsOrderLineItem.Count; i++)
        {
            MainModel modOrdDet = (MainModel)lsOrderLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "2cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[7].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[8].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            row1.Cells[1].AddParagraph(modOrdDet.GetSetitemno);
            row1.Cells[2].AddParagraph(modOrdDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modOrdDet.GetSetunitprice.ToString("#,##0.00"));
            row1.Cells[4].AddParagraph(modOrdDet.GetSetdiscamount.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modOrdDet.GetSetquantity.ToString());
            row1.Cells[6].AddParagraph(modOrdDet.GetSetorderprice.ToString("#,##0.00"));
            row1.Cells[7].AddParagraph(modOrdDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[8].AddParagraph(modOrdDet.GetSettotalprice.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 6) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
                row1.Cells[7].Borders.Bottom.Visible = true;
                row1.Cells[8].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
                row1.Cells[7].Borders.Bottom.Visible = false;
                row1.Cells[8].Borders.Bottom.Visible = false;
            }
        }
        if ((lsOrderLineItem.Count % 6) > 0)
        {
            int totalremainingrow = 6 - (lsOrderLineItem.Count % 6);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "2cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();
                rowRemain.Cells[7].AddParagraph();
                rowRemain.Cells[8].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                    rowRemain.Cells[7].Borders.Bottom.Visible = false;
                    rowRemain.Cells[8].Borders.Bottom.Visible = false;
                }
            }
        }

        /*
         * Row rowTax = table.AddRow();
         * //rowTax.Height = "1cm";
         * rowTax.Cells[0].AddParagraph();
         * rowTax.Cells[0].Borders.Left.Visible = false;
         * rowTax.Cells[0].Borders.Right.Visible = false;
         * rowTax.Cells[0].Borders.Bottom.Visible = false;
         * rowTax.Cells[0].MergeRight = 6;
         * rowTax.Cells[7].AddParagraph("TAX");
         * rowTax.Cells[7].Format.Alignment = ParagraphAlignment.Left;
         * rowTax.Cells[8].AddParagraph(oModOrder.GetSettaxamount.ToString("#,##0.00"));
         * rowTax.Cells[8].Format.Alignment = ParagraphAlignment.Right;
         */

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph();
        rowTot.Cells[0].Borders.Left.Visible   = false;
        rowTot.Cells[0].Borders.Right.Visible  = false;
        rowTot.Cells[0].Borders.Bottom.Visible = false;
        rowTot.Cells[0].MergeRight             = 6;

        /*
         * rowTot.Cells[1].AddParagraph();
         * rowTot.Cells[1].Borders.Left.Visible = false;
         * rowTot.Cells[2].AddParagraph();
         * rowTot.Cells[2].Borders.Left.Visible = false;
         * rowTot.Cells[3].AddParagraph();
         * rowTot.Cells[3].Borders.Left.Visible = false;
         * rowTot.Cells[4].AddParagraph();
         * rowTot.Cells[4].Borders.Left.Visible = false;
         * rowTot.Cells[5].AddParagraph();
         * rowTot.Cells[5].Borders.Left.Visible = false;
         * rowTot.Cells[6].AddParagraph();
         * rowTot.Cells[6].Borders.Left.Visible = false;
         */
        rowTot.Cells[6].Borders.Right.Visible = false;

        rowTot.Cells[7].AddParagraph("GRAND TOTAL");
        rowTot.Cells[7].Format.Alignment     = ParagraphAlignment.Left;
        rowTot.Cells[7].VerticalAlignment    = VerticalAlignment.Center;
        rowTot.Cells[7].Borders.Left.Visible = false;
        //rowTot.Cells[7].Borders.Right.Visible = false;
        rowTot.Cells[7].Borders.Bottom.Visible = false;

        rowTot.Cells[8].AddParagraph(oModOrder.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[8].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[8].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Remarks:");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        //rowTblBtm.Borders.Top.Visible = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetorderremarks);
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Height = "2cm";
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("1. Once the order is confirmed, any cancellation and changes of the order is not allowed.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("2. Delivery lead time is 3 working days upon receive the confirmed Work Order & advert content.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("3. All prices are subject to change without any prior notices.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 1;
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        //rowTblBtm.Cells[0].Borders.Top.Visible = true;
        rowTblBtm.Cells[1].AddParagraph("CAPITAL DIGITAL");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Confirmed By: (Please stamp and sign)");
        rowTblBtm.Cells[1].AddParagraph("Checked By:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible          = false;
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Name:");
        rowTblBtm.Cells[1].AddParagraph("Name: HAZZARUL ANAS HALIM");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Designation:");
        rowTblBtm.Cells[1].AddParagraph("Designation: Sales & Marketing Advisor");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Date:");
        rowTblBtm.Cells[1].AddParagraph("Date:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sOrderNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Esempio n. 9
0
        public static byte[] GeneratePdf(Consignment co)
        {
            // Create a MigraDoc document
            Document document = new Document();

            document.DefaultPageSetup.LeftMargin  = Unit.FromCentimeter(1);
            document.DefaultPageSetup.RightMargin = Unit.FromCentimeter(1);
            MigraDoc.DocumentObjectModel.Style style = document.Styles["Normal"];
            style.Font.Name = "Arial";
            style.Font.Size = 10;
            Unit pageWidth = document.DefaultPageSetup.PageWidth;

            pageWidth -= document.DefaultPageSetup.LeftMargin + document.DefaultPageSetup.RightMargin;
            Section section = document.AddSection();

            section.PageSetup.HeaderDistance = Unit.FromMillimeter(5);
            section.PageSetup.TopMargin      = Unit.FromCentimeter(7.5);

            // Add header
            section.PageSetup.StartingNumber = 1;
            HeaderFooter header = section.Headers.Primary;

            Paragraph title = new Paragraph();

            title.Format.Alignment = ParagraphAlignment.Center;
            title.Format.Font.Bold = true;
            title.Format.Font.Size = 32;
            title.AddText("CONSIGNMENT NOTE");
            header.Add(title);

            Table tableHeader = new Table();

            tableHeader.Borders.Width = 0.75;
            tableHeader.TopPadding    = "1mm";
            tableHeader.BottomPadding = "1mm";

            tableHeader.AddColumn("7cm");
            tableHeader.AddColumn("4.2cm");
            tableHeader.AddColumn("2cm");
            tableHeader.AddColumn("2.2cm");
            tableHeader.AddColumn("3cm");

            Row headerRow = tableHeader.AddRow();

            tableHeader.AddRow();
            tableHeader.AddRow();
            tableHeader.AddRow();
            tableHeader.AddRow();
            tableHeader.AddRow();
            tableHeader.AddRow();
            headerRow.Cells[0].MergeDown            = 6;
            headerRow.Cells[1].MergeRight           = 1;
            headerRow.Cells[3].MergeRight           = 1;
            tableHeader.Rows[1].Cells[1].MergeRight = 3;
            tableHeader.Rows[2].Cells[2].MergeRight = 2;
            tableHeader.Rows[3].Cells[2].MergeRight = 1;
            tableHeader.Rows[4].Cells[1].MergeRight = 3;
            tableHeader.Rows[5].Cells[1].MergeRight = 3;
            tableHeader.Rows[6].Cells[1].MergeRight = 3;

            //Paragraph logo = new Paragraph();
            //logo.Format.Alignment = ParagraphAlignment.Left;
            //logo.AddImage(HttpContext.Current.Server.MapPath("~/Images/MyImage.png")).Width = "7cm";
            //headerRow.Cells[0].Add(logo);

            Paragraph campus = headerRow.Cells[1].AddParagraph();

            campus.AddFormattedText("Campus: ", TextFormat.Bold);
            campus.AddText(co.Campus);

            Paragraph locality = headerRow.Cells[3].AddParagraph();

            locality.AddFormattedText("Locality: ", TextFormat.Bold);
            locality.AddText(co.Locality);

            Paragraph contactName = tableHeader.Rows[1].Cells[1].AddParagraph();

            contactName.AddFormattedText("Contact Name: ", TextFormat.Bold);
            contactName.AddText(co.ContactName);

            Paragraph phone = tableHeader.Rows[2].Cells[1].AddParagraph();

            phone.AddFormattedText("Phone: ", TextFormat.Bold);
            phone.AddText("");

            Paragraph email = tableHeader.Rows[2].Cells[2].AddParagraph();

            email.AddFormattedText("Email: ", TextFormat.Bold);
            email.AddText(co.Email);

            Paragraph dateSent = tableHeader.Rows[3].Cells[1].AddParagraph();

            dateSent.AddFormattedText("Date sent: ", TextFormat.Bold);
            dateSent.AddText(co.DispatchDate.ToString("dd/MM/yyyy"));

            Paragraph returnBy = tableHeader.Rows[3].Cells[2].AddParagraph();

            returnBy.AddFormattedText("Return by: ", TextFormat.Bold);
            returnBy.AddText(co.ReturnBy.ToString("dd/MM/yyyy"));

            Paragraph refNum = tableHeader.Rows[3].Cells[4].AddParagraph();

            refNum.AddFormattedText("Ref: ", TextFormat.Bold);
            refNum.AddText(co.ID.ToString());

            Paragraph deliveredTo = tableHeader.Rows[4].Cells[1].AddParagraph();

            deliveredTo.AddFormattedText("Delivered to: ", TextFormat.Bold);
            deliveredTo.AddText(co.CompanyName ?? "");

            tableHeader.Rows[5].Cells[1].AddParagraph().AddFormattedText("Unsold goods to be returned to Widgets Co", TextFormat.Bold);
            tableHeader.Rows[6].Cells[1].AddParagraph(@"Queries to [email protected]
Unsold goods to be returned to Widgets Co Returns");

            header.Add(tableHeader);


            // Add main body
            Table tableItems = new Table();

            tableItems.Borders.Width = 0.75;
            tableItems.AddColumn("3cm");
            tableItems.AddColumn("8cm");
            tableItems.AddColumn("2.5cm");
            tableItems.AddColumn("1.5cm");
            tableItems.AddColumn("1.5cm");
            tableItems.AddColumn("1.5cm");
            tableItems.TopPadding    = "3mm";
            tableItems.BottomPadding = "3mm";

            Row itemsHeader = tableItems.AddRow();

            itemsHeader.Format.Alignment = ParagraphAlignment.Center;
            itemsHeader.Format.Font.Bold = true;
            itemsHeader[0].AddParagraph("CODE");
            itemsHeader[1].AddParagraph("DESCRIPTION");
            itemsHeader[2].AddParagraph("PRICE");
            itemsHeader[3].AddParagraph("QTY");
            itemsHeader[4].AddParagraph("???");
            itemsHeader[5].AddParagraph("???");

            // Add each item
            foreach (var item in co.ConsignmentItems)
            {
                Row itemRow = tableItems.AddRow();
                itemRow[2].Format.Alignment = ParagraphAlignment.Right;
                itemRow[3].Format.Alignment = ParagraphAlignment.Center;
                itemRow[0].AddParagraph(item.StockCode ?? "");
                itemRow[1].AddParagraph(item.Description ?? "");
                itemRow[2].AddParagraph(item.UnitPrice.ToString("£#,##0.00"));
                itemRow[3].AddParagraph(item.Quantity.ToString());
            }
            section.Add(tableItems);


            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);

            renderer.Document = document;

            renderer.RenderDocument();

            MemoryStream ms = new MemoryStream();

            renderer.PdfDocument.Save(ms);
            return(ms.ToArray());
        }
Esempio n. 10
0
        /// <summary>
        /// Writes the Color object in its hexadecimal value.
        /// </summary>
        public override string ToString()
        {
            if (_stdColors == null)
            {
#if !SILVERLIGHT
                Array colorNames = Enum.GetNames(typeof(ColorName));
                Array colorValues = Enum.GetValues(typeof(ColorName));
                int count = colorNames.GetLength(0);
                _stdColors = new Dictionary<uint, string>(count);
                for (int index = 0; index < count; index++)
                {
                    string c = (string)colorNames.GetValue(index);
                    uint d = (uint)colorValues.GetValue(index);
                    // Some color are double named...
                    // Aqua == Cyan
                    // Fuchsia == Magenta
                    Style key = new Style();
                    if (!_stdColors.ContainsKey(d))
                        _stdColors.Add(d, c);
                }
#else
        _stdColors = new Dictionary<uint, string>();
        _stdColors.Add(0xFFF0F8FF, "AliceBlue");
        _stdColors.Add(0xFFFAEBD7, "AntiqueWhite");
        _stdColors.Add(0xFF00FFFF, "Aqua");
        _stdColors.Add(0xFF7FFFD4, "Aquamarine");
        _stdColors.Add(0xFFF0FFFF, "Azure");
        _stdColors.Add(0xFFF5F5DC, "Beige");
        _stdColors.Add(0xFFFFE4C4, "Bisque");
        _stdColors.Add(0xFF000000, "Black");
        _stdColors.Add(0xFFFFEBCD, "BlanchedAlmond");
        _stdColors.Add(0xFF0000FF, "Blue");
        _stdColors.Add(0xFF8A2BE2, "BlueViolet");
        _stdColors.Add(0xFFA52A2A, "Brown");
        _stdColors.Add(0xFFDEB887, "BurlyWood");
        _stdColors.Add(0xFF5F9EA0, "CadetBlue");
        _stdColors.Add(0xFF7FFF00, "Chartreuse");
        _stdColors.Add(0xFFD2691E, "Chocolate");
        _stdColors.Add(0xFFFF7F50, "Coral");
        _stdColors.Add(0xFF6495ED, "CornflowerBlue");
        _stdColors.Add(0xFFFFF8DC, "Cornsilk");
        _stdColors.Add(0xFFDC143C, "Crimson");
        //_stdColors.Add(0xFF00FFFF, "Cyan"); already added as "Aqua"
        _stdColors.Add(0xFF00008B, "DarkBlue");
        _stdColors.Add(0xFF008B8B, "DarkCyan");
        _stdColors.Add(0xFFB8860B, "DarkGoldenrod");
        _stdColors.Add(0xFFA9A9A9, "DarkGray");
        _stdColors.Add(0xFF006400, "DarkGreen");
        _stdColors.Add(0xFFBDB76B, "DarkKhaki");
        _stdColors.Add(0xFF8B008B, "DarkMagenta");
        _stdColors.Add(0xFF556B2F, "DarkOliveGreen");
        _stdColors.Add(0xFFFF8C00, "DarkOrange");
        _stdColors.Add(0xFF9932CC, "DarkOrchid");
        _stdColors.Add(0xFF8B0000, "DarkRed");
        _stdColors.Add(0xFFE9967A, "DarkSalmon");
        _stdColors.Add(0xFF8FBC8B, "DarkSeaGreen");
        _stdColors.Add(0xFF483D8B, "DarkSlateBlue");
        _stdColors.Add(0xFF2F4F4F, "DarkSlateGray");
        _stdColors.Add(0xFF00CED1, "DarkTurquoise");
        _stdColors.Add(0xFF9400D3, "DarkViolet");
        _stdColors.Add(0xFFFF1493, "DeepPink");
        _stdColors.Add(0xFF00BFFF, "DeepSkyBlue");
        _stdColors.Add(0xFF696969, "DimGray");
        _stdColors.Add(0xFF1E90FF, "DodgerBlue");
        _stdColors.Add(0xFFB22222, "Firebrick");
        _stdColors.Add(0xFFFFFAF0, "FloralWhite");
        _stdColors.Add(0xFF228B22, "ForestGreen");
        _stdColors.Add(0xFFFF00FF, "Fuchsia");
        _stdColors.Add(0xFFDCDCDC, "Gainsboro");
        _stdColors.Add(0xFFF8F8FF, "GhostWhite");
        _stdColors.Add(0xFFFFD700, "Gold");
        _stdColors.Add(0xFFDAA520, "Goldenrod");
        _stdColors.Add(0xFF808080, "Gray");
        _stdColors.Add(0xFF008000, "Green");
        _stdColors.Add(0xFFADFF2F, "GreenYellow");
        _stdColors.Add(0xFFF0FFF0, "Honeydew");
        _stdColors.Add(0xFFFF69B4, "HotPink");
        _stdColors.Add(0xFFCD5C5C, "IndianRed");
        _stdColors.Add(0xFF4B0082, "Indigo");
        _stdColors.Add(0xFFFFFFF0, "Ivory");
        _stdColors.Add(0xFFF0E68C, "Khaki");
        _stdColors.Add(0xFFE6E6FA, "Lavender");
        _stdColors.Add(0xFFFFF0F5, "LavenderBlush");
        _stdColors.Add(0xFF7CFC00, "LawnGreen");
        _stdColors.Add(0xFFFFFACD, "LemonChiffon");
        _stdColors.Add(0xFFADD8E6, "LightBlue");
        _stdColors.Add(0xFFF08080, "LightCoral");
        _stdColors.Add(0xFFE0FFFF, "LightCyan");
        _stdColors.Add(0xFFFAFAD2, "LightGoldenrodYellow");
        _stdColors.Add(0xFFD3D3D3, "LightGray");
        _stdColors.Add(0xFF90EE90, "LightGreen");
        _stdColors.Add(0xFFFFB6C1, "LightPink");
        _stdColors.Add(0xFFFFA07A, "LightSalmon");
        _stdColors.Add(0xFF20B2AA, "LightSeaGreen");
        _stdColors.Add(0xFF87CEFA, "LightSkyBlue");
        _stdColors.Add(0xFF778899, "LightSlateGray");
        _stdColors.Add(0xFFB0C4DE, "LightSteelBlue");
        _stdColors.Add(0xFFFFFFE0, "LightYellow");
        _stdColors.Add(0xFF00FF00, "Lime");
        _stdColors.Add(0xFF32CD32, "LimeGreen");
        _stdColors.Add(0xFFFAF0E6, "Linen");
        // _stdColors.Add(0xFFFF00FF, "Magenta"); already added as "Fuchsia"
        _stdColors.Add(0xFF800000, "Maroon");
        _stdColors.Add(0xFF66CDAA, "MediumAquamarine");
        _stdColors.Add(0xFF0000CD, "MediumBlue");
        _stdColors.Add(0xFFBA55D3, "MediumOrchid");
        _stdColors.Add(0xFF9370DB, "MediumPurple");
        _stdColors.Add(0xFF3CB371, "MediumSeaGreen");
        _stdColors.Add(0xFF7B68EE, "MediumSlateBlue");
        _stdColors.Add(0xFF00FA9A, "MediumSpringGreen");
        _stdColors.Add(0xFF48D1CC, "MediumTurquoise");
        _stdColors.Add(0xFFC71585, "MediumVioletRed");
        _stdColors.Add(0xFF191970, "MidnightBlue");
        _stdColors.Add(0xFFF5FFFA, "MintCream");
        _stdColors.Add(0xFFFFE4E1, "MistyRose");
        _stdColors.Add(0xFFFFE4B5, "Moccasin");
        _stdColors.Add(0xFFFFDEAD, "NavajoWhite");
        _stdColors.Add(0xFF000080, "Navy");
        _stdColors.Add(0xFFFDF5E6, "OldLace");
        _stdColors.Add(0xFF808000, "Olive");
        _stdColors.Add(0xFF6B8E23, "OliveDrab");
        _stdColors.Add(0xFFFFA500, "Orange");
        _stdColors.Add(0xFFFF4500, "OrangeRed");
        _stdColors.Add(0xFFDA70D6, "Orchid");
        _stdColors.Add(0xFFEEE8AA, "PaleGoldenrod");
        _stdColors.Add(0xFF98FB98, "PaleGreen");
        _stdColors.Add(0xFFAFEEEE, "PaleTurquoise");
        _stdColors.Add(0xFFDB7093, "PaleVioletRed");
        _stdColors.Add(0xFFFFEFD5, "PapayaWhip");
        _stdColors.Add(0xFFFFDAB9, "PeachPuff");
        _stdColors.Add(0xFFCD853F, "Peru");
        _stdColors.Add(0xFFFFC0CB, "Pink");
        _stdColors.Add(0xFFDDA0DD, "Plum");
        _stdColors.Add(0xFFB0E0E6, "PowderBlue");
        _stdColors.Add(0xFF800080, "Purple");
        _stdColors.Add(0xFFFF0000, "Red");
        _stdColors.Add(0xFFBC8F8F, "RosyBrown");
        _stdColors.Add(0xFF4169E1, "RoyalBlue");
        _stdColors.Add(0xFF8B4513, "SaddleBrown");
        _stdColors.Add(0xFFFA8072, "Salmon");
        _stdColors.Add(0xFFF4A460, "SandyBrown");
        _stdColors.Add(0xFF2E8B57, "SeaGreen");
        _stdColors.Add(0xFFFFF5EE, "SeaShell");
        _stdColors.Add(0xFFA0522D, "Sienna");
        _stdColors.Add(0xFFC0C0C0, "Silver");
        _stdColors.Add(0xFF87CEEB, "SkyBlue");
        _stdColors.Add(0xFF6A5ACD, "SlateBlue");
        _stdColors.Add(0xFF708090, "SlateGray");
        _stdColors.Add(0xFFFFFAFA, "Snow");
        _stdColors.Add(0xFF00FF7F, "SpringGreen");
        _stdColors.Add(0xFF4682B4, "SteelBlue");
        _stdColors.Add(0xFFD2B48C, "Tan");
        _stdColors.Add(0xFF008080, "Teal");
        _stdColors.Add(0xFFD8BFD8, "Thistle");
        _stdColors.Add(0xFFFF6347, "Tomato");
        _stdColors.Add(0x00FFFFFF, "Transparent");
        _stdColors.Add(0xFF40E0D0, "Turquoise");
        _stdColors.Add(0xFFEE82EE, "Violet");
        _stdColors.Add(0xFFF5DEB3, "Wheat");
        _stdColors.Add(0xFFFFFFFF, "White");
        _stdColors.Add(0xFFF5F5F5, "WhiteSmoke");
        _stdColors.Add(0xFFFFFF00, "Yellow");
        _stdColors.Add(0xFF9ACD32, "YellowGreen");
#endif
            }
            if (_isCmyk)
            {
                string s;
                if (Alpha == 100.0)
                    s = String.Format(CultureInfo.InvariantCulture, "CMYK({0:0.##},{1:0.##},{2:0.##},{3:0.##})", C, M, Y, K);
                else
                    s = String.Format(CultureInfo.InvariantCulture, "CMYK({0:0.##},{1:0.##},{2:0.##},{3:0.##},{4:0.##})", Alpha, C, M, Y, K);
                return s;
            }
            else
            {
                if (_stdColors.ContainsKey(_argb))
                    return _stdColors[_argb];
                if ((_argb & 0xFF000000) == 0xFF000000)
                    return "RGB(" +
                           ((_argb & 0xFF0000) >> 16) + "," +
                           ((_argb & 0x00FF00) >> 8) + "," +
                           (_argb & 0x0000FF) + ")";
                return "0x" + _argb.ToString("X");
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Adds a new style to the styles collection.
        /// </summary>
        /// <param name="name">Name of the style.</param>
        /// <param name="baseStyleName">Name of the base style.</param>
        public Style AddStyle(string name, string baseStyleName)
        {
            if (name == null || baseStyleName == null)
            throw new ArgumentNullException(name == null ? "name" : "baseStyleName");
              if (name == "" || baseStyleName == "")
            throw new ArgumentException(name == "" ? "name" : "baseStyleName");

              Style style = new Style();
              style.name.Value = name;
              style.baseStyle.Value = baseStyleName;
              this.Add(style);
              return style;
        }
Esempio n. 12
0
 /// <summary>
 /// Adds a new style to the document styles.
 /// </summary>
 public void Add(Style style)
 {
     Styles.Add(style);
 }
Esempio n. 13
0
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Expenses";
        doc.Info.Subject = "Expenses No:" + oModExpenses.GetSetexpensesno;
        doc.Info.Author  = "B.I.O.App System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "5.5cm"; //20

        MigraDoc.DocumentObjectModel.Style style = doc.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 = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put Capital Digital logo in the header

        /*
         * string logo_lima = Server.MapPath("~/images/logo_CD_bgBLUE_BLACK_310x98.png");
         * MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
         * image.Height = "1cm";
         * image.LockAspectRatio = true;
         * image.RelativeVertical = RelativeVertical.Line;
         * image.RelativeHorizontal = RelativeHorizontal.Margin;
         * image.Top = ShapePosition.Top;
         * image.Left = ShapePosition.Right;
         * image.WrapFormat.Style = WrapStyle.Through;
         */
        // Put CD logo in the header

        /*
         * string logo_mod = Server.MapPath("~/images/logo_versi_4.png");
         * MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
         * image2.Height = "1.5cm";
         * image2.LockAspectRatio = true;
         * image2.RelativeVertical = RelativeVertical.Line;
         * image2.RelativeHorizontal = RelativeHorizontal.Margin;
         * image2.Top = ShapePosition.Top;
         * image2.Left = ShapePosition.Left;
         * image2.WrapFormat.Style = WrapStyle.Through;
         */

        // Create Header

        Paragraph header2 = section.Headers.Primary.AddParagraph();

        header2.AddText(modCompInfo.GetSetcomp_name);
        header2.Format.Font.Size = 8;
        header2.Format.Font.Bold = true;
        header2.Format.Alignment = ParagraphAlignment.Center;

        Paragraph header3 = section.Headers.Primary.AddParagraph();

        header3.AddText(modCompInfo.GetSetcomp_address);
        header3.Format.Font.Size = 7;
        header3.Format.Font.Bold = false;
        header3.Format.Alignment = ParagraphAlignment.Center;

        header3 = section.Headers.Primary.AddParagraph();
        header3.AddText("website: " + modCompInfo.GetSetcomp_website);
        header3.Format.Font.Size = 7;
        header3.Format.Font.Bold = false;
        header3.Format.Alignment = ParagraphAlignment.Center;

        header3 = section.Headers.Primary.AddParagraph();
        header3.AddText("Tel: " + modCompInfo.GetSetcomp_contactno);
        header3.Format.Font.Size = 7;
        header3.Format.Font.Bold = false;
        header3.Format.Alignment = ParagraphAlignment.Center;

        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        header = section.Headers.Primary.AddParagraph();
        header.AddText("VOUCHER BAYARAN");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;


        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("2cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("2cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("2cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("5cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Bayar Kepada: ");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetbpdesc);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[3].AddParagraph("No. Bil & Belanja: ");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetexpensesno);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 2;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetbpaddress);
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetbpcontact);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeDown = 2;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[2].MergeDown = 2;
        rowTop.Cells[3].AddParagraph("Tarikh: ");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetexpensesdate);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[3].AddParagraph("Status: ");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetstatus);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Rujukan: ");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetremarks);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[3].AddParagraph();
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph();
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Jenis Bayaran: ");
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph(oModExpenses.GetSetexpensestype);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[2].AddParagraph();
        rowTop.Cells[2].Borders.Left.Visible   = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;
        rowTop.Cells[2].Borders.Bottom.Visible = false;
        rowTop.Cells[3].AddParagraph("Rujukan:");
        rowTop.Cells[3].Borders.Left.Visible   = false;
        rowTop.Cells[3].Borders.Right.Visible  = false;
        rowTop.Cells[3].Borders.Bottom.Visible = false;
        rowTop.Cells[4].AddParagraph(oModExpenses.GetSetremarks);
        rowTop.Cells[4].Borders.Left.Visible   = false;
        rowTop.Cells[4].Borders.Right.Visible  = false;
        rowTop.Cells[4].Borders.Bottom.Visible = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("1cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("4.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("6cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Height           = "1cm";
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("KETERANGAN ITEM");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[0].MergeRight        = 2;
        row.Cells[3].AddParagraph("QTY");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[4].AddParagraph("HARGA");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[5].AddParagraph("TAX");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Center;
        row.Cells[6].AddParagraph("JUMLAH");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Center;

        for (int i = 0; i < lsExpensesLineItem.Count; i++)
        {
            MainModel modExpDet = (MainModel)lsExpensesLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "1cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            if (oModExpenses.GetSetexpensescat.Equals("PAYMENT_VOUCHER"))
            {
                row1.Cells[1].AddParagraph(oMainCon.getParamDetails("000", modExpDet.GetSetitemno, oModExpenses.GetSetexpensestype, "").GetSetparamdesc);
            }
            else
            {
                row1.Cells[1].AddParagraph(modExpDet.GetSetitemno);
            }
            row1.Cells[2].AddParagraph(modExpDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modExpDet.GetSetquantity.ToString());
            row1.Cells[4].AddParagraph(modExpDet.GetSetexpensesprice.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modExpDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[6].AddParagraph(modExpDet.GetSettotalexpenses.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 10) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
            }
        }
        if ((lsExpensesLineItem.Count % 10) > 0)
        {
            int totalremainingrow = 10 - (lsExpensesLineItem.Count % 10);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "1cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                }
            }
        }

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph("Catatan:");
        rowTot.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
        rowTot.Cells[0].VerticalAlignment = VerticalAlignment.Top;
        rowTot.Cells[0].MergeRight        = 2;

        rowTot.Cells[3].AddParagraph("JUMLAH BESAR");
        rowTot.Cells[3].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[3].VerticalAlignment = VerticalAlignment.Center;
        rowTot.Cells[3].MergeRight        = 2;

        rowTot.Cells[6].AddParagraph(oModExpenses.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[6].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[6].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[1].AddParagraph();
        rowTblBtm.Cells[2].AddParagraph();

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Height           = "1cm";
        rowTblBtm.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.Gray;
        rowTblBtm.Cells[0].AddParagraph("Disediakan Oleh:");
        rowTblBtm.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
        rowTblBtm.Cells[0].VerticalAlignment = VerticalAlignment.Center;
        rowTblBtm.Cells[1].AddParagraph("Disemak Oleh:");
        rowTblBtm.Cells[1].Format.Alignment  = ParagraphAlignment.Left;
        rowTblBtm.Cells[1].VerticalAlignment = VerticalAlignment.Center;
        rowTblBtm.Cells[2].AddParagraph("Diluluskan Oleh:");
        rowTblBtm.Cells[2].Format.Alignment  = ParagraphAlignment.Left;
        rowTblBtm.Cells[2].VerticalAlignment = VerticalAlignment.Center;
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[1].AddParagraph();
        rowTblBtm.Cells[2].AddParagraph();
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Nama:");
        rowTblBtm.Cells[1].AddParagraph("Nama:");
        rowTblBtm.Cells[2].AddParagraph("Nama:");
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Jawatan:");
        rowTblBtm.Cells[1].AddParagraph("Jawatan:");
        rowTblBtm.Cells[2].AddParagraph("Jawatan:");
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Tarikh:");
        rowTblBtm.Cells[1].AddParagraph("Tarikh:");
        rowTblBtm.Cells[2].AddParagraph("Tarikh:");
        //rowTblBtm.Cells[2].Borders.Left.Visible = false;
        //rowTblBtm.Cells[2].Borders.Right.Visible = false;
        //rowTblBtm.Cells[2].Borders.Top.Visible = false;
        //rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sExpensesNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Esempio n. 14
0
 internal StyleRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.style = domObj as Style;
       this.styles = DocumentRelations.GetParent(this.style) as Styles;
 }
Esempio n. 15
0
        public void CreateDocument(List <Recipe> r)
        {
            for (int i = 0; i < r.Count; i++)
            {
                Patient  pa = GetPatient(r[i].PatientId);
                User     u  = GetUser(r[i].DoctorId);
                Medicine m  = GetMedicine(r[i].MedicineId);

                // Create a new MigraDoc document
                Document document = new Document();
                document.Info.Title = "Prescription";


                // Get the predefined style Normal.
                Style style = document.Styles["Normal"];
                style.Font.Name = "Verdana";
                style           = document.Styles[StyleNames.Header];
                style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
                style = document.Styles[StyleNames.Footer];
                style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
                style           = document.Styles.AddStyle("Table", "Normal");
                style.Font.Name = "Verdana";
                style.Font.Name = "Times New Roman";
                style.Font.Size = 9;
                style           = document.Styles.AddStyle("Reference", "Normal");
                style.ParagraphFormat.SpaceBefore = "5mm";
                style.ParagraphFormat.SpaceAfter  = "5mm";
                style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right);


                // Each MigraDoc document needs at least one section.
                Section section = document.AddSection();

                // Put a logo in the header
                Image image = section.Headers.Primary.AddImage("../../Images/bikurofelogo.png");
                image.Height             = "2.5cm";
                image.LockAspectRatio    = true;
                image.RelativeVertical   = RelativeVertical.Line;
                image.RelativeHorizontal = RelativeHorizontal.Margin;
                image.Top              = ShapePosition.Top;
                image.Left             = ShapePosition.Right;
                image.WrapFormat.Style = WrapStyle.Through;


                Paragraph paragraph = section.Footers.Primary.AddParagraph();


                // Create the text frame for the address
                var addressFrame = section.AddTextFrame();
                addressFrame.Height = "3.0cm";
                //addressFrame.Width = "20cm";
                addressFrame.Left = ShapePosition.Center;
                addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
                addressFrame.Top = "5.0cm";
                addressFrame.RelativeVertical = RelativeVertical.Page;

                // Put sender in address frame
                paragraph = addressFrame.AddParagraph(Reverse("מרשם"));
                paragraph.Format.Font.Name  = "Times New Roman";
                paragraph.Format.Font.Size  = 24;
                paragraph.Format.SpaceAfter = 3;


                // Add the print date field
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "8cm";
                paragraph.Style = "Reference";
                //paragraph.AddFormattedText("אאאאאאאאאאא", TextFormat.Bold);
                paragraph.AddTab();
                paragraph.AddText("Prescription, ");
                paragraph.AddDateField("dd.MM.yyyy");


                // Create the item table

                Table table = section.AddTable();
                table.Style = "Table";
                //table.Borders.Color = TableBorder;
                table.Borders.Width       = 0.25;
                table.Borders.Left.Width  = 0.5;
                table.Borders.Right.Width = 0.5;
                table.Rows.LeftIndent     = 0;


                // Before you can add a row, you must define the columns
                Column column = table.AddColumn("1cm");
                column.Format.Alignment = ParagraphAlignment.Center;
                column = table.AddColumn("2.0cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Center;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;
                column = table.AddColumn("2cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                // Create the header of the table

                Row row = table.AddRow();
                row = table.AddRow();
                row.HeadingFormat    = true;
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Format.Font.Bold = true;



                row.Cells[1].AddParagraph(Reverse("מספר פעמים ביום"));

                row.Cells[1].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[2].AddParagraph(Reverse("משך זמן בימים"));

                row.Cells[2].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[3].AddParagraph(Reverse("שם תרופה"));

                row.Cells[3].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[4].AddParagraph(Reverse("מספר תרופה"));

                row.Cells[4].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[5].AddParagraph(Reverse("שם רופא מטפל"));

                row.Cells[5].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[6].AddParagraph(Reverse("מספר זהות"));

                row.Cells[6].Format.Alignment = ParagraphAlignment.Right;

                row.Cells[7].AddParagraph(Reverse("שם חולה"));

                row.Cells[7].Format.Alignment = ParagraphAlignment.Right;

                table.SetEdge(0, 0, 6, 2, Edge.Box, BorderStyle.Single, 0.75);

                Paragraph p = addressFrame.AddParagraph();

                p.AddLineBreak();

                p.AddLineBreak();

                // Each item fills two rows

                Row row1 = table.AddRow();
                row1.TopPadding = 1.5;
                row1.Cells[7].AddParagraph(Reverse(pa.Fname + " " + pa.Lname));
                row1.Cells[6].AddParagraph(pa.PatientId);
                row1.Cells[5].AddParagraph(Reverse(u.Fname + " " + u.Lname));
                row1.Cells[4].AddParagraph(m.Id);
                row1.Cells[3].AddParagraph(m.CommercialName);
                row1.Cells[2].AddParagraph(r[i].PeriodOfUse.ToString());
                row1.Cells[1].AddParagraph(r[i].QuantityPerDay.ToString());

                string pdfFilename = r[i].RecipeId + ".pdf";
                var    pdf         = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.None);
                pdf.Document = document;
                pdf.RenderDocument();
                pdf.Save(pdfFilename);
                Process.Start(pdfFilename);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Initialize the built-in styles.
        /// </summary>
        internal void SetupStyles()
        {
            Style style;

            // First standard style.
            style                  = new Style(Style.DefaultParagraphFontName, null);
            style.IsReadOnly       = true;
            style._styleType.Value = (int)StyleType.Character;
            style._buildIn.Value   = true;
            Add(style);

            // Normal 'Standard' (Paragraph Style).
            style = new Style(Style.DefaultParagraphName, null);
            style._styleType.Value                = (int)StyleType.Paragraph;
            style._buildIn.Value                  = true;
            style.Font.Name                       = "Arial"; // Not "Verdana" anymore.
            style.Font.Size                       = 10;
            style.Font.Bold                       = false;
            style.Font.Italic                     = false;
            style.Font.Underline                  = Underline.None;
            style.Font.Color                      = Colors.Black;
            style.Font.Subscript                  = false;
            style.Font.Superscript                = false;
            style.ParagraphFormat.Alignment       = ParagraphAlignment.Left;
            style.ParagraphFormat.FirstLineIndent = 0;
            style.ParagraphFormat.LeftIndent      = 0;
            style.ParagraphFormat.RightIndent     = 0;
            style.ParagraphFormat.KeepTogether    = false;
            style.ParagraphFormat.KeepWithNext    = false;
            style.ParagraphFormat.SpaceBefore     = 0;
            style.ParagraphFormat.SpaceAfter      = 0;
            style.ParagraphFormat.LineSpacing     = 10;
            style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Single;
            style.ParagraphFormat.OutlineLevel    = OutlineLevel.BodyText;
            style.ParagraphFormat.PageBreakBefore = false;
            style.ParagraphFormat.WidowControl    = true;
            Add(style);

            // Heading1 'Überschrift 1' (Paragraph Style).
            style = new Style(StyleNames.Heading1, StyleNames.Normal);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1;
            Add(style);

            // Heading2 'Überschrift 2' (Paragraph Style).
            style = new Style(StyleNames.Heading2, StyleNames.Heading1);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level2;
            Add(style);

            // Heading3 'Überschrift 3' (Paragraph Style).
            style = new Style(StyleNames.Heading3, StyleNames.Heading2);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level3;
            Add(style);

            // Heading4 'Überschrift 4' (Paragraph Style).
            style = new Style(StyleNames.Heading4, StyleNames.Heading3);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level4;
            Add(style);

            // Heading5 'Überschrift 5' (Paragraph Style).
            style = new Style(StyleNames.Heading5, StyleNames.Heading4);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level5;
            Add(style);

            // Heading6 'Überschrift 6' (Paragraph Style).
            style = new Style(StyleNames.Heading6, StyleNames.Heading5);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level6;
            Add(style);

            // Heading7 'Überschrift 7' (Paragraph Style).
            style = new Style(StyleNames.Heading7, StyleNames.Heading6);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level7;
            Add(style);

            // Heading8 'Überschrift 8' (Paragraph Style).
            style = new Style(StyleNames.Heading8, StyleNames.Heading7);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level8;
            Add(style);

            // Heading9 'Überschrift 9' (Paragraph Style).
            style = new Style(StyleNames.Heading9, StyleNames.Heading8);
            style._buildIn.Value = true;
            style.ParagraphFormat.OutlineLevel = OutlineLevel.Level9;
            Add(style);

            // List 'Liste' (Paragraph Style).
            style = new Style(StyleNames.List, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // Footnote 'Fußnote' (Paragraph Style).
            style = new Style(StyleNames.Footnote, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // Header 'Kopfzeile' (Paragraph Style).
            style = new Style(StyleNames.Header, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // -33: Footer 'Fußzeile' (Paragraph Style).
            style = new Style(StyleNames.Footer, StyleNames.Normal);
            style._buildIn.Value = true;
            Add(style);

            // Hyperlink 'Hyperlink' (Character Style).
            style = new Style(StyleNames.Hyperlink, StyleNames.DefaultParagraphFont);
            style._buildIn.Value = true;
            Add(style);

            // InvalidStyleName 'Ungültiger Formatvorlagenname' (Paragraph Style).
            style = new Style(StyleNames.InvalidStyleName, StyleNames.Normal);
            style._buildIn.Value = true;
            style.Font.Bold      = true;
            style.Font.Underline = Underline.Dash;
            style.Font.Color     = new Color(0xFF00FF00);
            Add(style);
        }
Esempio n. 17
0
        private void btnPDF_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "PDF File (*.pdf)|*.pdf";

            if (saveFileDialog.ShowDialog() == true)
            {
                Document document = new Document();

                String tPdfFont = "Verdana";
                MigraDoc.DocumentObjectModel.Style style = document.Styles["Normal"];
                style.Font.Name = tPdfFont;
                style.Font.Size = 6;

                Section section = document.AddSection();

                Table table = new Table();
                table.Borders.Width = 0.75;

                Column column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column = table.AddColumn(Unit.FromCentimeter(1.5));
                column.Format.Alignment = ParagraphAlignment.Center;

                table.AddColumn(Unit.FromCentimeter(1.5));

                Row row = table.AddRow();
                row.Shading.Color = MigraDoc.DocumentObjectModel.Colors.PaleGoldenrod;
                Cell cell = row.Cells[0];
                cell.AddParagraph("ID");
                cell = row.Cells[1];
                cell.AddParagraph("FN");
                cell = row.Cells[2];
                cell.AddParagraph("LN");
                cell = row.Cells[3];
                cell.AddParagraph("Gender");
                cell = row.Cells[4];
                cell.AddParagraph("DOB");
                cell = row.Cells[5];
                cell.AddParagraph("Address");
                cell = row.Cells[6];
                cell.AddParagraph("City");
                cell = row.Cells[7];
                cell.AddParagraph("ZIP");
                cell = row.Cells[8];
                cell.AddParagraph("Department");
                cell = row.Cells[9];
                cell.AddParagraph("Position");
                cell = row.Cells[10];
                cell.AddParagraph("Salary");

                foreach (var emp in query)
                {
                    row  = table.AddRow();
                    cell = row.Cells[0];
                    cell.AddParagraph(emp.Emp_EmployeeId.ToString());
                    cell = row.Cells[1];
                    cell.AddParagraph(emp.Emp_FirstName);
                    cell = row.Cells[2];
                    cell.AddParagraph(emp.Emp_LastName);
                    cell = row.Cells[3];
                    cell.AddParagraph(emp.Emp_Gender);
                    cell = row.Cells[4];
                    cell.AddParagraph(emp.Emp_BirthOfDate.ToShortDateString());
                    cell = row.Cells[5];
                    cell.AddParagraph(emp.Emp_Address);
                    cell = row.Cells[6];
                    cell.AddParagraph(emp.tblCity.Cit_Name);
                    cell = row.Cells[7];
                    cell.AddParagraph(emp.Emp_PostalCode);
                    cell = row.Cells[8];
                    cell.AddParagraph(emp.tblDepartment.Dep_Name);
                    cell = row.Cells[9];
                    cell.AddParagraph(emp.tblPosition.Pos_Description);
                    cell = row.Cells[10];
                    cell.AddParagraph(Convert.ToDouble(emp.Emp_AnualSalary).ToString("0.##"));
                }

                //table.SetEdge(0, 0, 2, 3, Edge.Box, BorderStyle.Single, 1.5, MigraDoc.DocumentObjectModel.Colors.Black);

                document.LastSection.Add(table);

                PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false,
                                                                          PdfFontEmbedding.Always);

                pdfRenderer.Document = document;

                pdfRenderer.RenderDocument();


                string filename = saveFileDialog.FileName;
                pdfRenderer.PdfDocument.Save(filename);

                Process.Start(filename);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Initialize the built in styles.
        /// </summary>
        internal void SetupStyles()
        {
            Style style;

              // First standard style
              style = new Style(Style.DefaultParagraphFontName, null);
              style.readOnly = true;
              style.styleType.Value = (int)StyleType.Character;
              style.buildIn.Value = true;
              this.Add(style);

              // Normal 'Standard' (Paragraph Style)
              style = new Style(Style.DefaultParagraphName, null);
              style.styleType.Value = (int)StyleType.Paragraph;
              style.buildIn.Value = true;
              style.Font.Name = "Verdana";
              style.Font.Size = 10;
              style.Font.Bold = false;
              style.Font.Italic = false;
              style.Font.Underline = Underline.None;
              style.Font.Color = Colors.Black;
              style.Font.Subscript = false;
              style.Font.Superscript = false;
              style.ParagraphFormat.Alignment = ParagraphAlignment.Left;
              style.ParagraphFormat.FirstLineIndent = 0;
              style.ParagraphFormat.LeftIndent = 0;
              style.ParagraphFormat.RightIndent = 0;
              style.ParagraphFormat.KeepTogether = false;
              style.ParagraphFormat.KeepWithNext = false;
              style.ParagraphFormat.SpaceBefore = 0;
              style.ParagraphFormat.SpaceAfter = 0;
              style.ParagraphFormat.LineSpacing = 10;
              style.ParagraphFormat.LineSpacingRule = LineSpacingRule.Single;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.BodyText;
              style.ParagraphFormat.PageBreakBefore = false;
              style.ParagraphFormat.WidowControl = true;
              this.Add(style);

              // Heading1 'Überschrift 1' (Paragraph Style)
              style = new Style("Heading1", "Normal");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1;
              this.Add(style);

              // Heading2 'Überschrift 2' (Paragraph Style)
              style = new Style("Heading2", "Heading1");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level2;
              this.Add(style);

              // Heading3 'Überschrift 3' (Paragraph Style)
              style = new Style("Heading3", "Heading2");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level3;
              this.Add(style);

              // Heading4 'Überschrift 4' (Paragraph Style)
              style = new Style("Heading4", "Heading3");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level4;
              this.Add(style);

              // Heading5 'Überschrift 5' (Paragraph Style)
              style = new Style("Heading5", "Heading4");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level5;
              this.Add(style);

              // Heading6 'Überschrift 6' (Paragraph Style)
              style = new Style("Heading6", "Heading5");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level6;
              this.Add(style);

              // Heading7 'Überschrift 7' (Paragraph Style)
              style = new Style("Heading7", "Heading6");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level7;
              this.Add(style);

              // Heading8 'Überschrift 8' (Paragraph Style)
              style = new Style("Heading8", "Heading7");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level8;
              this.Add(style);

              // Heading9 'Überschrift 9' (Paragraph Style)
              style = new Style("Heading9", "Heading8");
              style.buildIn.Value = true;
              style.ParagraphFormat.OutlineLevel = OutlineLevel.Level9;
              this.Add(style);

              // List 'Liste' (Paragraph Style)
              style = new Style("List", "Normal");
              style.buildIn.Value = true;
              this.Add(style);

              // Footnote 'Fußnote' (Paragraph Style)
              style = new Style("Footnote", "Normal");
              style.buildIn.Value = true;
              this.Add(style);

              // Header 'Kopfzeile' (Paragraph Style)
              style = new Style("Header", "Normal");
              style.buildIn.Value = true;
              this.Add(style);

              // -33: Footer 'Fußzeile' (Paragraph Style)
              style = new Style("Footer", "Normal");
              style.buildIn.Value = true;
              this.Add(style);

              // Hyperlink 'Hyperlink' (Character Style)
              style = new Style("Hyperlink", "DefaultParagraphFont");
              style.buildIn.Value = true;
              this.Add(style);

              // InvalidStyleName 'Ungültiger Formatvorlagenname' (Paragraph Style)
              style = new Style("InvalidStyleName", "Normal");
              style.buildIn.Value = true;
              style.Font.Bold = true;
              style.Font.Underline = Underline.Dash;
              style.Font.Color = new Color(0xFF00FF00);
              this.Add(style);
        }
Esempio n. 19
0
 /// <summary>
 /// Adds a new style to the document styles.
 /// </summary>
 public void Add(Style style)
 {
   this.Styles.Add(style);
 }
Esempio n. 20
0
    private void generatePDFFile()
    {
        // Create a MigraDoc document
        Document doc = new Document();

        doc.Info.Title   = "Pesanan Agihan";
        doc.Info.Subject = "Order No:" + oModOrder.GetSetorderno;
        doc.Info.Author  = "ZMartPartner System";

        //set page orientation
        doc.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
        doc.DefaultPageSetup.TopMargin      = "7.5cm"; //120
        doc.DefaultPageSetup.BottomMargin   = "8.5cm"; //150
        doc.DefaultPageSetup.LeftMargin     = 40;
        doc.DefaultPageSetup.RightMargin    = 40;
        doc.DefaultPageSetup.HeaderDistance = "1.5cm"; //20
        doc.DefaultPageSetup.FooterDistance = "1cm";   //20

        MigraDoc.DocumentObjectModel.Style style = doc.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 = "Verdana";

        // Create a new style called Table based on style Normal
        style           = doc.Styles.AddStyle("Table", "Normal");
        style.Font.Name = "Verdana";
        style.Font.Name = "Arial";
        style.Font.Size = 8;

        // Each MigraDoc document needs at least one section.
        Section section = doc.AddSection();

        // Put 1st logo in the header
        string logo_lima = Server.MapPath("~/images/" + modCompInfo.GetSetcomp_logo1);

        MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(logo_lima);
        image.Height             = "1cm";
        image.LockAspectRatio    = true;
        image.RelativeVertical   = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top              = ShapePosition.Top;
        image.Left             = ShapePosition.Right;
        image.WrapFormat.Style = WrapStyle.Through;

        // Put 2nd logo in the header
        string logo_mod = Server.MapPath("~/images/" + modCompInfo.GetSetcomp_logo2);

        MigraDoc.DocumentObjectModel.Shapes.Image image2 = section.Headers.Primary.AddImage(logo_mod);
        image2.Height             = "1cm";
        image2.LockAspectRatio    = true;
        image2.RelativeVertical   = RelativeVertical.Line;
        image2.RelativeHorizontal = RelativeHorizontal.Margin;
        image2.Top              = ShapePosition.Top;
        image2.Left             = ShapePosition.Left;
        image2.WrapFormat.Style = WrapStyle.Through;

        // Create Header
        Paragraph header = section.Headers.Primary.AddParagraph();

        header.AddText("PESANAN AGIHAN");
        header.Format.Font.Size = 12;
        header.Format.Font.Bold = true;
        header.Format.Alignment = ParagraphAlignment.Center;

        // Create main section for Sales Order
        //Paragraph main = section.AddParagraph();
        // main = section.AddParagraph();
        //main.Format.SpaceBefore = 1;

        // Create the item table for header
        //MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.AddTable();
        MigraDoc.DocumentObjectModel.Tables.Table tableTop = section.Headers.Primary.AddTable();
        tableTop.Style               = "Table";
        tableTop.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tableTop.Borders.Width       = 0.25;
        tableTop.Borders.Left.Width  = 0.5;
        tableTop.Borders.Right.Width = 0.5;
        tableTop.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column columnTop = tableTop.AddColumn("8cm");

        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("3cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;
        columnTop = tableTop.AddColumn("7cm");
        columnTop.Format.Alignment = ParagraphAlignment.Left;

        Row rowTop = tableTop.AddRow();

        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible   = false;
        rowTop.Borders.Right.Visible  = false;
        rowTop.Borders.Top.Visible    = false;
        rowTop.Borders.Bottom.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Borders.Left.Visible  = false;
        rowTop.Borders.Right.Visible = false;
        rowTop.Borders.Top.Visible   = false;
        //rowTop.Borders.Bottom.Visible = false;
        rowTop.Cells[0].AddParagraph();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph();
        rowTop.Cells[2].AddParagraph();


        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Daripada:");
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_name);
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_address);
        rowTop.Cells[0].AddParagraph(modCompInfo.GetSetcomp_website);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[0].MergeDown = 5;
        rowTop.Cells[1].AddParagraph("No. Pesanan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Tarikh");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetorderdate);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Jenis");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetordertype);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Pejabat Agihan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + modCompInfo.GetSetcomp_name);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[1].AddParagraph("Pegawai Agihan");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + oModOrder.GetSetusername);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("No. Dihubungi");
        rowTop.Cells[1].Borders.Right.Visible = false;
        rowTop.Cells[2].AddParagraph(": " + modCompInfo.GetSetcomp_contactno);
        rowTop.Cells[2].Borders.Left.Visible = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("");
        rowTop.Cells[0].MergeRight             = 2;
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Top.Visible    = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        rowTop = tableTop.AddRow();
        rowTop.Cells[0].AddParagraph("Kepada: ");
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        rowTop.Cells[0].AddParagraph(oModOrder.GetSetbpaddress);
        rowTop.Cells[0].AddParagraph("Hubungi: " + oModOrder.GetSetbpcontact);
        rowTop.Cells[0].Borders.Left.Visible   = false;
        rowTop.Cells[0].Borders.Right.Visible  = false;
        rowTop.Cells[0].Borders.Bottom.Visible = false;
        rowTop.Cells[1].AddParagraph("Support: ");
        rowTop.Cells[1].AddParagraph(modCompInfo.GetSetcomp_contact);
        rowTop.Cells[1].AddParagraph("SALES & SUPPORT");
        rowTop.Cells[1].AddParagraph("Hubungi: " + modCompInfo.GetSetcomp_contactno);
        rowTop.Cells[1].Borders.Left.Visible   = false;
        rowTop.Cells[1].Borders.Right.Visible  = false;
        rowTop.Cells[1].Borders.Bottom.Visible = false;
        rowTop.Cells[1].MergeRight             = 1;
        rowTop.Cells[2].Borders.Right.Visible  = false;

        // Create the item table
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Style               = "Table";
        table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column column = table.AddColumn("0.5cm");

        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("4cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Center;

        column = table.AddColumn("1cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("1.5cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        column = table.AddColumn("2cm");
        column.Format.Alignment = ParagraphAlignment.Right;

        // Create the header of the table
        Row row = table.AddRow();

        row.HeadingFormat    = true;
        row.Format.Alignment = ParagraphAlignment.Center;
        row.Format.Font.Bold = true;
        row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;
        row.Cells[0].AddParagraph("#");
        row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[1].AddParagraph("NO. ITEM");
        row.Cells[1].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[2].AddParagraph("KETERANGAN");
        row.Cells[2].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[3].AddParagraph("HARGA UNIT");
        row.Cells[3].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[3].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[4].AddParagraph("DISKAUN");
        row.Cells[4].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[5].AddParagraph("QTY");
        row.Cells[5].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[6].AddParagraph("HARGA");
        row.Cells[6].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[6].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[7].AddParagraph("TAX");
        row.Cells[7].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[7].VerticalAlignment = VerticalAlignment.Bottom;
        row.Cells[8].AddParagraph("JUMLAH");
        row.Cells[8].Format.Alignment  = ParagraphAlignment.Center;
        row.Cells[8].VerticalAlignment = VerticalAlignment.Bottom;

        for (int i = 0; i < lsOrderLineItem.Count; i++)
        {
            MainModel modOrdDet = (MainModel)lsOrderLineItem[i];

            // Each item fills two rows
            Row row1 = table.AddRow();
            row1.Height     = "2cm";
            row1.TopPadding = 1.5;
            //row1.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row1.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row1.Cells[3].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[4].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[5].Format.Alignment = ParagraphAlignment.Center;
            row1.Cells[6].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[7].Format.Alignment = ParagraphAlignment.Right;
            row1.Cells[8].Format.Alignment = ParagraphAlignment.Right;

            row1.Cells[0].AddParagraph((i + 1).ToString());
            row1.Cells[1].AddParagraph(modOrdDet.GetSetitemno);
            row1.Cells[2].AddParagraph(modOrdDet.GetSetitemdesc);
            row1.Cells[3].AddParagraph(modOrdDet.GetSetunitprice.ToString("#,##0.00"));
            row1.Cells[4].AddParagraph(modOrdDet.GetSetdiscamount.ToString("#,##0.00"));
            row1.Cells[5].AddParagraph(modOrdDet.GetSetquantity.ToString());
            row1.Cells[6].AddParagraph(modOrdDet.GetSetorderprice.ToString("#,##0.00"));
            row1.Cells[7].AddParagraph(modOrdDet.GetSettaxamount.ToString("#,##0.00"));
            row1.Cells[8].AddParagraph(modOrdDet.GetSettotalprice.ToString("#,##0.00"));

            if (i > 0 && ((i + 1) % 6) == 0)
            {
                row1.Cells[0].Borders.Bottom.Visible = true;
                row1.Cells[1].Borders.Bottom.Visible = true;
                row1.Cells[2].Borders.Bottom.Visible = true;
                row1.Cells[3].Borders.Bottom.Visible = true;
                row1.Cells[4].Borders.Bottom.Visible = true;
                row1.Cells[5].Borders.Bottom.Visible = true;
                row1.Cells[6].Borders.Bottom.Visible = true;
                row1.Cells[7].Borders.Bottom.Visible = true;
                row1.Cells[8].Borders.Bottom.Visible = true;
            }
            else
            {
                row1.Cells[0].Borders.Bottom.Visible = false;
                row1.Cells[1].Borders.Bottom.Visible = false;
                row1.Cells[2].Borders.Bottom.Visible = false;
                row1.Cells[3].Borders.Bottom.Visible = false;
                row1.Cells[4].Borders.Bottom.Visible = false;
                row1.Cells[5].Borders.Bottom.Visible = false;
                row1.Cells[6].Borders.Bottom.Visible = false;
                row1.Cells[7].Borders.Bottom.Visible = false;
                row1.Cells[8].Borders.Bottom.Visible = false;
            }
        }
        if ((lsOrderLineItem.Count % 6) > 0)
        {
            int totalremainingrow = 6 - (lsOrderLineItem.Count % 6);
            for (int j = 0; j < totalremainingrow; j++)
            {
                Row rowRemain = table.AddRow();
                rowRemain.Height = "2cm";
                rowRemain.Cells[0].AddParagraph();
                rowRemain.Cells[1].AddParagraph();
                rowRemain.Cells[2].AddParagraph();
                rowRemain.Cells[3].AddParagraph();
                rowRemain.Cells[4].AddParagraph();
                rowRemain.Cells[5].AddParagraph();
                rowRemain.Cells[6].AddParagraph();
                rowRemain.Cells[7].AddParagraph();
                rowRemain.Cells[8].AddParagraph();

                if (j == (totalremainingrow - 1))
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else if (j > 0 && (j % (totalremainingrow - 1)) == 0)
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = true;
                    rowRemain.Cells[1].Borders.Bottom.Visible = true;
                    rowRemain.Cells[2].Borders.Bottom.Visible = true;
                    rowRemain.Cells[3].Borders.Bottom.Visible = true;
                    rowRemain.Cells[4].Borders.Bottom.Visible = true;
                    rowRemain.Cells[5].Borders.Bottom.Visible = true;
                    rowRemain.Cells[6].Borders.Bottom.Visible = true;
                    rowRemain.Cells[7].Borders.Bottom.Visible = true;
                    rowRemain.Cells[8].Borders.Bottom.Visible = true;
                }
                else
                {
                    rowRemain.Cells[0].Borders.Bottom.Visible = false;
                    rowRemain.Cells[1].Borders.Bottom.Visible = false;
                    rowRemain.Cells[2].Borders.Bottom.Visible = false;
                    rowRemain.Cells[3].Borders.Bottom.Visible = false;
                    rowRemain.Cells[4].Borders.Bottom.Visible = false;
                    rowRemain.Cells[5].Borders.Bottom.Visible = false;
                    rowRemain.Cells[6].Borders.Bottom.Visible = false;
                    rowRemain.Cells[7].Borders.Bottom.Visible = false;
                    rowRemain.Cells[8].Borders.Bottom.Visible = false;
                }
            }
        }

        /*
         * Row rowTax = table.AddRow();
         * //rowTax.Height = "1cm";
         * rowTax.Cells[0].AddParagraph();
         * rowTax.Cells[0].Borders.Left.Visible = false;
         * rowTax.Cells[0].Borders.Right.Visible = false;
         * rowTax.Cells[0].Borders.Bottom.Visible = false;
         * rowTax.Cells[0].MergeRight = 6;
         * rowTax.Cells[7].AddParagraph("TAX");
         * rowTax.Cells[7].Format.Alignment = ParagraphAlignment.Left;
         * rowTax.Cells[8].AddParagraph(oModOrder.GetSettaxamount.ToString("#,##0.00"));
         * rowTax.Cells[8].Format.Alignment = ParagraphAlignment.Right;
         */

        Row rowTot = table.AddRow();

        rowTot.Height           = "1cm";
        rowTot.Format.Font.Bold = true;
        rowTot.Cells[0].AddParagraph();
        rowTot.Cells[0].Borders.Left.Visible   = false;
        rowTot.Cells[0].Borders.Right.Visible  = false;
        rowTot.Cells[0].Borders.Bottom.Visible = false;
        rowTot.Cells[0].MergeRight             = 6;

        /*
         * rowTot.Cells[1].AddParagraph();
         * rowTot.Cells[1].Borders.Left.Visible = false;
         * rowTot.Cells[2].AddParagraph();
         * rowTot.Cells[2].Borders.Left.Visible = false;
         * rowTot.Cells[3].AddParagraph();
         * rowTot.Cells[3].Borders.Left.Visible = false;
         * rowTot.Cells[4].AddParagraph();
         * rowTot.Cells[4].Borders.Left.Visible = false;
         * rowTot.Cells[5].AddParagraph();
         * rowTot.Cells[5].Borders.Left.Visible = false;
         * rowTot.Cells[6].AddParagraph();
         * rowTot.Cells[6].Borders.Left.Visible = false;
         */
        rowTot.Cells[6].Borders.Right.Visible = false;

        rowTot.Cells[7].AddParagraph("JUMLAH BESAR");
        rowTot.Cells[7].Format.Alignment     = ParagraphAlignment.Left;
        rowTot.Cells[7].VerticalAlignment    = VerticalAlignment.Center;
        rowTot.Cells[7].Borders.Left.Visible = false;
        //rowTot.Cells[7].Borders.Right.Visible = false;
        rowTot.Cells[7].Borders.Bottom.Visible = false;

        rowTot.Cells[8].AddParagraph(oModOrder.GetSettotalamount.ToString("#,##0.00"));
        rowTot.Cells[8].Format.Alignment  = ParagraphAlignment.Right;
        rowTot.Cells[8].VerticalAlignment = VerticalAlignment.Center;

        //footer.AddText("Footer");
        //footer.Format.Font.Size = 9;
        //footer.Format.Alignment = ParagraphAlignment.Center;

        // Create the item table for footer
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Headers.Primary.AddImage(logo_lima);
        MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.Footers.Primary.AddTable();
        //MigraDoc.DocumentObjectModel.Tables.Table tblBtm = section.AddTable();
        tblBtm.Style               = "Table";
        tblBtm.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.Blue;
        tblBtm.Borders.Width       = 0.25;
        tblBtm.Borders.Left.Width  = 0.5;
        tblBtm.Borders.Right.Width = 0.5;
        tblBtm.Rows.LeftIndent     = 0;

        // Before you can add a row, you must define the columns
        Column colTblBtm = tblBtm.AddColumn("6cm");

        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;
        colTblBtm = tblBtm.AddColumn("6cm");
        colTblBtm.Format.Alignment = ParagraphAlignment.Left;

        Row rowTblBtm = tblBtm.AddRow();

        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Catatan:");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        //rowTblBtm.Borders.Top.Visible = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetorderremarks);
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Height = "2cm";
        //rowTblBtm.Borders.Left.Visible = false;
        //rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("1. Setelah Pesanan Agihan disahkan, sebarang pembatalan dan perubahan pesanan tidak dibenarkan.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("2. Penghantaran item Pesanan Agihan akan dilakukan setelah menerima pengesahan daripada Pejabat Agihan.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible   = false;
        rowTblBtm.Borders.Right.Visible  = false;
        rowTblBtm.Borders.Top.Visible    = false;
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("3. Perubahan pada harga item Pesanan Agihan adalah tertakluk kepada terma & syarat tanpa sebarang notis.");
        rowTblBtm.Cells[0].MergeRight = 2;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Left.Visible  = false;
        rowTblBtm.Borders.Right.Visible = false;
        rowTblBtm.Borders.Top.Visible   = false;
        //rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph();
        rowTblBtm.Cells[0].MergeRight = 1;
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Format.Font.Bold = true;
        rowTblBtm.Cells[0].AddParagraph(oModOrder.GetSetbpdesc);
        //rowTblBtm.Cells[0].Borders.Top.Visible = true;
        rowTblBtm.Cells[1].AddParagraph(modCompInfo.GetSetcomp_name);
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Disahkan Oleh: (Cop dan Tandatangan)");
        rowTblBtm.Cells[1].AddParagraph("Disemak Oleh:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible          = false;
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm.Height = "2cm";
        rowTblBtm        = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Nama:");
        rowTblBtm.Cells[1].AddParagraph("Nama:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Borders.Bottom.Visible = false;
        rowTblBtm.Cells[0].AddParagraph("Jawatan:");
        rowTblBtm.Cells[1].AddParagraph("Jawatan: Pegawai Agihan & Pemasaran");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;
        rowTblBtm = tblBtm.AddRow();
        rowTblBtm.Cells[0].AddParagraph("Tarikh:");
        rowTblBtm.Cells[1].AddParagraph("Tarikh:");
        rowTblBtm.Cells[2].AddParagraph();
        rowTblBtm.Cells[2].Borders.Left.Visible   = false;
        rowTblBtm.Cells[2].Borders.Right.Visible  = false;
        rowTblBtm.Cells[2].Borders.Top.Visible    = false;
        rowTblBtm.Cells[2].Borders.Bottom.Visible = false;

        // Create a renderer for PDF that uses Unicode font encoding
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

        // Set the MigraDoc document
        pdfRenderer.Document = doc;

        // Create the PDF document
        pdfRenderer.RenderDocument();

        // Save the document...
        string pdfFilename = sOrderNo + ".pdf";
        string file        = Server.MapPath("~/App_Data/" + pdfFilename);
        //string file = HttpContext.Current.Server.MapPath("~/pdf/" + pdfFilename);
        //string file = "C:/TEMP/" + pdfFilename;

        // ...and start a viewer //
        //pdfRenderer.Save(file);
        //Process.Start(file);

        // Send PDF to browser //
        MemoryStream stream = new MemoryStream();

        pdfRenderer.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();

        //download file //
        //Response.ContentType = "Application/pdf";
        //Response.AppendHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
        //Response.TransmitFile(file);
        //Response.End();
    }
Esempio n. 21
0
 /// <summary>
 /// Sets a paragraph style.
 /// </summary>
 /// <param name="style">The style.</param>
 /// <param name="ps">The ps.</param>
 private static void SetStyle(Style style, ParagraphStyle ps)
 {
     style.Font.Name = ps.FontFamily;
     style.Font.Size = Unit.FromPoint(ps.FontSize);
     style.Font.Bold = ps.Bold;
     style.Font.Italic = ps.Italic;
     style.Font.Color = ToMigraDocColor(ps.TextColor);
     style.ParagraphFormat.PageBreakBefore = ps.PageBreakBefore;
     style.ParagraphFormat.LeftIndent = Unit.FromPoint(ps.LeftIndentation);
     style.ParagraphFormat.RightIndent = Unit.FromPoint(ps.RightIndentation);
     style.ParagraphFormat.LineSpacing = Unit.FromPoint(ps.LineSpacing);
     style.ParagraphFormat.SpaceBefore = Unit.FromPoint(ps.SpacingBefore);
     style.ParagraphFormat.SpaceAfter = Unit.FromPoint(ps.SpacingAfter);
 }
Esempio n. 22
0
        /// <summary>
        /// Converts Style into DDL.
        /// </summary>
        internal override void Serialize(Serializer serializer)
        {
            // For build-in styles all properties that differ from their default values
            // are serialized.
            // For user-defined styles all non-null properties are serialized.
            //!!!newTHHO 26.07.2007 Modified method for built-in styles.
            //!!!newTHHO 26.07.2007 Modified method for user-defined styles.
            Styles          buildInStyles = Styles.BuildInStyles;
            Style           refStyle      = null;
            Font            refFont       = null;
            ParagraphFormat refFormat     = null;

            serializer.WriteComment(this.comment.Value);
            if (this.buildIn.Value)
            {
                // BaseStyle is never null, but empty only for "Normal" and "DefaultParagraphFont"
                if (this.BaseStyle == "")
                {
                    // case: style is "Normal"
                    if (String.Compare(this.name.Value, Style.DefaultParagraphName, true) != 0)
                    {
                        throw new ArgumentException("Internal Error: BaseStyle not set.");
                    }

                    refStyle  = buildInStyles[buildInStyles.GetIndex(this.Name)];
                    refFormat = refStyle.ParagraphFormat;
                    refFont   = refFormat.Font;
                    string name = DdlEncoder.QuoteIfNameContainsBlanks(this.Name);
                    serializer.WriteLineNoCommit(name);
                }
                else
                {
                    // case: any build-in style except "Normal"
                    refStyle  = buildInStyles[buildInStyles.GetIndex(this.Name)];
                    refFormat = refStyle.ParagraphFormat;
                    refFont   = refFormat.Font;
                    if (String.Compare(this.BaseStyle, refStyle.BaseStyle, true) == 0)
                    {
                        // case: build-in style with unmodified base style name
                        string name = DdlEncoder.QuoteIfNameContainsBlanks(this.Name);
                        serializer.WriteLineNoCommit(name);
                        // It's fine if we have the predefined base style, but ...
                        // ... the base style may have been modified or may even have a modified base style.
                        // Methinks it's wrong to compare with the built-in style, so let's compare with the
                        // real base style:
                        refStyle  = Document.Styles[Document.Styles.GetIndex(this.baseStyle.Value)];
                        refFormat = refStyle.ParagraphFormat;
                        refFont   = refFormat.Font;
                        // Note: we must write "Underline = none" if the base style has "Underline = single" - we cannot
                        // detect this if we compare with the built-in style that has no underline.
                        // Known problem: Default values like "OutlineLevel = Level1" will now be serialized
                        // TODO: optimize...
                    }
                    else
                    {
                        // case: build-in style with modified base style name
                        string name     = DdlEncoder.QuoteIfNameContainsBlanks(this.Name);
                        string baseName = DdlEncoder.QuoteIfNameContainsBlanks(this.BaseStyle);
                        serializer.WriteLine(name + " : " + baseName);
                        refStyle  = Document.Styles[Document.Styles.GetIndex(this.baseStyle.Value)];
                        refFormat = refStyle.ParagraphFormat;
                        refFont   = refFormat.Font;
                    }
                }
            }
            else
            {
                // case: user-defined style; base style always exists

                string name     = DdlEncoder.QuoteIfNameContainsBlanks(this.Name);
                string baseName = DdlEncoder.QuoteIfNameContainsBlanks(this.BaseStyle);
                serializer.WriteLine(name + " : " + baseName);

#if true
                Style refStyle0 = Document.Styles[Document.Styles.GetIndex(this.baseStyle.Value)];
                refStyle  = Document.Styles[this.baseStyle.Value];
                refFormat = refStyle != null ? refStyle.ParagraphFormat : null;
                refFont   = refStyle.Font;
#else
                refFormat = null;
#endif
            }

            serializer.BeginContent();

            if (!this.IsNull("ParagraphFormat"))
            {
                if (!this.ParagraphFormat.IsNull("Font"))
                {
                    this.Font.Serialize(serializer, refFormat != null ? refFormat.Font : null);
                }

                if (this.Type == StyleType.Paragraph)
                {
                    this.ParagraphFormat.Serialize(serializer, "ParagraphFormat", refFormat);
                }
            }

            serializer.EndContent();
        }