Example #1
0
        private void AppendBulletedList(Section section)
        {
            Paragraph paragraph = null;

            paragraph = section.AddParagraph();

            //Append Text
            paragraph.AppendText("Bulleted List");

            paragraph.ApplyStyle(BuiltinStyle.Heading3);

            paragraph = section.AddParagraph();
            for (int i = 0; i < 5; i++)
            {
                paragraph = section.AddParagraph();
                paragraph.AppendText("Item" + i.ToString());

                if (i == 0)
                {
                    paragraph.ListFormat.ApplyBulletStyle();
                }
                else
                {
                    paragraph.ListFormat.ContinueListNumbering();
                }

                paragraph.ListFormat.ListLevelNumber = 1;
            }
        }
Example #2
0
        private void InsertTextbox(Section section)
        {
            Paragraph paragraph
                = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
            paragraph.AppendText("The sample demonstrates how to insert a textbox into a document.");
            paragraph.ApplyStyle(BuiltinStyle.Heading2);

            paragraph = section.AddParagraph();
            paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left;
            Spire.Doc.Fields.TextBox textBox = paragraph.AppendTextBox(50,20);
        }
Example #3
0
        private void InsertImage(Section section)
        {
            Paragraph paragraph
                = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
            paragraph.AppendText("The sample demonstrates how to insert a image into a document.");
            paragraph.ApplyStyle(BuiltinStyle.Heading2);

            paragraph = section.AddParagraph();
            paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left;
            paragraph.AppendPicture(Image.Properties.Resources.Word);
        }
Example #4
0
        private void AppendIndentationText(Section section)
        {
            Paragraph paragraph = null;

            paragraph = section.AddParagraph();

            //Append Text
            paragraph.AppendText("Indentation");

            paragraph.ApplyStyle(BuiltinStyle.Heading3);

            paragraph = section.AddParagraph();
            paragraph.AppendText("Indentation is the spacing between text and margins. Word allows you to set left and right margins, as well as indentations for the first line of a paragraph and hanging indents");
            paragraph.Format.FirstLineIndent = 15;
        }
Example #5
0
        private void AppendAligmentText(Section section)
        {
            Paragraph paragraph = null;

            paragraph = section.AddParagraph();

            //Append Text
            paragraph.AppendText("Horizontal Aligenment");

            paragraph.ApplyStyle(BuiltinStyle.Heading3);

            foreach (Spire.Doc.Documents.HorizontalAlignment align in Enum.GetValues(typeof(Spire.Doc.Documents.HorizontalAlignment)))
            {
                Paragraph paramgraph = section.AddParagraph();
                paramgraph.AppendText("This text is " + align.ToString());
                paramgraph.Format.HorizontalAlignment = align;
            }
        }
Example #6
0
        private void InsertHyberlink(Section section)
        {
            Paragraph paragraph
                = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
            paragraph.AppendText("Spire.XLS for .NET \r\n e-iceblue company Ltd. 2002-2010 All rights reserverd");
            paragraph.ApplyStyle(BuiltinStyle.Heading2);

            paragraph = section.AddParagraph();
            paragraph.AppendText("Home page");
            paragraph.ApplyStyle(BuiltinStyle.Heading2);
            paragraph = section.AddParagraph();
            paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);

            paragraph = section.AddParagraph();
            paragraph.AppendText("Contact US");
            paragraph.ApplyStyle(BuiltinStyle.Heading2);
            paragraph = section.AddParagraph();
            paragraph.AppendHyperlink("mailto:[email protected]", "*****@*****.**", HyperlinkType.EMailLink);
        }
Example #7
0
        private void InsertContent(Section section)
        {
            ParagraphStyle list = new ParagraphStyle(section.Document);
            list.Name = "list";
            list.CharacterFormat.FontName = "Arial";
            list.CharacterFormat.FontSize = 11;
            list.ParagraphFormat.LineSpacing = 1.5F * 12F;
            list.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
            section.Document.Styles.Add(list);

            Paragraph title = section.AddParagraph();

            //next page
            title.AppendBreak(BreakType.PageBreak);
            TextRange text = title.AppendText("Field type list:");
            title.ApplyStyle(list.Name);

            bool first = true;
            foreach (FieldType type in Enum.GetValues(typeof(FieldType)))
            {
                if (type == FieldType.FieldUnknown
                    || type == FieldType.FieldNone || type == FieldType.FieldEmpty)
                {
                    continue;
                }
                Paragraph paragraph = section.AddParagraph();
                paragraph.AppendText(String.Format("{0} is supported in Spire.Doc", type));

                if (first)
                {
                    paragraph.ListFormat.ApplyNumberedStyle();
                    first = false;
                }
                else
                {
                    paragraph.ListFormat.ContinueListNumbering();
                }
                paragraph.ApplyStyle(list.Name);
            }
        }
Example #8
0
        private void InsertWatermark(Section section)
        {
            Paragraph paragraph
                = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
            paragraph.AppendText("The sample demonstrates how to insert a watermark into a document.");
            paragraph.ApplyStyle(BuiltinStyle.Heading2);

            TextWatermark txtWatermark = new TextWatermark();
            txtWatermark.Text = "Watermark Demo";
            txtWatermark.FontSize = 90;
            txtWatermark.Layout = WatermarkLayout.Diagonal;
            section.Document.Watermark = txtWatermark;
        }
Example #9
0
        private void Bookmark(Section section)
        {
            Paragraph paragraph
                = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
            paragraph.AppendText("The sample demonstrates how to using bookmark.");
            paragraph.ApplyStyle(BuiltinStyle.Heading2);

            section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph.AppendText("Simple bookmark.");
            paragraph.ApplyStyle(BuiltinStyle.Heading4);
            
            // Writing simple bookmarks
            section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph.AppendBookmarkStart("SimpleBookMark");
            paragraph.AppendText("This is a simple book mark.");
            paragraph.AppendBookmarkEnd("SimpleBookMark");

            section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph.AppendText("Nested bookmark.");
            paragraph.ApplyStyle(BuiltinStyle.Heading4);

            // Writing nested bookmarks
            section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph.AppendBookmarkStart("Root");
            paragraph.AppendText(" Root data ");
            paragraph.AppendBookmarkStart("NestedLevel1");
            paragraph.AppendText(" Nested Level1 ");
            paragraph.AppendBookmarkStart("NestedLevel2");
            paragraph.AppendText(" Nested Level2 ");
            paragraph.AppendBookmarkEnd("NestedLevel2");
            paragraph.AppendText(" Data Level1 ");
            paragraph.AppendBookmarkEnd("NestedLevel1");
            paragraph.AppendText(" Data Root ");
            paragraph.AppendBookmarkEnd("Root");

        }
Example #10
0
        /// <summary>Writes PDF for specified auto-doc commands.</summary>
        /// <param name="section">The writer to write to.</param>
        /// <param name="tags">The autodoc tags.</param>
        /// <param name="workingDirectory">The working directory.</param>
        private void TagsToMigraDoc(Section section, List <AutoDocumentation.ITag> tags, string workingDirectory)
        {
            int figureNumber = 0;

            foreach (AutoDocumentation.ITag tag in tags)
            {
                if (tag is AutoDocumentation.Heading)
                {
                    AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading;
                    if (heading.headingLevel > 0 && heading.headingLevel <= 6)
                    {
                        Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel);
                        para.Format.KeepWithNext = true;
                        if (heading.headingLevel == 1)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level1;
                        }
                        else if (heading.headingLevel == 2)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level2;
                        }
                        else if (heading.headingLevel == 3)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level3;
                        }
                        else if (heading.headingLevel == 4)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level4;
                        }
                        else if (heading.headingLevel == 5)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level5;
                        }
                        else if (heading.headingLevel == 6)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level6;
                        }
                    }
                }
                else if (tag is AutoDocumentation.Paragraph)
                {
                    AutoDocumentation.Paragraph paragraph = tag as AutoDocumentation.Paragraph;
                    if (paragraph.text.Contains("![Alt Text]"))
                    {
                        figureNumber++;
                    }
                    paragraph.text = paragraph.text.Replace("[FigureNumber]", figureNumber.ToString());
                    AddFormattedParagraphToSection(section, paragraph);
                }
                else if (tag is AutoDocumentation.GraphAndTable)
                {
                    CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable, workingDirectory);
                }
                else if (tag is GraphPage)
                {
                    CreateGraphPage(section, tag as GraphPage, workingDirectory);
                }
                else if (tag is AutoDocumentation.NewPage)
                {
                    section.AddPageBreak();
                }
                else if (tag is AutoDocumentation.Table)
                {
                    CreateTable(section, tag as AutoDocumentation.Table, workingDirectory);
                }
                else if (tag is Graph)
                {
                    GraphPresenter graphPresenter = new GraphPresenter();
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    GraphView graphView = new GraphView();
                    graphView.BackColor        = OxyPlot.OxyColors.White;
                    graphView.ForegroundColour = OxyPlot.OxyColors.Black;
                    graphView.FontSize         = 12;
                    graphView.Width            = 500;
                    graphView.Height           = 500;
                    graphPresenter.Attach(tag, graphView, explorerPresenter);
                    string pngFileName = graphPresenter.ExportToPNG(workingDirectory);
                    section.AddImage(pngFileName);
                    string caption = (tag as Graph).Caption;
                    if (caption != null)
                    {
                        section.AddParagraph(caption);
                    }
                    graphPresenter.Detach();
                    graphView.MainWidget.Destroy();
                }
                else if (tag is Map && (tag as Map).GetCoordinates().Count > 0)
                {
                    MapPresenter mapPresenter = new MapPresenter();
                    MapView      mapView      = new MapView(null);
                    mapPresenter.Attach(tag, mapView, explorerPresenter);
                    string pngFileName = mapPresenter.ExportToPNG(workingDirectory);
                    if (!String.IsNullOrEmpty(pngFileName))
                    {
                        section.AddImage(pngFileName);
                    }
                    mapPresenter.Detach();
                    mapView.MainWidget.Destroy();
                }
                else if (tag is AutoDocumentation.Image)
                {
                    AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image;
                    if (imageTag.image.Width > 700)
                    {
                        imageTag.image = ImageUtilities.ResizeImage(imageTag.image, 700, 500);
                    }
                    string pngFileName = Path.Combine(workingDirectory, imageTag.name);
                    imageTag.image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png);
                    section.AddImage(pngFileName);
                    figureNumber++;
                }
                else if (tag is AutoDocumentation.ModelView)
                {
                    AutoDocumentation.ModelView modelView     = tag as AutoDocumentation.ModelView;
                    ViewNameAttribute           viewName      = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                    PresenterNameAttribute      presenterName = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;
                    if (viewName != null && presenterName != null)
                    {
                        ViewBase   view      = Assembly.GetExecutingAssembly().CreateInstance(viewName.ToString(), false, BindingFlags.Default, null, new object[] { ViewBase.MasterView }, null, null) as ViewBase;
                        IPresenter presenter = Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter;

                        if (view != null && presenter != null)
                        {
                            explorerPresenter.ApsimXFile.Links.Resolve(presenter);
                            presenter.Attach(modelView.model, view, explorerPresenter);

                            Gtk.Window popupWin = null;
                            if (view is MapView)
                            {
                                popupWin = (view as MapView)?.GetPopupWin();
                                popupWin?.SetSizeRequest(515, 500);
                            }
                            if (popupWin == null)
                            {
                                popupWin = new Gtk.Window(Gtk.WindowType.Popup);
                                popupWin.SetSizeRequest(800, 800);
                                popupWin.Add(view.MainWidget);
                            }
                            popupWin.ShowAll();
                            while (Gtk.Application.EventsPending())
                            {
                                Gtk.Application.RunIteration();
                            }

                            string pngFileName = (presenter as IExportable).ExportToPNG(workingDirectory);
                            section.AddImage(pngFileName);
                            presenter.Detach();
                            view.MainWidget.Destroy();
                            popupWin.Destroy();
                        }
                    }
                }
            }
        }
Example #11
0
        public IActionResult OnGet(string PDF)
        {
            ActiveRecord = new SessionActive();
            // get the session data
            ActiveRecord.Active_SessionID    = HttpContext.Session.GetString(Session_SessionID);
            ActiveRecord.Active_EmailAddress = HttpContext.Session.GetString(Session_EmailAddress);
            ActiveRecord.Active_FirstName    = HttpContext.Session.GetString(Session_FirstName);
            ActiveRecord.Active_ModLevel     = HttpContext.Session.GetInt32(Session_ModLevel);

            // check if a session exists
            if (string.IsNullOrEmpty(ActiveRecord.Active_EmailAddress) && string.IsNullOrEmpty(ActiveRecord.Active_FirstName) && string.IsNullOrEmpty(ActiveRecord.Active_SessionID))
            {
                ActiveRecord.Active_Sesson = false;
                // redirect to login if no session exists
                return(RedirectToPage("/Login/Login"));
            }
            else
            {
                ActiveRecord.Active_Sesson = true;
                if (ActiveRecord.Active_ModLevel != 1)
                {
                    //if not a an admin redirect to user account page
                    return(RedirectToPage("/Users/Index"));
                }
            }

            //connect to database
            DBConnect G24database_connection = new DBConnect();
            string    DBconnection           = G24database_connection.DatabaseString();


            SqlConnection connect = new SqlConnection(DBconnection);

            connect.Open();


            using (SqlCommand command = new SqlCommand())
            {
                command.Connection = connect;
                // selects all users from the User database
                command.CommandText = @"SELECT * FROM Users";

                // filters users from the database if filter exists
                if (!(string.IsNullOrEmpty(Type) || Type == "ALL"))
                {
                    command.CommandText += " WHERE ModLevel = @accType";
                    command.Parameters.AddWithValue("@accType", Convert.ToInt32(Type));
                }

                // execte the database command
                SqlDataReader reader = command.ExecuteReader();

                UserRecords = new List <User>();

                // loop though returned data
                while (reader.Read())
                {
                    User record = new User();
                    record.UserID       = reader.GetInt32(0);
                    record.FirstName    = reader.GetString(1);
                    record.LastName     = reader.GetString(2);
                    record.EmailAddress = reader.GetString(3);
                    record.Password     = reader.GetString(4);
                    record.ModLevel     = reader.GetInt32(5);


                    UserRecords.Add(record);
                }
                reader.Close();


                // if PDF is set in the url
                if (PDF == "1")
                {
                    //Create an object for the PDF document
                    Document  doc  = new Document();
                    Section   sec  = doc.AddSection();
                    Paragraph para = sec.AddParagraph();

                    //Add a picture to the pdf
                    ImageSource.ImageSourceImpl = new ImageSharpImageSource <Rgba32>();
                    Paragraph para2   = sec.AddParagraph();
                    var       picpath = Path.Combine(_env.WebRootPath, "Files", "UserPhoto.png");
                    var       image   = para2.AddImage(ImageSource.FromFile(picpath));
                    image.Width             = Unit.FromCentimeter(17); // define picture width
                    para2.Format.SpaceAfter = Unit.FromCentimeter(2);  // define the space after the image

                    // define the font type size and colour
                    para.Format.Font.Name  = "Arial";
                    para.Format.Font.Size  = 14;
                    para.Format.Font.Color = Color.FromCmyk(0, 0, 0, 100); //black colour
                    // add title
                    para.AddFormattedText("User Report : ", TextFormat.Bold);
                    // add space after the title
                    para.Format.SpaceAfter = "1.0cm";

                    // set-up table define padding, and borders
                    Table tab = new Table();
                    tab.Borders.Width = 0.75;
                    tab.TopPadding    = 5;
                    tab.BottomPadding = 5;

                    // sets up the columns within the ta table
                    Column col = tab.AddColumn(Unit.FromCentimeter(1.5));
                    col.Format.Alignment = ParagraphAlignment.Justify;
                    tab.AddColumn(Unit.FromCentimeter(4));
                    tab.AddColumn(Unit.FromCentimeter(4));
                    tab.AddColumn(Unit.FromCentimeter(6));
                    tab.AddColumn(Unit.FromCentimeter(1.5));

                    // creates a row for the table header and sets a background colour
                    Row row = tab.AddRow();
                    row.Shading.Color = Colors.Green;

                    //sets up the table headers
                    Cell cell = new Cell();
                    cell = row.Cells[0];
                    cell.AddParagraph("User ID");
                    cell = row.Cells[1];
                    cell.AddParagraph("First Name");
                    cell = row.Cells[2];
                    cell.AddParagraph("Last Name");
                    cell = row.Cells[3];
                    cell.AddParagraph("Email");
                    cell = row.Cells[4];
                    cell.AddParagraph("Mod Level");



                    //Add data to table loops through the user record array
                    for (int i = 0; i < UserRecords.Count; i++)
                    {
                        row  = tab.AddRow();
                        cell = row.Cells[0];
                        cell.AddParagraph(Convert.ToString(UserRecords[i].UserID));
                        cell = row.Cells[1];
                        cell.AddParagraph(UserRecords[i].FirstName);
                        cell = row.Cells[2];
                        cell.AddParagraph(UserRecords[i].LastName);
                        cell = row.Cells[3];
                        cell.AddParagraph(UserRecords[i].EmailAddress);
                        cell = row.Cells[4];
                        cell.AddParagraph(Convert.ToString(UserRecords[i].ModLevel));
                    }

                    // sets the border of the page
                    tab.SetEdge(0, 0, 4, (UserRecords.Count + 1), Edge.Box, BorderStyle.Single, 1, Colors.Gray);
                    sec.Add(tab);


                    //renders the PDF
                    PdfDocumentRenderer pdfRen = new PdfDocumentRenderer();
                    pdfRen.Document = doc;
                    pdfRen.RenderDocument();

                    //creates a memory stream
                    MemoryStream stream = new MemoryStream();
                    pdfRen.PdfDocument.Save(stream); //saving the file into the stream

                    Response.Headers.Add("content-disposition", new[] { "inline; filename = UserRecord.pdf" });
                    return(File(stream, "application/pdf")); //directs to the PDF
                }
            }

            return(Page());
        }
Example #12
0
 private void AddTitle(Section section)
 {
     Paragraph title = section.AddParagraph();
     TextRange titleText = title.AppendText("Create Your Account");
     titleText.CharacterFormat.FontSize = 18;
     titleText.CharacterFormat.FontName = "Arial";
     titleText.CharacterFormat.TextColor = Color.FromArgb(0x00, 0x71, 0xb6);
     title.Format.HorizontalAlignment
         = Spire.Doc.Documents.HorizontalAlignment.Center;
     title.Format.AfterSpacing = 8;
 }
Example #13
0
 private void AddHeading(Section section, DVHTable dvhTable)
 {
     section.AddParagraph(dvhTable.Title, StyleNames.Heading1);
 }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create Word document.
            Document document = new Document();

            //Add a section.
            Section section = document.AddSection();

            //Add paragraph 1.
            Paragraph paragraph1 = section.AddParagraph();

            //Add tab and set its position (in points).
            Tab tab = paragraph1.Format.Tabs.AddTab(28);

            //Set tab alignment.
            tab.Justification = TabJustification.Left;

            //Move to next tab and append text.
            paragraph1.AppendText("\tWashing Machine");

            //Add another tab and set its position (in points).
            tab = paragraph1.Format.Tabs.AddTab(280);

            //Set tab alignment.
            tab.Justification = TabJustification.Left;

            //Specify tab leader type.
            tab.TabLeader = TabLeader.Dotted;

            //Move to next tab and append text.
            paragraph1.AppendText("\t$650");

            //Add paragraph 2.
            Paragraph paragraph2 = section.AddParagraph();

            //Add tab and set its position (in points).
            tab = paragraph2.Format.Tabs.AddTab(28);

            //Set tab alignment.
            tab.Justification = TabJustification.Left;

            //Move to next tab and append text.
            paragraph2.AppendText("\tRefrigerator");

            //Add another tab and set its position (in points).
            tab = paragraph2.Format.Tabs.AddTab(280);

            //Set tab alignment.
            tab.Justification = TabJustification.Left;

            //Specify tab leader type.
            tab.TabLeader = TabLeader.NoLeader;

            //Move to next tab and append text.
            paragraph2.AppendText("\t$800");

            String result = "Result-AddTabStopsToParagraph.docx";

            //Save to file.
            document.SaveToFile(result, FileFormat.Docx2013);

            //Launch the MS Word file.
            WordDocViewer(result);
        }
Example #15
0
        public static void CreatePage(Document document, string Name, string[,] data)
        {
            // Each MigraDoc document needs at least one section.
            Section section = document.AddSection();

            // Put a logo in the header
            Image image = section.Headers.Primary.AddImage("../../PowerBooks.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;

            // Create footer
            Paragraph paragraph = section.Footers.Primary.AddParagraph();

            paragraph.AddText("Na potoce 390/27 · Třebíč");
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Create the text frame for the address
            TextFrame addressFrame = section.AddTextFrame();

            addressFrame.Height             = "3.0cm";
            addressFrame.Width              = "7.0cm";
            addressFrame.Left               = ShapePosition.Left;
            addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            addressFrame.Top = "5.0cm";
            addressFrame.RelativeVertical = RelativeVertical.Page;

            // Put sender in address frame
            paragraph = addressFrame.AddParagraph("Na potoce 390/27, Třebíč");
            paragraph.Format.Font.Name  = "Times New Roman";
            paragraph.Format.Font.Size  = 7;
            paragraph.Format.SpaceAfter = 3;

            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "8cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText(Name, TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddText("Třebíč, ");
            paragraph.AddDateField("dd.MM.yyyy");

            if (data != null && data.GetLength(0) >= 2)
            {
                // 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;
                for (int i = 0; i < data.GetLength(1); i++)
                {
                    column = table.AddColumn(data[0, i]);
                    column.Format.Alignment = ParagraphAlignment.Center;
                }

                // 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 = TableBlue;
                for (int i = 0; i < data.GetLength(1); i++)
                {
                    row.Cells[i].AddParagraph(data[1, i]);
                    row.Cells[i].Format.Alignment  = ParagraphAlignment.Left;
                    row.Cells[i].VerticalAlignment = VerticalAlignment.Bottom;
                }

                //row.Cells[0].MergeDown = 1;
                //row.Cells[1].MergeRight = 3;

                table.SetEdge(0, 0, data.GetLength(1), 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);

                // Fill Table

                for (int i = 2; i < data.GetLength(0); i++)
                {
                    row = table.AddRow();
                    row.HeadingFormat    = true;
                    row.Format.Alignment = ParagraphAlignment.Center;
                    row.Format.Font.Bold = false;

                    for (int j = 0; j < data.GetLength(1); j++)
                    {
                        row.Cells[j].AddParagraph(data[i, j]);
                        row.Cells[j].Format.Alignment  = ParagraphAlignment.Left;
                        row.Cells[j].VerticalAlignment = VerticalAlignment.Bottom;
                    }
                }

                table.SetEdge(0, 0, data.GetLength(1), data.GetLength(0) - 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
            }
        }
Example #16
0
        /// <summary>
        /// Export name to a section in a document
        /// </summary>
        /// <param name="toExport">The data to export from</param>
        /// <param name="sect">The section to write on</param>
        /// <returns>The section with appended data</returns>
        public override Section Export(FaseType toExport, Section sect)
        {
            base.Export(toExport, sect);

            //custom code
            foreach (Fase f in toExport.Fase)
            {
                Paragraph p = sect.AddParagraph((toExport.Type ?? "Data niet gevonden") + " - " + (f.Naam ?? "Data niet gevonden"), "Heading2");
                p.AddLineBreak();
                FormattedText text = p.AddFormattedText("Als U hieronder geen tabel ziet, bevat de database nog incomplete Modules.");
                text.Font.Color = Colors.DarkGray;
                text.Font.Size  = 8;

                var ungroupedFaseModules = f.FaseModules.Where(element => element.Module.Status.Equals("Compleet (gecontroleerd)"));

                foreach (var faseModules in ungroupedFaseModules.GroupBy(element => element.Blok))
                {
                    var semester = "" + Math.Ceiling(Convert.ToInt32(faseModules.First().Blok) / 2.0);

                    p = sect.AddParagraph("Blok " + faseModules.First().Blok + " - " + semester + "e Semester");
                    p.Format.Font.Bold = true;

                    Table table = sect.AddTable();
                    table.Borders.Width = 0.75;
                    table.Borders.Color = Colors.DarkGray;

                    Column onderdeelCol  = table.AddColumn(Unit.FromCentimeter(2));
                    Column cursusCol     = table.AddColumn(Unit.FromCentimeter(2.4));
                    Column descCol       = table.AddColumn(Unit.FromCentimeter(3));
                    Column cuCol         = table.AddColumn(Unit.FromCentimeter(0.8));
                    Column wvCol         = table.AddColumn(Unit.FromCentimeter(1));
                    Column toetsCodeCol  = table.AddColumn(Unit.FromCentimeter(2));
                    Column toetsStyleCol = table.AddColumn(Unit.FromCentimeter(3));
                    Column ecCol         = table.AddColumn(Unit.FromCentimeter(0.8));
                    Column minCol        = table.AddColumn(Unit.FromCentimeter(0.8));

                    Row titleRow = table.AddRow();
                    titleRow.Shading.Color = Colors.Red;

                    titleRow.Cells[0].AddParagraph("Onderdeel").Format.Font.Color    = Colors.White;
                    titleRow.Cells[1].AddParagraph("Cursus").Format.Font.Color       = Colors.White;
                    titleRow.Cells[2].AddParagraph("Omschrijving").Format.Font.Color = Colors.White;
                    titleRow.Cells[3].AddParagraph("CU").Format.Font.Color           = Colors.White;
                    titleRow.Cells[4].AddParagraph("WV").Format.Font.Color           = Colors.White;
                    titleRow.Cells[5].AddParagraph("Toetscode").Format.Font.Color    = Colors.White;
                    titleRow.Cells[6].AddParagraph("Toetsvorm").Format.Font.Color    = Colors.White;
                    titleRow.Cells[7].AddParagraph("EC").Format.Font.Color           = Colors.White;
                    titleRow.Cells[8].AddParagraph("Min").Format.Font.Color          = Colors.White;

                    int maxSchoolJaar = int.Parse(faseModules.First().FaseSchooljaar);
                    foreach (var fm in faseModules)
                    {
                        if (int.Parse(fm.FaseSchooljaar) > maxSchoolJaar)
                        {
                            maxSchoolJaar = int.Parse(fm.FaseSchooljaar);
                        }
                    }

                    string currSchoolJaar = "" + maxSchoolJaar;

                    int     totalCu = 0;
                    decimal totalEc = 0;

                    foreach (var fm in faseModules.Where(x => x.FaseSchooljaar.Equals(currSchoolJaar)))
                    {
                        Module m = fm.Module;

                        Row startRow = table.AddRow();
                        startRow.Format.Font.Size = 10;
                        startRow.Cells[0].AddParagraph(m.OnderdeelCode ?? "");
                        startRow.Cells[1].AddParagraph(m.CursusCode ?? "");
                        startRow.Cells[2].AddParagraph(m.Naam ?? "");

                        int cu = m.StudieBelasting.Sum(x => x.ContactUren.Value);
                        totalCu += cu;

                        startRow.Cells[3].AddParagraph("" + cu);

                        string wv             = "";
                        bool   firstIteration = true;
                        foreach (ModuleWerkvorm mwv in m.ModuleWerkvorm)
                        {
                            if (firstIteration)
                            {
                                firstIteration = false;
                            }
                            else
                            {
                                wv = wv + ", ";
                            }
                            wv = wv + (mwv.Werkvorm.Type ?? "NOT FOUND");
                        }

                        startRow.Cells[4].AddParagraph(wv);

                        int iteration = 0;
                        foreach (StudiePunten sp in m.StudiePunten)
                        {
                            if (iteration == 0)
                            {
                                startRow.Cells[5].AddParagraph(sp.ToetsCode ?? "");
                                startRow.Cells[6].AddParagraph(sp.Toetsvorm ?? "");
                                startRow.Cells[7].AddParagraph("" + sp.EC);
                                startRow.Cells[8].AddParagraph(sp.Minimum ?? "");
                                firstIteration = false;
                            }
                            else
                            {
                                Row toetsRow = table.AddRow();
                                toetsRow.Format.Font.Size = 10;
                                toetsRow.Cells[5].AddParagraph(sp.ToetsCode ?? "");
                                toetsRow.Cells[6].AddParagraph(sp.Toetsvorm ?? "");
                                toetsRow.Cells[7].AddParagraph("" + sp.EC);
                                toetsRow.Cells[8].AddParagraph(sp.Minimum ?? "");
                            }
                            totalEc += sp.EC;

                            iteration++;
                        }

                        if (iteration > 1)
                        {
                            int down = iteration - 1;
                            startRow.Cells[0].MergeDown = down;
                            startRow.Cells[1].MergeDown = down;
                            startRow.Cells[2].MergeDown = down;
                            startRow.Cells[3].MergeDown = down;
                            startRow.Cells[4].MergeDown = down;
                        }
                    }

                    Row lastRow = table.AddRow();
                    lastRow.Shading.Color = Colors.LightBlue;
                    lastRow.Cells[2].AddParagraph("Totaal").Format.Font.Bold     = true;
                    lastRow.Cells[3].AddParagraph("" + totalCu).Format.Font.Bold = true;
                    lastRow.Cells[6].AddParagraph("Totaal").Format.Font.Bold     = true;
                    lastRow.Cells[7].AddParagraph("" + totalEc).Format.Font.Bold = true;
                }
            }

            return(sect);
        }
Example #17
0
        private void AddForm(Section section)
        {
            ParagraphStyle descriptionStyle = new ParagraphStyle(section.Document);
            descriptionStyle.Name = "description";
            descriptionStyle.CharacterFormat.FontSize = 12;
            descriptionStyle.CharacterFormat.FontName = "Arial";
            descriptionStyle.CharacterFormat.TextColor = Color.FromArgb(0x00, 0x45, 0x8e);
            section.Document.Styles.Add(descriptionStyle);

            Paragraph p1 = section.AddParagraph();
            String text1
                = "So that we can verify your identity and find your information, "
                + "please provide us with the following information. "
                + "This information will be used to create your online account. "
                + "Your information is not public, shared in anyway, or displayed on this site";
            p1.AppendText(text1);
            p1.ApplyStyle(descriptionStyle.Name);

            Paragraph p2 = section.AddParagraph();
            String text2
                = "You must provide a real email address to which we will send your password.";
            p2.AppendText(text2);
            p2.ApplyStyle(descriptionStyle.Name);
            p2.Format.AfterSpacing = 8;

            //field group label style
            ParagraphStyle formFieldGroupLabelStyle = new ParagraphStyle(section.Document);
            formFieldGroupLabelStyle.Name = "formFieldGroupLabel";
            formFieldGroupLabelStyle.ApplyBaseStyle("description");
            formFieldGroupLabelStyle.CharacterFormat.Bold = true;
            formFieldGroupLabelStyle.CharacterFormat.TextColor = Color.White;
            section.Document.Styles.Add(formFieldGroupLabelStyle);

            //field label style
            ParagraphStyle formFieldLabelStyle = new ParagraphStyle(section.Document);
            formFieldLabelStyle.Name = "formFieldLabel";
            formFieldLabelStyle.ApplyBaseStyle("description");
            formFieldLabelStyle.ParagraphFormat.HorizontalAlignment
                = Spire.Doc.Documents.HorizontalAlignment.Right;
            section.Document.Styles.Add(formFieldLabelStyle);

            //add table
            Table table = section.AddTable();

            //2 columns of per row
            table.DefaultColumnsNumber = 2;

            //default height of row is 20point
            table.DefaultRowHeight = 20;

            //load form config data
            using (Stream stream = File.OpenRead(@"..\..\..\..\..\..\Data\Form.xml"))
            {
                XPathDocument xpathDoc = new XPathDocument(stream);
                XPathNodeIterator sectionNodes = xpathDoc.CreateNavigator().Select("/form/section");
                foreach (XPathNavigator node in sectionNodes)
                {
                    //create a row for field group label, does not copy format
                    TableRow row = table.AddRow(false);
                    row.Cells[0].CellFormat.BackColor = Color.FromArgb(0x00, 0x71, 0xb6);
                    row.Cells[0].CellFormat.VerticalAlignment = VerticalAlignment.Middle;

                    //label of field group
                    Paragraph cellParagraph = row.Cells[0].AddParagraph();
                    cellParagraph.AppendText(node.GetAttribute("name", ""));
                    cellParagraph.ApplyStyle(formFieldGroupLabelStyle.Name);

                    XPathNodeIterator fieldNodes = node.Select("field");
                    foreach (XPathNavigator fieldNode in fieldNodes)
                    {
                        //create a row for field, does not copy format
                        TableRow fieldRow = table.AddRow(false);

                        //field label
                        fieldRow.Cells[0].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
                        Paragraph labelParagraph = fieldRow.Cells[0].AddParagraph();
                        labelParagraph.AppendText(fieldNode.GetAttribute("label", ""));
                        labelParagraph.ApplyStyle(formFieldLabelStyle.Name);

                        fieldRow.Cells[1].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
                        Paragraph fieldParagraph = fieldRow.Cells[1].AddParagraph();
                        String fieldId = fieldNode.GetAttribute("id", "");
                        switch (fieldNode.GetAttribute("type", ""))
                        {
                            case "text":
                                //add text input field
                                TextFormField field
                                    = fieldParagraph.AppendField(fieldId, FieldType.FieldFormTextInput) as TextFormField;

                                //set default text
                                field.DefaultText = "";
                                field.Text = "";
                                break;

                            case "list":
                                //add dropdown field
                                DropDownFormField list
                                    = fieldParagraph.AppendField(fieldId, FieldType.FieldFormDropDown) as DropDownFormField;

                                //add items into dropdown.
                                XPathNodeIterator itemNodes = fieldNode.Select("item");
                                foreach (XPathNavigator itemNode in itemNodes)
                                {
                                    list.DropDownItems.Add(itemNode.SelectSingleNode("text()").Value);
                                }
                                break;

                            case "checkbox":
                                //add checkbox field
                                fieldParagraph.AppendField(fieldId, FieldType.FieldFormCheckBox);
                                break;
                        }
                    }

                    //merge field group row. 2 columns to 1 column
                    table.ApplyHorizontalMerge(row.GetRowIndex(), 0, 1);
                }
            }
        }
Example #18
0
 internal static void AddInvoiceTitle(Section s)
 {
     s.AddImage(ImageUrl).SetScale(ScalingMode.AutoSize).SetAlignment(HorizontalAlignment.Center);
     s.AddParagraph("Receipt").SetMargins(20, 0, 0, 10).SetFont(TitleFont).SetAlignment(HorizontalAlignment.Center);
     s.AddLine().SetColor(Color.FromRgba(106.0 / 255.0, 85.0 / 255.9, 189.0 / 255.0)).SetStyle(Stroke.Solid).SetWidth(2);
 }
Example #19
0
        private void CreatePage()
        {
            //Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();

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

            // Create footer
            Paragraph paragraph = section.Footers.Primary.AddParagraph();

            paragraph.AddText("© EasyRes Inc");
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Create the text frame for the general information
            this.generalFrame                    = section.AddTextFrame();
            this.generalFrame.Height             = "3.0cm";
            this.generalFrame.Width              = "5.0cm";
            this.generalFrame.Left               = ShapePosition.Right;
            this.generalFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.generalFrame.Top                = "1.75cm";
            this.generalFrame.RelativeVertical   = RelativeVertical.Page;

            // Add the title of the restaurant
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "1.25cm";
            paragraph.Style = "Titel";
            paragraph.AddFormattedText(factuur.Restaurant.Naam, TextFormat.Bold);

            // Add the title on top of the table
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "0.5cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText("Bestellingen", TextFormat.Bold);

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

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

            column.Format.Alignment = ParagraphAlignment.Left;

            Column column1 = this.table.AddColumn("1.5cm");

            column1.Format.Alignment = ParagraphAlignment.Left;

            Column column2 = this.table.AddColumn("2.5cm");

            column2.Format.Alignment = ParagraphAlignment.Left;

            Column column3 = this.table.AddColumn("1.5cm");

            column3.Format.Alignment = ParagraphAlignment.Left;

            Column column4 = this.table.AddColumn("2.5cm");

            column4.Format.Alignment = ParagraphAlignment.Left;

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

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = false;
            row.Shading.Color    = TableGray;
            row.TopPadding       = 3;
            row.BottomPadding    = 3;

            row.Cells[0].AddParagraph("Omschrijving");
            row.Cells[0].Format.Font.Bold  = true;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;

            row.Cells[1].AddParagraph("Aantal");
            row.Cells[1].Format.Font.Bold  = true;
            row.Cells[1].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[1].VerticalAlignment = VerticalAlignment.Center;

            row.Cells[2].AddParagraph("Prijs/stuk");
            row.Cells[2].Format.Font.Bold  = true;
            row.Cells[2].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[2].VerticalAlignment = VerticalAlignment.Center;

            row.Cells[3].AddParagraph("Btw %");
            row.Cells[3].Format.Font.Bold  = true;
            row.Cells[3].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[3].VerticalAlignment = VerticalAlignment.Center;

            row.Cells[4].AddParagraph("Bedrag");
            row.Cells[4].Format.Font.Bold  = true;
            row.Cells[4].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[4].VerticalAlignment = VerticalAlignment.Center;

            //this.table.SetEdge(0, 0, 5, 2, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
        public string GenerateDocument()
        {
            table_color         = Tools.GetTableColorByRetailer("");
            document            = new Document();
            document.Info.Title = "Certificate Of Insurance";
            document.DefaultPageSetup.PageHeight   = page_height;
            document.DefaultPageSetup.PageWidth    = page_width;
            document.DefaultPageSetup.TopMargin    = margin;
            document.DefaultPageSetup.LeftMargin   = margin;
            document.DefaultPageSetup.RightMargin  = margin;
            document.DefaultPageSetup.BottomMargin = bottom_margin;

            DefineStyle();

            Section sec = document.AddSection();

            Tools.AddMainFooter(ref sec);

            // PdfSharpCore.

            //     MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes.ImageSource image = new Image

            // System.Drawing.Image img = System.Drawing.Image.FromFile("");



            Image image = new Image();

            //img.Width = "190cm";
            // img.Height = "50cm";

            image = sec.AddImage(Tools.GetMainPageHeader());

            image.Width  = "190mm";
            image.Height = "50mm";
            image.Left   = ShapePosition.Center;



            Table  t = sec.AddTable();
            Column c = t.AddColumn("95mm");

            c.Format.Alignment = ParagraphAlignment.Left;
            c = t.AddColumn("95mm");
            c.Format.Alignment = ParagraphAlignment.Right;

            Row r = t.AddRow();



            Paragraph p = r.Cells[0].AddParagraph();

            r = t.AddRow();

            p       = r.Cells[0].AddParagraph();
            p.Style = "Heading2";
            p.AddText("TO WHOM IT MAY CONCERN");

            p = r.Cells[1].AddParagraph();
            p.Format.Alignment = ParagraphAlignment.Right;
            p.Style            = "Heading2";
            p.AddText("Date: " + System.DateTime.Today.Date.ToLongDateString());

            r = t.AddRow();

            r = t.AddRow();

            p = r.Cells[0].AddParagraph();
            //p.Style = "Heading2";
            r.Cells[0].MergeRight = 1;
            p.AddFormattedText("IT IS HEREBY CERTIFIED THAT:", TextFormat.Underline);
            p = sec.AddParagraph();
            AddClientDetails(sec);

            // AddGeographicalLimits(sec);

            sec = document.AddSection();

            Tools.AddNoFooter(ref sec);

            AddHeader(sec);

            AddClientDetailsPage2(sec);

            AddAircraftsSchedules(sec);

            AddLastParagraph(sec);

            return(SaveDocument(document));
        }
        private void createJobDetailsSection()
        {
            Section currentSection = (Section)serviceSheetDoc.Sections.LastObject;

            jobDetailsTable = currentSection.AddTable();

            //Setup the table columns and borders
            Column tableColumnn = jobDetailsTable.AddColumn(COLUMN_ONE_WIDTH);

            tableColumnn = jobDetailsTable.AddColumn(COLUMN_TWO_WIDTH);
            jobDetailsTable.Borders.Color = tableBorderColour;
            jobDetailsTable.Borders.Width = borderWidth;

            Row row1Title = jobDetailsTable.AddRow();

            row1Title.Cells[0].MergeRight = 1;
            Paragraph jobDetailsPara = row1Title.Cells[0].AddParagraph();

            jobDetailsPara.AddFormattedText("J", "allCapsFirstLetter");
            jobDetailsPara.AddFormattedText("OB ", "allCapsNextLetter");
            jobDetailsPara.AddFormattedText("D", "allCapsFirstLetter");
            jobDetailsPara.AddFormattedText("ETAILS ", "allCapsNextLetter");
            row1Title.Cells[0].Shading.Color = headerGrey;

            addLineToJobDetails("Customer", currentSheet.Customer);
            addLineToJobDetails("Address Line 1", currentSheet.AddressLine1);
            addLineToJobDetails("Address Line 2", currentSheet.AddressLine2);
            //RT 7/9/17 - Adding USA formatting
            if (currentSheet.UkServiceSheet == true)
            {
                addLineToJobDetails("Town/City", currentSheet.TownCity);
                addLineToJobDetails("Postcode", currentSheet.Postcode);
            }
            else
            {
                addLineToJobDetails("City", currentSheet.TownCity);
                addLineToJobDetails("Zip code", currentSheet.Postcode);
            }


            addLineToJobDetails("Customer contact", currentSheet.CustomerContact);
            addLineToJobDetails("Customer phone number", currentSheet.CustomerPhoneNo);
            addLineToJobDetails("Machine make and model", currentSheet.MachineMakeModel);
            addLineToJobDetails("Machine serial number", currentSheet.MachineSerial);
            addLineToJobDetails("CNC controller", currentSheet.CncControl);
            //RT 7/9/17 - Adding USA date format
            if (currentSheet.UkServiceSheet == true)
            {
                addLineToJobDetails("Job start date", currentSheet.DtJobStart.ToString("dd/MM/yyyy"));
            }
            else
            {
                addLineToJobDetails("Job start date", currentSheet.DtJobStart.ToString("MM/dd/yyyy"));
            }

            addLineToJobDetails("Customer order no.", currentSheet.CustomerOrderNo);
            addLineToJobDetails("MTT job no.", currentSheet.MttJobNumber);
            addLineToJobDetails("Job description", currentSheet.JobDescription);

            //Add a line break between the tables
            currentSection.AddParagraph();
        }
Example #22
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create Word document.
            Document document = new Document();

            //Add a new section.
            Section   section   = document.AddSection();
            Paragraph paragraph = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();

            //Add Heading 1.
            paragraph = section.AddParagraph();
            paragraph.AppendText(BuiltinStyle.Heading1.ToString());
            paragraph.ApplyStyle(BuiltinStyle.Heading1);
            paragraph.ListFormat.ApplyNumberedStyle();

            //Add Heading 2.
            paragraph = section.AddParagraph();
            paragraph.AppendText(BuiltinStyle.Heading2.ToString());
            paragraph.ApplyStyle(BuiltinStyle.Heading2);

            //List style for Headings 2.
            ListStyle listSty2 = new ListStyle(document, ListType.Numbered);

            foreach (ListLevel listLev in listSty2.Levels)
            {
                listLev.UsePrevLevelPattern = true;
                listLev.NumberPrefix        = "1.";
            }
            listSty2.Name = "MyStyle2";
            document.ListStyles.Add(listSty2);
            paragraph.ListFormat.ApplyStyle(listSty2.Name);

            //Add list style 3.
            ListStyle listSty3 = new ListStyle(document, ListType.Numbered);

            foreach (ListLevel listLev in listSty3.Levels)
            {
                listLev.UsePrevLevelPattern = true;
                listLev.NumberPrefix        = "1.1.";
            }
            listSty3.Name = "MyStyle3";
            document.ListStyles.Add(listSty3);

            //Add Heading 3.
            for (int i = 0; i < 4; i++)
            {
                paragraph = section.AddParagraph();

                //Append text
                paragraph.AppendText(BuiltinStyle.Heading3.ToString());

                //Apply list style 3 for Heading 3
                paragraph.ApplyStyle(BuiltinStyle.Heading3);
                paragraph.ListFormat.ApplyStyle(listSty3.Name);
            }

            String result = "Result-FormACatalogue.docx";

            //Save to file.
            document.SaveToFile(result, FileFormat.Docx);

            //Launch the MS Word file.
            WordDocViewer(result);
        }
Example #23
0
        private void button1_Click(object sender, EventArgs e)
        {
            //create a document
            Document doc = new Document();
            Section  sec = doc.AddSection();

            //add a new paragraph
            Paragraph para = sec.AddParagraph();
            //add a shape group with the height and width
            ShapeGroup shapegroup = para.AppendShapeGroup(375, 462);

            shapegroup.HorizontalPosition = 180;
            //calcuate the scale ratio
            float X = (float)(shapegroup.Width / 1000.0f);
            float Y = (float)(shapegroup.Height / 1000.0f);

            Spire.Doc.Fields.TextBox txtBox = new Spire.Doc.Fields.TextBox(doc);
            txtBox.SetShapeType(ShapeType.RoundRectangle);
            txtBox.Width  = 125 / X;
            txtBox.Height = 54 / Y;
            Paragraph paragraph = txtBox.Body.AddParagraph();

            paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
            paragraph.AppendText("Start");
            txtBox.HorizontalPosition = 19 / X;
            txtBox.VerticalPosition   = 27 / Y;
            txtBox.Format.LineColor   = Color.Green;
            shapegroup.ChildObjects.Add(txtBox);

            ShapeObject arrowLineShape = new ShapeObject(doc, ShapeType.DownArrow);

            arrowLineShape.Width              = 16 / X;
            arrowLineShape.Height             = 40 / Y;
            arrowLineShape.HorizontalPosition = 69 / X;
            arrowLineShape.VerticalPosition   = 87 / Y;
            arrowLineShape.StrokeColor        = Color.Purple;
            shapegroup.ChildObjects.Add(arrowLineShape);

            txtBox = new Spire.Doc.Fields.TextBox(doc);
            txtBox.SetShapeType(ShapeType.Rectangle);
            txtBox.Width  = 125 / X;
            txtBox.Height = 54 / Y;
            paragraph     = txtBox.Body.AddParagraph();
            paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
            paragraph.AppendText("Step 1");
            txtBox.HorizontalPosition = 19 / X;
            txtBox.VerticalPosition   = 131 / Y;
            txtBox.Format.LineColor   = Color.Blue;
            shapegroup.ChildObjects.Add(txtBox);

            arrowLineShape                    = new ShapeObject(doc, ShapeType.DownArrow);
            arrowLineShape.Width              = 16 / X;
            arrowLineShape.Height             = 40 / Y;
            arrowLineShape.HorizontalPosition = 69 / X;
            arrowLineShape.VerticalPosition   = 192 / Y;
            arrowLineShape.StrokeColor        = Color.Purple;
            shapegroup.ChildObjects.Add(arrowLineShape);

            txtBox = new Spire.Doc.Fields.TextBox(doc);
            txtBox.SetShapeType(ShapeType.Parallelogram);
            txtBox.Width  = 149 / X;
            txtBox.Height = 59 / Y;
            paragraph     = txtBox.Body.AddParagraph();
            paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
            paragraph.AppendText("Step 2");
            txtBox.HorizontalPosition = 7 / X;
            txtBox.VerticalPosition   = 236 / Y;
            txtBox.Format.LineColor   = Color.BlueViolet;
            shapegroup.ChildObjects.Add(txtBox);

            arrowLineShape                    = new ShapeObject(doc, ShapeType.DownArrow);
            arrowLineShape.Width              = 16 / X;
            arrowLineShape.Height             = 40 / Y;
            arrowLineShape.HorizontalPosition = 66 / X;
            arrowLineShape.VerticalPosition   = 300 / Y;
            arrowLineShape.StrokeColor        = Color.Purple;
            shapegroup.ChildObjects.Add(arrowLineShape);

            txtBox = new Spire.Doc.Fields.TextBox(doc);
            txtBox.SetShapeType(ShapeType.Rectangle);
            txtBox.Width  = 125 / X;
            txtBox.Height = 54 / Y;
            paragraph     = txtBox.Body.AddParagraph();
            paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
            paragraph.AppendText("Step 3");
            txtBox.HorizontalPosition = 19 / X;
            txtBox.VerticalPosition   = 345 / Y;
            txtBox.Format.LineColor   = Color.Blue;
            shapegroup.ChildObjects.Add(txtBox);



            //save the document
            doc.SaveToFile("ShapeGroup.docx", FileFormat.Docx2010);

            FileViewer("ShapeGroup.docx");
        }
Example #24
0
        private static void Cuerpo(Document document, Documento doc, List <Detalle> listadetalle)
        {
            Section section = document.LastSection;

            if (doc.tipodocumento == "01")
            {
                section.PageSetup.TopMargin = new Unit(103, UnitType.Millimeter);
            }
            else if (doc.tipodocumento == "03")
            {
                section.PageSetup.TopMargin = new Unit(87, UnitType.Millimeter);
            }
            else if (doc.tipodocumento == "07")
            {
                section.PageSetup.TopMargin = new Unit(93, UnitType.Millimeter);
            }
            //TextFrame cuerpo = new TextFrame();
            //cuerpo.Width = new Unit(600);
            //cuerpo.WrapFormat.DistanceTop = new Unit(-10);
            //cuerpo.WrapFormat.DistanceBottom = new Unit(-50);
            //var cuerpodata = cuerpo.AddParagraph("Cant.\tCodigo\tDescripcion\tPre.unit.\tSub total\tI.G.V\tTotal\n\n");
            //section.Add(cuerpo);
            section.AddParagraph("Cant.\tCodigo\tDescripcion\tPre.unit.\tSub total\tI.G.V\tTotal\n\n", "Item");
            double t   = 0;
            double igv = 0;
            double sub = 0;

            foreach (var det in listadetalle)
            {
                string cant = det.cantidad.Substring(0, 1);

                section.AddParagraph(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\n", cant, det.codigoitem, det.descripcion,
                                                   det.preciounitario, det.subtotal, det.importeigv, det.importetotal), "Item");
                //float importet = Util.ToNumber(det.importetotal);
                //float importeigvt = Util.ToNumber(det.importeigv);
                //float subtotalt = Util.ToNumber(det.subtotal);
                //t = t + importet;
                //igv = igv + importeigvt;
                //sub = sub + subtotalt;
            }

            section.AddParagraph("");
            var par = section.AddParagraph("");

            ////string subs = Convert.ToString(sub);
            ////string ts = Convert.ToString(t);
            ////string igvs = Convert.ToString(igv);
            ////string subs2 = subs.Substring(0, 5);
            ////string ts2 = ts.Substring(0, 5);
            ////string igvs2 = igvs.Substring(0, 5);



            Table table = new Table();

            table.Borders.Width = 0;
            document.DefaultPageSetup.TopMargin = new Unit(20, UnitType.Millimeter);
            table.Rows.LeftIndent = new Unit(330);

            Column column = table.AddColumn(Unit.FromCentimeter(3.5));

            column = table.AddColumn(Unit.FromCentimeter(2));


            column.Format.Alignment = ParagraphAlignment.Right;



            Row row = table.AddRow();

            row.Format.Alignment = ParagraphAlignment.Right;
            Cell cell = row.Cells[0];

            cell.AddParagraph("SUB TOTAL S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.subtotal);



            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("DSCTO GLOBAL S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.totaldescuentos);

            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("OP. GRAVADA S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.totalgravadas);

            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("OP.EXONERADA S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.totalexoneradas);

            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("OP.INAFECTA S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.totalnogravada);


            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("OP.GRATUITA S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.totalgratuitas);

            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("IGV 18% S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.totaligv);

            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("");
            cell = row.Cells[1];
            cell.AddParagraph("");



            row = table.AddRow();
            row.Format.Alignment = ParagraphAlignment.Right;
            cell = row.Cells[0];
            cell.AddParagraph("TOTAL S/.");
            cell = row.Cells[1];
            cell.AddParagraph(doc.totalventa);

            TextFrame tablef = new TextFrame();

            tablef.WrapFormat.DistanceTop  = new Unit(-115);
            tablef.WrapFormat.DistanceLeft = new Unit(-20);

            BarcodeWriter writer = new BarcodeWriter();

            writer.Format = BarcodeFormat.QR_CODE;
            var bit = writer.Write(string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", doc.rucempresa, doc.tipodocumento, doc.serienumero, doc.totaligv, doc.totalventa, doc.fechaemision, doc.hash));

            var f = tablef.AddImage("qr.bmp");

            f.Width = new Unit(130);

            section.Add(table);
            section.Add(tablef);
            var parr  = section.AddParagraph("\n\n\t\t\tAutorizado mediante resolución Nro: 203 - 2015/SUNAT");
            var parr2 = section.AddParagraph("\t\t\tRepresentación impresa de la boleta electrónica");

            parr.Format.Alignment  = ParagraphAlignment.Left;
            parr2.Format.Alignment = ParagraphAlignment.Center;
            NumToWords totalLetras   = new NumToWords();
            string     numero        = Convert.ToString(doc.totalventa);
            string     TotalEnLetras = totalLetras.Convertir(numero, true);

            parr2.Section.AddParagraph("\nSON:" + TotalEnLetras);

            parr2.Format.Alignment = ParagraphAlignment.Left;
        }
Example #25
0
        public static void CreateDoc(PdfInfo info)
        {
            Document document = new Document();

            DefineStyles(document);
            Section   section   = document.AddSection();
            Paragraph paragraph = section.AddParagraph(info.Title);

            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Style            = "NormalTitle";

            var servicesLabel = section.AddParagraph("Пополнения:");

            servicesLabel.Style = "NormalTitle";
            foreach (var reqs in info.Requests)
            {
                foreach (var req in reqs)
                {
                    var orderLabel = section.AddParagraph("Заявка" + req.RequestName + " от " + req.DateCreate.ToShortDateString());
                    orderLabel.Style = "NormalTitle";
                    orderLabel.Format.SpaceBefore = "1cm";
                    orderLabel.Format.SpaceAfter  = "0,25cm";
                    var servicesLabel2 = section.AddParagraph("Детали:");
                    servicesLabel2.Style = "NormalTitle";
                    var           reqTable     = document.LastSection.AddTable();
                    List <string> headerWidths = new List <string> {
                        "1cm", "3cm", "3cm"
                    };
                    foreach (var elem in headerWidths)
                    {
                        reqTable.AddColumn(elem);
                    }
                    CreateRow(new PdfRowParameters
                    {
                        Table = reqTable,
                        Texts = new List <string> {
                            "№", "Деталь", "Количество"
                        },
                        Style = "NormalTitle",
                        ParagraphAlignment = ParagraphAlignment.Center
                    });
                    int i   = 1;
                    int col = 0;
                    foreach (var detail in req.DetailRequests)
                    {
                        CreateRow(new PdfRowParameters
                        {
                            Table = reqTable,
                            Texts = new List <string> {
                                i.ToString(), detail.Value.Item1, detail.Value.Item2.ToString()
                            },
                            Style = "Normal",
                            ParagraphAlignment = ParagraphAlignment.Left
                        });
                        i++;
                        col += detail.Value.Item2;
                    }

                    CreateRow(new PdfRowParameters
                    {
                        Table = reqTable,
                        Texts = new List <string> {
                            "", "Общее количество деталей:", col.ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                }
            }

            var CarLabel = section.AddParagraph("Автомобили с комплектацией:");

            CarLabel.Style = "NormalTitle";

            foreach (var car in info.Cars)
            {
                var           CarTable      = document.LastSection.AddTable();
                List <string> headerWidths2 = new List <string> {
                    "1cm", "3cm", "3cm", "6cm", "4cm"
                };
                foreach (var elem in headerWidths2)
                {
                    CarTable.AddColumn(elem);
                }
                CreateRow(new PdfRowParameters
                {
                    Table = CarTable,
                    Texts = new List <string> {
                        "№", "Авто", "Год выпуска", "Цена авто без комплектации", "Полная цена"
                    },
                    Style = "NormalTitle",
                    ParagraphAlignment = ParagraphAlignment.Center
                });
                CreateRow(new PdfRowParameters
                {
                    Table = CarTable,
                    Texts = new List <string> {
                        car.Id.ToString(), car.CarName, car.Year.ToString(), car.Price.ToString(), car.FullPrice.ToString()
                    },
                    Style = "Normal",
                    ParagraphAlignment = ParagraphAlignment.Left
                });

                var           detailTable   = document.LastSection.AddTable();
                List <string> headerWidths3 = new List <string> {
                    "1cm", "3cm", "3cm", "3cm"
                };
                foreach (var elem in headerWidths3)
                {
                    detailTable.AddColumn(elem);
                }
                CreateRow(new PdfRowParameters
                {
                    Table = detailTable,
                    Texts = new List <string> {
                        "№", "Деталь", "Количество", "Цена"
                    },
                    Style = "NormalTitle",
                    ParagraphAlignment = ParagraphAlignment.Center
                });
                foreach (var det in car.CarDetails)
                {
                    CreateRow(new PdfRowParameters
                    {
                        Table = detailTable,
                        Texts = new List <string> {
                            det.Key.ToString(), det.Value.Item1, det.Value.Item2.ToString(), det.Value.Item3.ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                }
                section.AddParagraph();
            }

            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true)
            {
                Document = document
            };

            renderer.RenderDocument();
            renderer.PdfDocument.Save(info.FileName);
        }
Example #26
0
        private void InsertTextbox(Section section)
        {
            Paragraph paragraph
                = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();

            paragraph = section.AddParagraph();
            paragraph = section.AddParagraph();

            //Insert and format the first textbox.
            Spire.Doc.Fields.TextBox textBox1 = paragraph.AppendTextBox(240, 35);
            textBox1.Format.HorizontalAlignment = ShapeHorizontalAlignment.Left;
            textBox1.Format.LineColor           = System.Drawing.Color.Gray;
            textBox1.Format.LineStyle           = TextBoxLineStyle.Simple;
            textBox1.Format.FillColor           = System.Drawing.Color.DarkSeaGreen;
            Paragraph para  = textBox1.Body.AddParagraph();
            TextRange txtrg = para.AppendText("Textbox 1 in the document");

            txtrg.CharacterFormat.FontName  = "Lucida Sans Unicode";
            txtrg.CharacterFormat.FontSize  = 14;
            txtrg.CharacterFormat.TextColor = System.Drawing.Color.White;
            para.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

            //Insert and format the second textbox.
            paragraph = section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph = section.AddParagraph();
            Spire.Doc.Fields.TextBox textBox2 = paragraph.AppendTextBox(240, 35);
            textBox2.Format.HorizontalAlignment = ShapeHorizontalAlignment.Left;
            textBox2.Format.LineColor           = System.Drawing.Color.Tomato;
            textBox2.Format.LineStyle           = TextBoxLineStyle.ThinThick;
            textBox2.Format.FillColor           = System.Drawing.Color.Blue;
            textBox2.Format.LineDashing         = LineDashing.Dot;
            para  = textBox2.Body.AddParagraph();
            txtrg = para.AppendText("Textbox 2 in the document");
            txtrg.CharacterFormat.FontName  = "Lucida Sans Unicode";
            txtrg.CharacterFormat.FontSize  = 14;
            txtrg.CharacterFormat.TextColor = System.Drawing.Color.Pink;
            para.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

            //Insert and format the third textbox.
            paragraph = section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph = section.AddParagraph();
            Spire.Doc.Fields.TextBox textBox3 = paragraph.AppendTextBox(240, 35);
            textBox3.Format.HorizontalAlignment = ShapeHorizontalAlignment.Left;
            textBox3.Format.LineColor           = System.Drawing.Color.Violet;
            textBox3.Format.LineStyle           = TextBoxLineStyle.Triple;
            textBox3.Format.FillColor           = System.Drawing.Color.Pink;
            textBox3.Format.LineDashing         = LineDashing.DashDotDot;
            para  = textBox3.Body.AddParagraph();
            txtrg = para.AppendText("Textbox 3 in the document");
            txtrg.CharacterFormat.FontName  = "Lucida Sans Unicode";
            txtrg.CharacterFormat.FontSize  = 14;
            txtrg.CharacterFormat.TextColor = System.Drawing.Color.Tomato;
            para.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
        }
Example #27
0
        public static void CreateDoc(PdfInfoClient info)
        {
            Document document = new Document();

            DefineStyles(document);
            Section   section   = document.AddSection();
            Paragraph paragraph = section.AddParagraph(info.Title);

            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Style            = "NormalTitle";
            foreach (var order in info.Orders)
            {
                var orderLabel = section.AddParagraph("Заказ №" + order.Id + "от" + order.DateCreate);
                orderLabel.Style = "NormalTitle";
                var CarLabel = section.AddParagraph("Автомобили с комплектацией:");
                CarLabel.Style = "NormalTitle";

                foreach (var cars in order.OrderCars)
                {
                    var           CarTable      = document.LastSection.AddTable();
                    List <string> headerWidths2 = new List <string> {
                        "1cm", "3cm", "3cm", "3cm", "3cm"
                    };
                    foreach (var elem in headerWidths2)
                    {
                        CarTable.AddColumn(elem);
                    }
                    CreateRow(new PdfRowParameters
                    {
                        Table = CarTable,
                        Texts = new List <string> {
                            "№", "Автомобиль", "Год выпуска", "Количество", "Цена"
                        },
                        Style = "NormalTitle",
                        ParagraphAlignment = ParagraphAlignment.Center
                    });
                    CreateRow(new PdfRowParameters
                    {
                        Table = CarTable,
                        Texts = new List <string> {
                            cars.CarId.ToString(), cars.CarName, cars.Year.ToString(), cars.Count.ToString(), cars.Price.ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                    foreach (var car in info.Cars)
                    {
                        if (car.Id != cars.CarId)
                        {
                            continue;
                        }

                        var           detailTable   = document.LastSection.AddTable();
                        List <string> headerWidths3 = new List <string> {
                            "1cm", "3cm", "3cm"
                        };
                        foreach (var elem in headerWidths3)
                        {
                            detailTable.AddColumn(elem);
                        }
                        CreateRow(new PdfRowParameters
                        {
                            Table = detailTable,
                            Texts = new List <string> {
                                "№", "Деталь", "Количество"
                            },
                            Style = "NormalTitle",
                            ParagraphAlignment = ParagraphAlignment.Center
                        });

                        foreach (var det in car.CarDetails)
                        {
                            CreateRow(new PdfRowParameters
                            {
                                Table = detailTable,
                                Texts = new List <string> {
                                    det.Key.ToString(), det.Value.Item1, det.Value.Item2.ToString()
                                },
                                Style = "Normal",
                                ParagraphAlignment = ParagraphAlignment.Left
                            });
                        }
                        section.AddParagraph();
                    }
                }
            }
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true)
            {
                Document = document
            };

            renderer.RenderDocument();
            renderer.PdfDocument.Save(info.FileName);
        }
        private void BtnPrintVouchersAndTickets_Click(object sender, EventArgs e)
        {
            Button button    = sender as Button;
            bool   closeForm = true;

            if ((button == BtnPrintHotelVouchers) || (button == BtnPrintBoth))
            {
                //MessageBox.Show("Button pressed = " + button.Text, "PRINTING HOTEL VOUCHERS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                /* open connection */
                try
                {
                    mySqlConnection.Open();
                }
                catch (Exception errConnOpen)
                {
                    MessageBox.Show("Error in opening mysql connection because : " + errConnOpen.Message);
                    return;
                }

                /* now execute query to obtain data from hotel booking table
                 * and fill t in dataset
                 */
                string           mySqlQueryString = "SELECT DISTINCT `idhotelinfo` FROM `hotelbookinginfo` WHERE `queryid` = '" + queryId + "' ORDER BY `idhotelinfo`";
                DataSet          dataset          = new DataSet();
                MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mySqlQueryString, mySqlConnection);
                mySqlDataAdapter.Fill(dataset, "TABLE_HOTEL_ID");
                if ((dataset == null) || (dataset.Tables["TABLE_HOTEL_ID"].Rows.Count < 1))
                {
                    MessageBox.Show("No Hotel information present for QueryId = " + queryId, "No Data Present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    try
                    {
                        mySqlConnection.Close();
                    }
                    catch (Exception errConnClose)
                    {
                        MessageBox.Show("Error in opening mysql connection because : " + errConnClose.Message);
                    }
                    return;
                }
                saveFileDialogItinerary.Title = "HOTEL VOUCHER FILE NAME";
                if (saveFileDialogItinerary.ShowDialog() == DialogResult.OK)
                {
                    /* file selected */
                    Debug.WriteLine("OUT FILE SELECTED : " + saveFileDialogItinerary.FileName);
                }
                else
                {
                    Debug.WriteLine("File not selected thus returning");
                    try
                    {
                        mySqlConnection.Close();
                    }
                    catch (Exception errConnClose)
                    {
                        MessageBox.Show("Error in opening mysql connection because : " + errConnClose.Message);
                    }
                    return;
                }
                string imagePath = saveFileDialogItinerary.FileName + "logo.png";
                Properties.Resources.ExcursionHolidaysSmallLogo.Save(imagePath);

                Document document = new Document();
                document.Info.Title = "HOTEL VOUCHER FOR " + queryId;

                /* now cange the style of the document */
                MyPdfDocuments.DefineStyles(document);

                /* add section to document */
                Section section = document.AddSection();

                /* add hotel booking details.
                 * add different page for different hotel
                 */
                for (int pageNumber = 0; pageNumber < dataset.Tables["TABLE_HOTEL_ID"].Rows.Count; pageNumber++)
                {
                    mySqlQueryString = "SELECT * FROM `hotelbookinginfo` WHERE `queryid` = '" + queryId + "' AND idhotelinfo = " + dataset.Tables["TABLE_HOTEL_ID"].Rows[pageNumber]["idhotelinfo"].ToString();
                    mySqlDataAdapter = new MySqlDataAdapter(mySqlQueryString, mySqlConnection);
                    string tableNameHotelRates = "TABLE_HOTEL_ID_" + pageNumber.ToString();
                    mySqlDataAdapter.Fill(dataset, tableNameHotelRates);
                    mySqlQueryString = "SELECT `hoteladdress`, `hotelname` FROM `hotelinfo` WHERE `idhotelinfo` = " + dataset.Tables["TABLE_HOTEL_ID"].Rows[pageNumber]["idhotelinfo"].ToString();
                    mySqlDataAdapter = new MySqlDataAdapter(mySqlQueryString, mySqlConnection);
                    string tableNameHotelAddress = "HOTEL_ADDRESS_" + pageNumber.ToString();
                    mySqlDataAdapter.Fill(dataset, tableNameHotelAddress);
                    if (dataset.Tables[tableNameHotelRates].Rows.Count < 1)
                    {
                        continue;
                    }
                    if (pageNumber > 0)
                    {
                        section.AddPageBreak();
                    }
                    Paragraph paragraph = section.AddParagraph("HOTEL VOUCHER", "Heading1");
                    /* enter reference details in tabular form */
                    Table  table       = null;
                    Column column      = null;
                    int    columnCount = 0; // 1;
                    double columnWidth = 0; // (21.0 - 2.0) / columnCount;
                    Row    row         = null;
                    int    rowsCount   = 0;

                    table = section.AddTable();
                    table.Borders.Visible = true;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 3;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    for (int index = 0; index < columnCount; index++)
                    {
                        column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                        column.Format.Alignment = ParagraphAlignment.Center;
                    }
                    row = table.AddRow();
                    rowsCount++;
                    paragraph = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("Reference No", "Heading2");
                    paragraph = row.Cells[1].AddParagraph();
                    paragraph.AddFormattedText("Confirmed By", "Heading2");
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText("Hotel Confirmation No", "Heading2");

                    row = table.AddRow();
                    rowsCount++;
                    paragraph = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText(queryId, "Heading3");
                    paragraph = row.Cells[1].AddParagraph();
                    paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[0]["confirmby"].ToString(), "Heading3");
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[0]["idconfirmation"].ToString(), "Heading3");
                    /* Add contant for the table information */
                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1.5, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    section.AddParagraph("\n", "Normal");
                    /* add hotel address and agency address in table */
                    table = section.AddTable();
                    table.Borders.Visible = false;
                    table.Borders.Width   = 0.75;
                    columnCount           = 2;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    column = table.AddColumn(Unit.FromCentimeter(1.2));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    columnCount++;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth - 1.2));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    row = table.AddRow();
                    rowsCount++;
                    paragraph = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("Hotel Address Details", "Heading2");
                    paragraph = row.Cells[1].AddParagraph();
                    paragraph.AddFormattedText("Agency Address Details", "Heading2");
                    row.Cells[1].MergeRight = 1;

                    row = table.AddRow();
                    rowsCount++;
                    //MyPdfDocuments.WriteHdrContentParagraph(row.Cells[0], dataset.Tables[tableNameHotelAddress].Rows[0]["hotelname"].ToString(), dataset.Tables[tableNameHotelAddress].Rows[0]["hoteladdress"].ToString());
                    paragraph = row.Cells[0].AddParagraph();
                    paragraph.Format.RightIndent = "1.5cm";
                    paragraph.AddFormattedText(dataset.Tables[tableNameHotelAddress].Rows[0]["hotelname"].ToString() + "\n", "Heading3");
                    paragraph.AddFormattedText(dataset.Tables[tableNameHotelAddress].Rows[0]["hoteladdress"].ToString());

                    MigraDoc.DocumentObjectModel.Shapes.Image image = row.Cells[1].AddImage(imagePath);
                    image.Width = "1cm";
                    //image.Left = "-2.4cm";

                    MyPdfDocuments.WriteAgencyAddressDetails(row.Cells[2]);
                    /* Add contant for the table information */
                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1.5, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    section.AddParagraph("\n", "Normal");

                    table = section.AddTable();
                    table.Borders.Visible = true;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 6;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    for (int index = 1; index < columnCount; index++)
                    {
                        column = table.AddColumn(Unit.FromCentimeter(columnWidth + 0.45));
                        column.Format.Alignment = ParagraphAlignment.Left;
                    }
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth - (0.45 * 5)));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    row = table.AddRow();
                    rowsCount++;
                    row.VerticalAlignment = VerticalAlignment.Center;
                    paragraph             = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("Lead Passenger Name", "Heading2");
                    row.Cells[0].MergeRight = 1;
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[0]["leadpassangername"].ToString(), "Heading3");
                    row.Cells[2].MergeRight = 3;
                    row = table.AddRow();
                    rowsCount++;
                    row.VerticalAlignment = VerticalAlignment.Center;
                    paragraph             = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("Check In Date", "Heading2");
                    paragraph = row.Cells[1].AddParagraph();
                    //paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[0]["checkindate"].ToString(), "Heading3");
                    paragraph.AddFormattedText(DateTime.Parse(dataset.Tables[tableNameHotelRates].Rows[0]["checkindate"].ToString()).ToString("yyyy - MM - dd"), "Heading3");
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText("Check Out Date", "Heading2");
                    paragraph = row.Cells[3].AddParagraph();
                    //paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[0]["checkoutdate"].ToString(), "Heading3");
                    paragraph.AddFormattedText(DateTime.Parse(dataset.Tables[tableNameHotelRates].Rows[0]["checkoutdate"].ToString()).ToString("yyyy - MM - dd"), "Heading3");
                    paragraph = row.Cells[4].AddParagraph();
                    paragraph.AddFormattedText("No of Nights", "Heading2");
                    paragraph = row.Cells[5].AddParagraph();
                    double noOfnights = (DateTime.Parse(dataset.Tables[tableNameHotelRates].Rows[0]["checkoutdate"].ToString()) -
                                         DateTime.Parse(dataset.Tables[tableNameHotelRates].Rows[0]["checkindate"].ToString())).TotalDays;
                    paragraph.AddFormattedText(Convert.ToInt32(noOfnights).ToString(), "Heading3");
                    row = table.AddRow();
                    rowsCount++;
                    row.VerticalAlignment = VerticalAlignment.Center;
                    paragraph             = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("Pick Time", "Heading2");
                    paragraph = row.Cells[1].AddParagraph();
                    //paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[0]["checkindate"].ToString(), "Heading3");
                    paragraph.AddFormattedText(DateTime.Parse(dataset.Tables[tableNameHotelRates].Rows[0]["checkindate"].ToString()).ToString("HH:mm"), "Heading3");
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText("Drop Time", "Heading2");
                    paragraph = row.Cells[3].AddParagraph();
                    //paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[0]["checkoutdate"].ToString(), "Heading3");
                    paragraph.AddFormattedText(DateTime.Parse(dataset.Tables[tableNameHotelRates].Rows[0]["checkoutdate"].ToString()).ToString("HH:mm"), "Heading3");
                    row.Cells[4].MergeRight = 1;


                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1.5, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    section.AddParagraph("\n", "Normal");

                    table = section.AddTable();
                    table.Borders.Visible = true;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 6;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    column = table.AddColumn(Unit.FromCentimeter(1.5));
                    column.Format.Alignment = ParagraphAlignment.Center;
                    column = table.AddColumn(Unit.FromCentimeter(2 * columnWidth - 1.5));
                    column.Format.Alignment = ParagraphAlignment.Center;
                    for (int index = 2; index < columnCount; index++)
                    {
                        column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                        column.Format.Alignment = ParagraphAlignment.Center;
                    }
                    row = table.AddRow();
                    rowsCount++;
                    row.VerticalAlignment = VerticalAlignment.Center;
                    //row.Shading.Color = Colors.LightSlateGray;
                    paragraph = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("S. No", "Heading2");
                    paragraph = row.Cells[1].AddParagraph();
                    paragraph.AddFormattedText("Room Type", "Heading2");
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText("Meal Plan", "Heading2");
                    paragraph = row.Cells[3].AddParagraph();
                    paragraph.AddFormattedText("No of Rooms", "Heading2");
                    paragraph = row.Cells[4].AddParagraph();
                    paragraph.AddFormattedText("No of Guests", "Heading2");
                    paragraph = row.Cells[5].AddParagraph();
                    paragraph.AddFormattedText("Guests Type", "Heading2");
                    for (int roomCounter = 0; roomCounter < dataset.Tables[tableNameHotelRates].Rows.Count; roomCounter++)
                    {
                        row = table.AddRow();
                        rowsCount++;
                        row.VerticalAlignment = VerticalAlignment.Center;
                        paragraph             = row.Cells[0].AddParagraph();
                        paragraph.AddFormattedText((roomCounter + 1).ToString(), "Heading3");
                        paragraph = row.Cells[1].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[roomCounter]["roomtype"].ToString(), "Heading3");
                        paragraph = row.Cells[2].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[roomCounter]["mealplan"].ToString(), "Heading3");
                        paragraph = row.Cells[3].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countroom"].ToString(), "Heading3");
                        paragraph = row.Cells[4].AddParagraph();
                        int numberOfGuest = Convert.ToInt32(dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countadults"]) + Convert.ToInt32(dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countchildren"]);
                        paragraph.AddFormattedText(numberOfGuest.ToString(), "Heading3");
                        paragraph = row.Cells[5].AddParagraph();
                        string guestType = "Adults(" + dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countadults"].ToString() + ")";
                        if (Convert.ToInt32(dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countchildren"]) > 0)
                        {
                            guestType = guestType + "\nChildren(" + dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countchildren"].ToString() + ")";
                        }
                        if (Convert.ToInt32(dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countinfants"]) > 0)
                        {
                            guestType = guestType + "\nBabies(" + dataset.Tables[tableNameHotelRates].Rows[roomCounter]["countinfants"].ToString() + ")";
                        }
                        paragraph.AddFormattedText(guestType, "Heading3");
                    }

                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1.5, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    section.AddParagraph("\n", "Normal");

                    MyPdfDocuments.WriteHotelVoucherStaticDetails(section);
                }

                PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
                try
                {
                    /* try to save file */
                    renderer.Document = document;
                    renderer.RenderDocument();
                    renderer.PdfDocument.Save(saveFileDialogItinerary.FileName);
                    renderer.PdfDocument.Close();
                    Process.Start(saveFileDialogItinerary.FileName);
                }
                catch (Exception errSave)
                {
                    MessageBox.Show("Error in saving file " + saveFileDialogItinerary.FileName + " because " + errSave.Message);
                    Debug.WriteLine("Error in saving file " + saveFileDialogItinerary.FileName + " because " + errSave.Message);
                    closeForm = false;
                }
                finally
                {
                    System.IO.File.Delete(imagePath);
                }
                /* now close connection */
                try
                {
                    mySqlConnection.Close();
                }
                catch (Exception errConnClose)
                {
                    MessageBox.Show("Error in opening mysql connection because : " + errConnClose.Message);
                }

                if (closeForm)
                {
                    Debug.WriteLine("File saved: " + saveFileDialogItinerary.FileName);
                }
                else
                {
                    return;
                }
            }

            if ((button == BtnPrintFlightTickets) || (button == BtnPrintBoth))
            {
                //MessageBox.Show("Button pressed = " + button.Text, "PRINTING FLIGHT TICKETS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                /* open connection */
                try
                {
                    mySqlConnection.Open();
                }
                catch (Exception errConnOpen)
                {
                    MessageBox.Show("Error in opening mysql connection because : " + errConnOpen.Message);
                    return;
                }

                /* now execute query to obtain data from hotel booking table
                 * and fill t in dataset
                 */
                string           mySqlQueryString = "SELECT DISTINCT `pnr` FROM `flightbookinginfo` WHERE `queryid` = '" + queryId + "' ORDER BY `pnr`";
                DataSet          dataset          = new DataSet();
                MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mySqlQueryString, mySqlConnection);
                mySqlDataAdapter.Fill(dataset, "TABLE_FLIGHT_PNR");
                if ((dataset == null) || (dataset.Tables["TABLE_FLIGHT_PNR"].Rows.Count < 1))
                {
                    MessageBox.Show("No Flight information present for QueryId = " + queryId, "No Data Present", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    try
                    {
                        mySqlConnection.Close();
                    }
                    catch (Exception errConnClose)
                    {
                        MessageBox.Show("Error in opening mysql connection because : " + errConnClose.Message);
                    }
                    return;
                }
                saveFileDialogItinerary.Title = "FLIGHT TICKET FILE NAME";
                if (saveFileDialogItinerary.ShowDialog() == DialogResult.OK)
                {
                    /* file selected */
                    Debug.WriteLine("OUT FILE SELECTED : " + saveFileDialogItinerary.FileName);
                }
                else
                {
                    Debug.WriteLine("File not selected thus returning");
                    try
                    {
                        mySqlConnection.Close();
                    }
                    catch (Exception errConnClose)
                    {
                        MessageBox.Show("Error in opening mysql connection because : " + errConnClose.Message);
                    }
                    return;
                }
                string imagePath = saveFileDialogItinerary.FileName + "logo.png";
                Properties.Resources.ExcursionHolidaysSmallLogo.Save(imagePath);

                Document document = new Document();
                document.Info.Title = "FLIGHT TICKET FOR " + queryId;

                /* Ask for printing price on ticket */
                bool         printPrice   = false;
                DialogResult dialogResult = MessageBox.Show("Flight price details needs to be printed in the flight voucher?", "PRINT PRICE ON VOUCHER", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    printPrice = true;
                }
                else
                {
                    Debug.WriteLine("Price not printing in the ticket");
                }

                /* now cange the style of the document */
                MyPdfDocuments.DefineStyles(document);

                /* add section to document */
                Section section = document.AddSection();
                for (int pageNumber = 0; pageNumber < dataset.Tables["TABLE_FLIGHT_PNR"].Rows.Count; pageNumber++)
                {
                    mySqlQueryString = "SELECT * FROM `flightbookinginfo` WHERE `queryid` = '" + queryId + "' AND `pnr` = '" + dataset.Tables["TABLE_FLIGHT_PNR"].Rows[pageNumber]["pnr"].ToString() + "'";
                    mySqlDataAdapter = new MySqlDataAdapter(mySqlQueryString, mySqlConnection);
                    string tableFlightInfo = "TABLE_FLIGHT_ID_" + pageNumber.ToString();
                    mySqlDataAdapter.Fill(dataset, tableFlightInfo);
                    if (dataset.Tables[tableFlightInfo].Rows.Count < 1)
                    {
                        continue;
                    }
                    if (pageNumber > 0)
                    {
                        section.AddPageBreak();
                    }
                    Paragraph paragraph;
                    Table     table       = null;
                    Column    column      = null;
                    int       columnCount = 0; // 1;
                    double    columnWidth = 0; // (21.0 - 2.0) / columnCount;
                    Row       row         = null;
                    int       rowsCount   = 0;

                    table = section.AddTable();
                    table.Borders.Visible = false;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 3;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    column = table.AddColumn(Unit.FromCentimeter(1.2));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    columnCount++;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth - 1.2));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                    column.Format.Alignment = ParagraphAlignment.Center;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                    column.Format.Alignment = ParagraphAlignment.Right;
                    row = table.AddRow();
                    rowsCount++;
                    MigraDoc.DocumentObjectModel.Shapes.Image image = row.Cells[0].AddImage(imagePath);
                    image.Width = "1cm";
                    MyPdfDocuments.WriteAgencyAddressDetails(row.Cells[1]);
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText("E - Ticket\nTICKETED", "Heading2");
                    paragraph = row.Cells[3].AddParagraph();
                    paragraph.AddFormattedText("PNR: " + dataset.Tables[tableFlightInfo].Rows[0]["pnr"].ToString() +
                                               " \nIssued Date: " + DateTime.Parse(dataset.Tables[tableFlightInfo].Rows[0]["issuedate"].ToString()).ToString("ddd dd MM yyyy") +
                                               "", "Normal");

                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.None, 0, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    section.AddParagraph("\n", "Normal");

                    table = section.AddTable();
                    table.Borders.Visible = false;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 3;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                    column.Format.Alignment = ParagraphAlignment.Center;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                    column.Format.Alignment = ParagraphAlignment.Right;
                    row = table.AddRow();
                    rowsCount++;
                    row.Shading.Color = Colors.AliceBlue;
                    paragraph         = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("Passanger Name", "Heading3");
                    paragraph = row.Cells[1].AddParagraph();
                    paragraph.AddFormattedText("Ticket Number", "Heading3");
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText("Frequent flyer no.", "Heading3");
                    string[] persons = dataset.Tables[tableFlightInfo].Rows[0]["passangername"].ToString().Split(',');
                    string[] tickets = dataset.Tables[tableFlightInfo].Rows[0]["ticketnumber"].ToString().Split(',');
                    string[] ffys    = dataset.Tables[tableFlightInfo].Rows[0]["ffy"].ToString().Split(',');
                    for (int index = 0; index < persons.Length; index++)
                    {
                        if (string.Equals(persons[index], ""))
                        {
                            continue;
                        }
                        row = table.AddRow();
                        rowsCount++;
                        paragraph = row.Cells[0].AddParagraph();
                        paragraph.AddFormattedText(persons[index]);
                        paragraph = row.Cells[1].AddParagraph();
                        try
                        {
                            paragraph.AddFormattedText(tickets[index]);
                        }
                        catch (Exception errindex)
                        {
                            MessageBox.Show("Error : " + errindex.Message, "Error in index", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            paragraph.AddFormattedText("");
                        }
                        paragraph = row.Cells[2].AddParagraph();
                        try
                        {
                            paragraph.AddFormattedText(ffys[index]);
                        }
                        catch (Exception errindex)
                        {
                            MessageBox.Show("Error : " + errindex.Message, "Error in index", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            paragraph.AddFormattedText("-");
                        }
                    }

                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.None, 0.75, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    section.AddParagraph("\n", "Normal");

                    table = section.AddTable();
                    table.Borders.Visible = false;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 4;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    for (int index = 0; index < columnCount; index++)
                    {
                        column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                        column.Format.Alignment = ParagraphAlignment.Left;
                    }
                    row = table.AddRow();
                    row.Shading.Color = Colors.AliceBlue;
                    rowsCount++;
                    paragraph = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("Flight", "Heading3");
                    paragraph = row.Cells[1].AddParagraph();
                    paragraph.AddFormattedText("Departure", "Heading3");
                    paragraph = row.Cells[2].AddParagraph();
                    paragraph.AddFormattedText("Arrival", "Heading3");
                    paragraph = row.Cells[3].AddParagraph();
                    paragraph.AddFormattedText("Status", "Heading3");
                    for (int flightCounter = 0; flightCounter < dataset.Tables[tableFlightInfo].Rows.Count; flightCounter++)
                    {
                        row = table.AddRow();
                        rowsCount++;
                        paragraph = row.Cells[0].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableFlightInfo].Rows[flightCounter]["flightinfo"].ToString());
                        paragraph = row.Cells[1].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableFlightInfo].Rows[flightCounter]["departureinfo"].ToString());
                        paragraph = row.Cells[2].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableFlightInfo].Rows[flightCounter]["arrivalinfo"].ToString());
                        paragraph = row.Cells[3].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableFlightInfo].Rows[flightCounter]["statusinfo"].ToString());
                    }
                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.None, 0.75, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    section.AddParagraph("\n", "Normal");

                    table = section.AddTable();
                    table.Borders.Visible = false;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 4;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    for (int index = 0; index < 2; index++)
                    {
                        column = table.AddColumn(Unit.FromCentimeter(columnWidth + 1.0));
                        column.Format.Alignment = ParagraphAlignment.Left;
                    }
                    for (int index = 2; index < 4; index++)
                    {
                        column = table.AddColumn(Unit.FromCentimeter(columnWidth - 1.0));
                        column.Format.Alignment = ParagraphAlignment.Right;
                    }
                    if (printPrice)
                    {
                        row = table.AddRow();
                        rowsCount++;
                        row.Shading.Color = Colors.AliceBlue;
                        paragraph         = row.Cells[0].AddParagraph();
                        paragraph.AddFormattedText("Payment Details", "Heading3");
                        row.Cells[0].MergeRight = 3;
                    }
                    row = table.AddRow();
                    rowsCount++;
                    paragraph = row.Cells[0].AddParagraph();
                    paragraph.AddFormattedText("This is an Electronic ticket. Please carry a positive identification for Check in.");
                    paragraph.Format.Font.Bold = true;
                    row.Cells[0].MergeRight    = 1;
                    if (printPrice)
                    {
                        int totalPrice = Convert.ToInt32(dataset.Tables[tableFlightInfo].Rows[0]["amountfare"]) +
                                         Convert.ToInt32(dataset.Tables[tableFlightInfo].Rows[0]["amountgst"]) +
                                         Convert.ToInt32(dataset.Tables[tableFlightInfo].Rows[0]["amountsurcharge"]);
                        row.Cells[0].MergeDown = 3;
                        paragraph = row.Cells[2].AddParagraph();
                        paragraph.AddFormattedText("Fare", "Normal");
                        paragraph = row.Cells[3].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableFlightInfo].Rows[0]["amountfare"].ToString(), "Normal");
                        row = table.AddRow();
                        rowsCount++;
                        paragraph = row.Cells[2].AddParagraph();
                        paragraph.AddFormattedText("K3/GST", "Normal");
                        paragraph = row.Cells[3].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableFlightInfo].Rows[0]["amountgst"].ToString(), "Normal");
                        row = table.AddRow();
                        rowsCount++;
                        paragraph = row.Cells[2].AddParagraph();
                        paragraph.AddFormattedText("Fee & Surcharge", "Normal");
                        paragraph = row.Cells[3].AddParagraph();
                        paragraph.AddFormattedText(dataset.Tables[tableFlightInfo].Rows[0]["amountsurcharge"].ToString(), "Normal");
                        row = table.AddRow();
                        rowsCount++;
                        paragraph = row.Cells[2].AddParagraph();
                        paragraph.AddFormattedText("Total Amount");
                        paragraph.Format.Font.Bold = true;
                        paragraph = row.Cells[3].AddParagraph();
                        paragraph.AddFormattedText(totalPrice.ToString());
                        paragraph.Format.Font.Bold = true;
                    }
                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.None, 0.5, Colors.SkyBlue);
                    rowsCount = columnCount = 0;
                    paragraph = section.AddParagraph("\n\n\n", "Normal");

                    /* ADD TERMINAL DETAILS HERE */
                    //paragraph = section.AddParagraph("<TERMINAL DETAILS TYPED HERE XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX>");
                    //paragraph.Format.Font.Color = Colors.Red;
                    table = section.AddTable();
                    table.Borders.Visible = false;
                    table.Borders.Width   = 0.75;
                    table.Borders.Color   = Colors.SkyBlue;
                    columnCount           = 1;
                    columnWidth           = (21.0 - 2.0) / columnCount;
                    column = table.AddColumn(Unit.FromCentimeter(columnWidth));
                    column.Format.Alignment = ParagraphAlignment.Left;
                    row = table.AddRow();
                    rowsCount++;
                    MyPdfDocuments.WriteFlightVoucherNote(row.Cells[0]);

                    table.SetEdge(0, 0, columnCount, rowsCount, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 0, Colors.SkyBlue);
                }

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

                try
                {
                    /* try to save file */
                    renderer.Document = document;
                    renderer.RenderDocument();
                    renderer.PdfDocument.Save(saveFileDialogItinerary.FileName);
                    renderer.PdfDocument.Close();
                    Process.Start(saveFileDialogItinerary.FileName);
                    Debug.WriteLine("File saved: " + saveFileDialogItinerary.FileName);
                }
                catch (Exception errSave)
                {
                    MessageBox.Show("Error in saving file " + saveFileDialogItinerary.FileName + " because " + errSave.Message);
                    Debug.WriteLine("Error in saving file " + saveFileDialogItinerary.FileName + " because " + errSave.Message);
                    closeForm = false;
                }
                finally
                {
                    System.IO.File.Delete(imagePath);
                }
                try
                {
                    mySqlConnection.Close();
                }
                catch (Exception errConnClose)
                {
                    MessageBox.Show("Error in opening mysql connection because : " + errConnClose.Message);
                }
            }
            if (closeForm)
            {
                Close();
            }
        }
Example #29
0
        void Pages()
        {
            //Document doc = new Document();
            Section sec = doc.AddSection();

            // // create a table
            var table = sec.AddTable();

            table.AddColumn("7cm");
            table.AddColumn("13cm");
            var row = table.AddRow();

            table.Rows.LeftIndent = "0.5cm";
            var image = row.Cells[0].AddImage("Resources/logo.png");

            image.Height = "19mm";
            var cell = row.Cells[1].AddParagraph("Energy Service Report\n");

            //cell.AddBookmark("Energy Service Report");
            //cell.Format.Font.Name = "SegoeUIGrass";
            cell.Format.Font.Size = 22;
            cell.Format.Font.Bold = true;

            cell.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.Parse("#103058");
            cell.Format.SpaceAfter = "3mm";

            var cell2 = row.Cells[1].AddParagraph("Cordium: Real - time heat control");

            cell2.Format.Font.Size  = 18;
            cell2.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.Parse("#02BBE6");

            Paragraph line = sec.AddParagraph();

            line.Format.Borders.Distance = "-3pt";
            line.Format.Borders.Bottom   = new Border()
            {
                Width = "2pt", Color = Colors.DarkGray
            };
            //line.Format.SpaceAfter = "2mm";

            Paragraph Period = sec.AddParagraph("Period: ", "Heading1");

            Period.Format.TabStops.ClearAll();
            Period.Format.TabStops.AddTabStop(Unit.FromMillimeter(176), MigraDoc.DocumentObjectModel.TabAlignment.Right);
            Period.AddTab();
            Period.Format.Alignment = ParagraphAlignment.Left;
            string DateMY = DateTime.Now.ToString("MMMM, yyyy", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"));

            Period.AddFormattedText(DateMY).Color = MigraDoc.DocumentObjectModel.Color.Parse("#838383");

            Paragraph ProjectDetails = sec.AddParagraph("Project Details:", "Heading1");

            var cordium = sec.AddImage("Resources/cordium.png");

            cordium.Left  = ShapePosition.Center;
            cordium.Width = "17 cm";
            DotListAdd2(doc, "Project Manager: Frank Louwet",
                        "Location: Crutzestraat, Hasselt");


            //для списка с точкой
            //string[] items = "Project Manager: Frank Louwet |Location: Crutzestraat, Hasselt ".Split('|');
            //for (int idx = 0; idx < items.Length; ++idx)
            //{
            //    ListInfo listinfo = new ListInfo();
            //    listinfo.ContinuePreviousList = idx > 0;
            //    listinfo.ListType = ListType.BulletList1;
            //    cordium = sec.AddParagraph(items[idx]);
            //    cordium.Style = "MyBulletList";
            //    cordium.Format.ListInfo = listinfo;
            //}
            //void DotListAdd(Document doc, Paragraph par, string str)
            //{
            //    ListInfo listinfo = new ListInfo();
            //    listinfo.ContinuePreviousList = false;
            //    listinfo.ListType = ListType.BulletList1;
            //    par = sec.AddParagraph(str);
            //    par.Style = "MyBulletList";
            //    par.Format.ListInfo = listinfo;
            //}

            void DotListAdd2(Document doc, params string[] arrstr)
            {
                //string[] items = "Project Manager: Frank Louwet |Location: Crutzestraat, Hasselt ".Split('|');
                for (int idx = 0; idx < arrstr.Length; ++idx)
                {
                    sec.AddParagraph(arrstr[idx], "BulletList");
                }
            }

            //doc.Styles.AddStyle("Bulletlist", "Normal");
            //var style = Styles["BulletList"];
            //style.ParagraphFormat.RightIndent = 12;
            //style.ParagraphFormat.TabStops.ClearAll();
            //style.ParagraphFormat.TabStops.AddTabStop(Unit.FromCentimeter(2.5), TabAlignment.Left);
            //style.ParagraphFormat.LeftIndent = "2.5cm";
            //style.ParagraphFormat.FirstLineIndent = "-0.5cm";
            //style.ParagraphFormat.SpaceBefore = 0;
            //style.ParagraphFormat.SpaceAfter = 0;

            Paragraph ExecutiveSummary = sec.AddParagraph("Executive Summary:", "Heading1");

            Paragraph ContentExecutiveSummary = sec.AddParagraph("This month there were a total of 345 degree days", "Text");

            ContentExecutiveSummary.Format.SpaceBefore = "5mm";

            sec.AddParagraph("Phase 1 heating energy:", "Text");
            sec.AddParagraph("2196 kWh of gas consumed(0.32 kWh per apartment per degree day)", "BulletList");
            sec.AddParagraph("Phase 2 heating energy: ", "Text");
            DotListAdd2(doc, "14515 kWh of gas consumed(2.1 kWh per apartment per degree day)",
                        "3.5 kWh of electricity consumed(0.00051 kWh per apartment per degree day)");
            sec.AddParagraph("Phase 3 heating energy: ", "Text");
            DotListAdd2(doc, "17791 kWh of gas consumed (1.8 kWh per apartment per degree day)",
                        "650 kWh of electricity produced");


            Paragraph ProjectOverview = sec.AddParagraph("Project Overview:", "Heading1");

            Paragraph ContentProjectOverview = sec.AddParagraph("The advanced control strategy is implemented in a district " +
                                                                "heating system for social housing in Crutzestraat, Hasselt. The social housing is operated " +
                                                                "by Cordium, the operating manager for social housing in Flemish region. The project consists" +
                                                                " of three phases or buildings with 20, 20 and 28 apartments in each phase. Each building " +
                                                                "has its own central heating system with various technologies installed. Furthermore, " +
                                                                "central heating systems are interconnected by an internal heat transfer network. " +
                                                                "i.Leco developed the control strategy which sends hourly setpoints fo: maximum and " +
                                                                "minimum temperature setpoint in each building and/or distribution circuit, operation " +
                                                                "modes of installed technologies, and distribution state settings between building/heating " +
                                                                "systems.", "Text");

            ContentProjectOverview.Format.SpaceAfter = "-5 mm";



            doc.LastSection.AddPageBreak();

            //2
            Paragraph phase1 = sec.AddParagraph("Phase 1", "Heading1");

            phase1.Format.Borders.Bottom.Visible = false;
            sec.AddParagraph("Installed technologies:", "Text");
            sec.AddParagraph("Geothermal/water gas absorption heat pumps – 2 pcs", "BulletList");
            //Paragraph fig1 = sec.AddParagraph("","figure");
            var img1 = sec.AddImage("Resources/2.1.jpg");

            //img1.Height = "10cm";
            img1.Top             = "10mm";
            img1.LockAspectRatio = true;
            img1.Left            = ShapePosition.Center;
            sec.AddParagraph("\nFigure 1: Phase 1 Energy Diagram", "figure");

            sec.AddParagraph("This month 20 MWh of heating energy was provided to the phase 1 building by heat pumps." +
                             " Consumption of gas compared with previous months is shown below.", "Text2");

            var img2 = sec.AddImage("Resources/2.2.jpg");

            img2.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 2: Phase 1 Energy Consumption monthly comparison", "figure");

            Paragraph fig3 = sec.AddParagraph("", "figure");

            fig3.AddImage("Resources/2.3.jpg");
            fig3.AddFormattedText("\nFigure 3: Phase 1 Control (" + DateMY + ")", "Text");
            sec.AddParagraph("The minimum return water temperature this month was 39.4 °C", "Text");

            doc.LastSection.AddPageBreak();

            Paragraph phase2 = sec.AddParagraph("Phase 2", "Heading1");

            phase2.Format.Borders.Bottom.Visible = false;
            sec.AddParagraph("Installed technologies:", "Text");
            DotListAdd2(doc, "Electrical air/water heat pump",
                        "Electrical geothermal/water heat pump",
                        "Geothermal / water gas absorption heat pump",
                        "Gas condensing boiler");


            Paragraph fig4 = sec.AddParagraph("", "figure");

            fig4.Format.SpaceBefore = "10mm";
            fig4.AddImage("Resources/4.1.jpg");
            fig4.AddFormattedText("\nFigure 4: Phase 2 Energy Diagram", "Text");
            sec.AddParagraph("The electrical and gas energy consumed by the " +
                             "installed technologies this month is shown below:", "Text");
            //Paragraph fig5 = sec.AddParagraph("", "figure");
            var img5 = sec.AddImage("Resources/4.2.jpg");

            img5.Left = ShapePosition.Center;

            sec.AddParagraph("Figure 5: Phase 2 Energy Consumption", "figure");
            sec.AddParagraph("This month 19.5 MWh of heating energy was provided to the phase 2 " +
                             "building by heat pumps and the gas boiler.Consumption of electricity " +
                             "and gas compared with previous months is shown below.", "Text");

            var img6 = sec.AddImage("Resources/5.1.jpg");

            img6.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 6: Phase 2 Energy Consumption monthly comparison", "figure");
            var img7 = sec.AddImage("Resources/5.2.jpg");

            img7.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 7: Phase 2 Control (" + DateMY + ")", "figure");
            sec.AddParagraph("The minimum return water temperature this month was 35.6 °C", "Text");

            doc.LastSection.AddPageBreak();
            Paragraph phase3 = sec.AddParagraph("Phase 3", "Heading1");

            phase3.Format.Borders.Bottom.Visible = false;

            sec.AddParagraph("Installed technologies:", "Text");
            DotListAdd2(doc, "Combined heat and power",
                        "Gas boilers – 3 pcs");
            var img8 = sec.AddImage("Resources/6.1.jpg");

            img8.Left = ShapePosition.Center;
            img8.Top  = "8mm";
            sec.AddParagraph("\nFigure 8: Phase 3 Energy Diagram", "figure");
            sec.AddParagraph("The gas energy consumed by the installed technologies this month is shown below:", "Text");

            var img9 = sec.AddImage("Resources/6.2.jpg");

            img9.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 9: Phase 3 Energy Consumption", "figure");
            sec.AddParagraph("This month 29 MWh of heating energy was provided to the phase 3 building by gas boilers and the combined heat & " +
                             "power plant.Consumption of gas and electricity production compared with previous months is shown below.", "Text");
            //7
            var img10 = sec.AddImage("Resources/7.1.jpg");

            img10.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 10: Phase 3 Energy Consumption/production monthly comparison", "figure");

            var img11 = sec.AddImage("Resources/7.2.jpg");

            img11.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 11: Phase 3 Control (" + DateMY + ")", "figure");
            sec.AddParagraph("The minimum return water temperature this month was 45.9 °C", "Text");

            // Create footer
            Paragraph footer = sec.Footers.Primary.AddParagraph();

            footer.AddText("i.Leco © ");
            footer.AddDateField("dd/MM/yyyy");
            // Clear all existing tab stops, and add our calculated tab stop, on the right
            footer.Format.TabStops.ClearAll();
            footer.Format.TabStops.AddTabStop(Unit.FromMillimeter(178), MigraDoc.DocumentObjectModel.TabAlignment.Right);
            footer.AddTab();
            footer.AddPageField();
            footer.AddText("/");
            footer.AddNumPagesField();
        }
        private void Fill()
        {
            Section section = _document.AddSection();
            Image   img     = section.AddImage(_path + "/img/logo/logo.png");

            img.Height = "4cm";

            Paragraph paragraph = section.AddParagraph();

            paragraph.AddLineBreaks(count: 2);

            Table table = CreateTableWithHeading("Приобретенные товары:");
            Row   row   = table.AddRow();

            row.Height         = 25;
            row.Borders.Bottom = new Border()
            {
                Width = "1pt", Color = Colors.DarkGray
            };
            row.Cells[0].AddParagraph("Артикул:");
            row.Cells[1].AddParagraph("Название:");
            row.Cells[2].AddParagraph("Количество:");
            row.Cells[3].AddParagraph("Цена:");

            foreach (var od in _orderHeader.OrderDetails)
            {
                row        = table.AddRow();
                row.Height = 20;
                row.Cells[0].AddParagraph(od.VendorCode);
                row.Cells[1].AddParagraph(od.Furniture.Name);
                row.Cells[2].AddParagraph($"{od.Quantity} шт.");
                row.Cells[3].AddParagraph($"{(int)od.Furniture.Price} грн");
            }
            row             = table.AddRow();
            row.Borders.Top = new Border()
            {
                Width = "1pt", Color = Colors.DarkGray
            };
            //
            row = table.AddRow();
            row.Borders.Bottom = new Border()
            {
                Width = "1pt", Color = Colors.DarkGray
            };
            paragraph = row.Cells[3].AddParagraph();
            FormattedText text = paragraph.AddFormattedText("Итог:", TextFormat.Bold);

            text.Color = Colors.Black;
            row.Height = 25;
            //
            row = table.AddRow();
            row.Cells[3].AddParagraph($"{_orderHeader.GetSum()} грн");

            paragraph = section.AddParagraph();
            paragraph.AddLineBreaks(count: 4);
            paragraph.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.FromCmyk(100, 30, 20, 50);
            paragraph.AddTextLines(
                $"Дата: {DateTime.Now.ToString("d")}",
                $"Покупатель: {_orderHeader.AppUser.Name}");
            paragraph.Format.Alignment = ParagraphAlignment.Right;

            paragraph = section.AddParagraph();
            paragraph.AddLineBreaks(count: 2);
            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.AddTextLines("Будем рады Вас видеть, FurnitureShop!");
        }
Example #31
0
        private void CreateBidding(int nr)
        {
            Section   section = document.LastSection;
            Paragraph tp      = section.AddParagraph();

            tp.AddLineBreak();
            tp.AddLineBreak();

            tp.AddFormattedText("LICYTACJA", font_tytuly);
            tp.AddLineBreak();
            tp.AddLineBreak();

            Table table = new Table();

            table.Format.Font.Name = "Cambria";
            table.Format.Font.Size = 8;
            table.Format.Alignment = ParagraphAlignment.Center;


            for (int i = 0; i < 4; i++)
            {
                Column col = table.AddColumn(Unit.FromCentimeter(bidding_szerokosckolumny));
                col.Borders.Width = szerokosc_krawedzi;
            }
            Row row = table.AddRow();

            row = CreateBidding_FirstRow(row);
            row = table.AddRow();
            row = CreateBidding_Surname(row);

            row = table.AddRow();

            int idx = 1;

            if (game.cztery_rece)
            {
                while (game.licytacja_[nr][idx] != null)
                {
                    if ((idx - 1 + nr) % 4 == 0)
                    {
                        if (idx != 1)
                        {
                            row = table.AddRow();
                        }
                        Paragraph p = row.Cells[(idx - 1 + nr) % 4].AddParagraph();
                        p = WriteOdzywka(p, game.licytacja_[nr][idx]);
                    }

                    else
                    {
                        Paragraph p = row.Cells[(idx - 1 + nr) % 4].AddParagraph();

                        p = WriteOdzywka(p, game.licytacja_[nr][idx]);
                    }
                    idx++;
                }
            }
            else
            {
                int test = 0;
                while (game.licytacja_[nr][idx] != null)
                {
                    if ((idx - 1 + test) % 4 == 0)
                    {
                        if (idx != 1)
                        {
                            row = table.AddRow();
                        }
                        Paragraph p = row.Cells[(idx - 1 + test) % 4].AddParagraph();
                        p = WriteOdzywka(p, game.licytacja_[nr][idx]);
                    }

                    else
                    {
                        Paragraph p = row.Cells[(idx - 1 + test) % 4].AddParagraph();

                        p = WriteOdzywka(p, game.licytacja_[nr][idx]);
                    }
                    idx++;
                }
            }


            table.Rows.Height            = Unit.FromCentimeter(0.6);
            table.Rows.VerticalAlignment = VerticalAlignment.Center;

            table.SetEdge(0, 0, 4, 1, Edge.Box, BorderStyle.Single, 1.0, Colors.Black);

            /*
             *       table[0, 4].Borders.Bottom.Width = 0;
             *       table[0, 5].Borders.Bottom.Width = 0;
             *       table[0, 4].Borders.Top.Width = 0;
             *       table[0, 5].Borders.Top.Width = 0;
             *       table[0, 4].Borders.Right.Width = 0;
             *       table[0, 4].Shading.Color = Colors.White;
             *       table[0, 5].Shading.Color = Colors.White;
             */
            document.LastSection.Add(table);
        }
Example #32
0
        public static void CreatePage(Document document, List <LInfo> list)
        {
            // Each MigraDoc document needs at least one section.
            Section section = document.AddSection();

            // Put a logo in the header
            Image image = section.Headers.Primary.AddImage("../../PowerBooks.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;

            // Create footer
            Paragraph paragraph = section.Footers.Primary.AddParagraph();

            paragraph.AddText("Na potoce 390/27 · Třebíč");
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Create the text frame for the address
            TextFrame addressFrame = section.AddTextFrame();

            addressFrame.Height             = "3.0cm";
            addressFrame.Width              = "7.0cm";
            addressFrame.Left               = ShapePosition.Left;
            addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            addressFrame.Top = "5.0cm";
            addressFrame.RelativeVertical = RelativeVertical.Page;

            // Put sender in address frame
            paragraph = addressFrame.AddParagraph("Na potoce 390/27, Třebíč");
            paragraph.Format.Font.Name  = "Times New Roman";
            paragraph.Format.Font.Size  = 7;
            paragraph.Format.SpaceAfter = 3;

            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "8cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText(Lng.Get("Lended"), TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddText("Třebíč, ");
            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.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

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

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

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

            // 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 = TableBlue;
            row.Cells[0].AddParagraph(Lng.Get("Number"));
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
            row.Cells[1].AddParagraph(Lng.Get("Type"));
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[2].AddParagraph(Lng.Get("ItemName", "Name"));
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[3].AddParagraph(Lng.Get("LendFrom", "Lend from"));
            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[4].AddParagraph(Lng.Get("LendTo", "Lend to"));
            row.Cells[4].Format.Alignment = ParagraphAlignment.Left;

            //row.Cells[0].MergeDown = 1;
            //row.Cells[1].MergeRight = 3;

            // Fill Table
            int i = 0;

            if (list != null && list.Count > 0)
            {
                foreach (var item in list)
                {
                    row = table.AddRow();
                    row.HeadingFormat    = true;
                    row.Format.Alignment = ParagraphAlignment.Center;
                    row.Format.Font.Bold = true;
                    row.Cells[0].AddParagraph((i + 1).ToString());
                    row.Cells[0].Format.Font.Bold  = false;
                    row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
                    row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
                    row.Cells[1].AddParagraph(global.GetItemTypeName(item.ItemType));
                    row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                    row.Cells[2].AddParagraph(item.Name);
                    row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
                    row.Cells[3].AddParagraph(item.LendFrom.ToShortDateString());
                    row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
                    row.Cells[4].AddParagraph(item.LendTo.ToShortDateString());
                    row.Cells[4].Format.Alignment = ParagraphAlignment.Left;
                    i++;
                }
            }

            table.SetEdge(0, 0, 5, 1 + i, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Example #33
0
        public void CreatePage(Document document, int BidId)
        {
            BidDomain bid = _BidService.BidGetById(BidId);

            Section section = document.AddSection();

            // Create the text frame for the address
            TextFrame addressFrame = section.AddTextFrame();

            addressFrame.Height             = "3.0cm";
            addressFrame.Width              = "7.0cm";
            addressFrame.Left               = ShapePosition.Left;
            addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            addressFrame.Top = "5.0cm";
            addressFrame.RelativeVertical = RelativeVertical.Page;

            // Add  content to address frame
            Paragraph paragraph = addressFrame.AddParagraph();

            paragraph.AddText(bid.Address1 + ", " + bid.City);
            paragraph.AddLineBreak();
            paragraph.AddText(bid.State + " " + bid.ZipCode);

            Paragraph paragraph2 = section.AddParagraph();

            paragraph2.Format.SpaceBefore = "8cm";

            // 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.5cm");
            column.Format.Alignment = ParagraphAlignment.Right;

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

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

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

            //column = table.AddColumn("4cm");
            //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 = TableBlue;
            row.Cells[0].AddParagraph("Item");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
            row.Cells[0].MergeDown         = 1;
            //row.Cells[1].AddParagraph("Title and Author");
            //row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            //row.Cells[1].MergeRight = 3;
            //row.Cells[5].AddParagraph("Extended Price");
            //row.Cells[5].Format.Alignment = ParagraphAlignment.Left;
            //row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
            //row.Cells[5].MergeDown = 1;

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            //row.Shading.Color = TableBlue;
            row.Cells[1].AddParagraph("Quote Request");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[2].AddParagraph("Quote Request Item");
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            row.Cells[3].AddParagraph("Amount");
            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
            //row.Cells[4].AddParagraph("Taxable");
            //row.Cells[4].Format.Alignment = ParagraphAlignment.Left;


            string  quoteRequestName     = bid.QrName;
            string  quoteRequestItemName = bid.QriName;
            decimal bidAmount            = bid.Amount;

            Row row1 = table.AddRow();

            row1.Cells[0].AddParagraph("1");
            row1.Cells[1].AddParagraph(quoteRequestName);
            row1.Cells[2].AddParagraph(quoteRequestItemName);
            row1.Cells[3].AddParagraph("$" + bidAmount.ToString("0.00"));


            //table.SetEdge(0, 0, 6, 6, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Example #34
0
        //------//-----------//----------//---------//----------//----------//--------//

        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        void CreatePage()
        {
            string date = DateTime.Now.ToString(); // dont think i need this line anymore

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

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

            // Put a logo in the header
#if DEBUG
            Image image = section.Headers.Primary.AddImage("../../logo2.PNG");
#else
            Image image = section.Headers.Primary.AddImage("logo2.PNG");
#endif
            image.Width           = "18cm";
            image.LockAspectRatio = false;
            //image.Height = "2.5cm";
            image.RelativeVertical   = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top              = ShapePosition.Top;
            image.Left             = ShapePosition.Left;
            image.WrapFormat.Style = WrapStyle.Through;

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

            // Create footer
            Paragraph paragraph = section.Footers.Primary.AddParagraph();
            paragraph.AddText("Charbonneau Vendette Solutions ");
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

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

            // Create the text frame for the address
            this.addressFrame                    = section.AddTextFrame();
            this.addressFrame.Height             = "3.0cm";
            this.addressFrame.Width              = "7.0cm";
            this.addressFrame.Left               = ShapePosition.Left;
            this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.addressFrame.Top                = "3.5cm";
            this.addressFrame.RelativeVertical   = RelativeVertical.Page;

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

            // Put sender in address frame
            paragraph = this.addressFrame.AddParagraph("     Tents For All Events");
            paragraph.Format.Font.Name   = "Calibri";
            paragraph.Format.Font.Bold   = true;
            paragraph.Format.Font.Color  = Colors.Black;
            paragraph.Format.Font.Size   = 13;
            paragraph.Format.SpaceBefore = "0.075cm";
            paragraph.Format.SpaceAfter  = 3;

            //----------------------------------------------------------------------------
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "2cm";
            paragraph.Style = "Reference";
            if (Driver == null)
            {
                paragraph.AddText("Driver: __________________");
            }
            else
            {
                paragraph.AddText(string.Format("Driver: {0}", Driver));
            }

            paragraph.AddTab();
            // TODO: Revisit exceptions (like not having a trailer)
            paragraph.AddText(string.Format("Vehicle: {0}, Trailer: {1}, ", Truck, Trailer));
            paragraph.AddText(InstallDate);
            paragraph.Format.Font.Size = 14;

            // Add the print date field
            //paragraph = section.AddParagraph();
            //paragraph.Format.SpaceBefore = "0.5cm";
            //paragraph.Style = "Reference";
            //paragraph.AddFormattedText("List Of Materials", TextFormat.Bold);
            //paragraph.Format.Font.Size = 14;
            //paragraph.AddTab();


            //--------------------------------------------------------------------------//
            //------//-----------//----     Metal Table      -----//----------//--------//
            //--------------------------------------------------------------------------//

            // Create the item table
            this.table                     = section.AddTable();
            table.Rows.Alignment           = RowAlignment.Center;
            this.table.Style               = "Table";
            this.table.Borders.Color       = Colors.Black;
            this.table.Borders.Width       = 0.5;
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;

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

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

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

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

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

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

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

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

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

            column = this.table.AddColumn("0.75cm");
            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    = Colors.LightGray;

            // Makes the new rows for the Metal
            row.Cells[0].AddParagraph("Metal");
            row.Cells[0].Format.Font.Bold  = true;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 8;

            // Get count of metal items
            int MetalTableSize = Counts.Metal.Count;

            // Extract metal list to small variable name ;)
            List <TentItems> metal = Counts.Metal;

            int b = 0;
            int r = 0;

            if (metal != null)
            {
                for (int i = 0; i < MetalTableSize; ++i)  //max number of rows for one page before cutting into other tings is 33 (or 32 for i)
                {
                    if (i == 0 || i % 3 == 0)
                    {
                        row = table.AddRow();
                        row.HeadingFormat    = true;
                        row.Format.Alignment = ParagraphAlignment.Center;
                        row.Format.Font.Bold = true;
                        row.Shading.Color    = Colors.White;
                        b = 0;
                        r++;
                    }


                    row.Cells[b].AddParagraph("□");
                    row.Cells[b].Format.Font.Bold  = true;
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[0].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(metal[i].Type);
                    row.Cells[b].Format.Alignment = ParagraphAlignment.Center;
                    //row.Cells[1].MergeRight = 0;
                    //row.Cells[1].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(metal[i].Qty.ToString());
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[2].MergeDown = 1;
                    //row.Cells[b].Format.Borders.Right.Width = 2;
                    b++;
                }
            }
            this.table.SetEdge(0, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
            this.table.SetEdge(3, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
            this.table.SetEdge(0, 0, 9, r + 1, Edge.Box, BorderStyle.Single, 1, Colors.Black);
            //this.table.SetEdge(0, 0, 9, r + 1, Edge.Top, BorderStyle.Single, 1, Colors.Black);

            //--------------------------------------------------------------------------//
            //------//-----------//--    End Metal Table      ----//----------//--------//
            //--------------------------------------------------------------------------//

            //--------------------------------------------------------------------------//
            //------//-----------//----     Covers Table     -----//----------//--------//
            //--------------------------------------------------------------------------//

            // Create the item table
            this.table                     = section.AddTable();
            table.Rows.Alignment           = RowAlignment.Center;
            this.table.Style               = "Table";
            this.table.Borders.Color       = Colors.Black;
            this.table.Borders.Width       = 0.5;
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;

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

            // Before you can add a row, you must define the columns
            Column column2 = this.table.AddColumn("0.5cm");
            column2.Format.Alignment = ParagraphAlignment.Center;

            column2 = this.table.AddColumn("4.08cm");
            column2.Format.Alignment = ParagraphAlignment.Right;

            column2 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column2 = this.table.AddColumn("0.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column2 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column2 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column2 = this.table.AddColumn("0.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column2 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column2 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

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

            // Create the header of the table
            Row row2 = table.AddRow();
            row2.HeadingFormat    = true;
            row2.Format.Alignment = ParagraphAlignment.Center;
            row2.Format.Font.Bold = true;
            row2.Shading.Color    = Colors.LightGray;

            row2.Cells[0].AddParagraph("Covers");
            row2.Cells[0].Format.Font.Bold  = true;
            row2.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row2.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row2.Cells[0].MergeRight        = 8;

            // Extract to smaller variable name
            List <TentItems> cover = Counts.Covers;

            // Get the size
            int CoverTableSize = cover.Count;

            // Reset b to zero
            b = 0;
            r = 0;

            if (cover != null)
            {
                for (int i = 0; i < CoverTableSize; ++i)  //max number of rows for one page before cutting into other tings is 33 (or 32 for i)
                {
                    if (i == 0 || i % 3 == 0)
                    {
                        row = table.AddRow();
                        row.HeadingFormat    = true;
                        row.Format.Alignment = ParagraphAlignment.Center;
                        row.Format.Font.Bold = true;
                        row.Shading.Color    = Colors.White;
                        b = 0;
                        r++;
                    }


                    row.Cells[b].AddParagraph("□");
                    row.Cells[b].Format.Font.Bold  = true;
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[0].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(cover[i].Type);
                    row.Cells[b].Format.Alignment = ParagraphAlignment.Center;
                    //row.Cells[1].MergeRight = 0;
                    //row.Cells[1].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(cover[i].Qty.ToString());
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[2].MergeDown = 1;
                    b++;
                }
                this.table.SetEdge(0, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
                this.table.SetEdge(3, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
                this.table.SetEdge(0, 0, 9, r + 1, Edge.Left, BorderStyle.Single, 1, Colors.Black);
                this.table.SetEdge(0, 0, 9, r + 1, Edge.Right, BorderStyle.Single, 1, Colors.Black);
            }

            //--------------------------------------------------------------------------//
            //------//-----------//----     Walls  Table     -----//----------//--------//
            //--------------------------------------------------------------------------//

            // Create the item table
            this.table                     = section.AddTable();
            table.Rows.Alignment           = RowAlignment.Center;
            this.table.Style               = "Table";
            this.table.Borders.Color       = Colors.Black;
            this.table.Borders.Width       = 0.5;
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;

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

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

            column3 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column3 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column3 = this.table.AddColumn("0.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column3 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column3 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column3 = this.table.AddColumn("0.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column3 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column3 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

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

            // Create the header of the table
            Row row3 = table.AddRow();
            row3.HeadingFormat    = true;
            row3.Format.Alignment = ParagraphAlignment.Center;
            row3.Format.Font.Bold = true;
            row3.Shading.Color    = Colors.LightGray;

            row3.Cells[0].AddParagraph("Walls");
            row3.Cells[0].Format.Font.Bold  = true;
            row3.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row3.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row3.Cells[0].MergeRight        = 8;

            // Extract to smaller variable name
            List <TentItems> walls = Counts.Walls;

            // Get the size
            int WallsTableSize = walls.Count;

            // Reset b to zero
            b = 0;
            r = 0;

            if (cover != null)
            {
                for (int i = 0; i < WallsTableSize; ++i)  //max number of rows for one page before cutting into other tings is 33 (or 32 for i)
                {
                    if (i == 0 || i % 3 == 0)
                    {
                        row = table.AddRow();
                        row.HeadingFormat    = true;
                        row.Format.Alignment = ParagraphAlignment.Center;
                        row.Format.Font.Bold = true;
                        row.Shading.Color    = Colors.White;
                        b = 0;
                        r++;
                    }


                    row.Cells[b].AddParagraph("□");
                    row.Cells[b].Format.Font.Bold  = true;
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[0].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(walls[i].Type);
                    row.Cells[b].Format.Alignment = ParagraphAlignment.Center;
                    //row.Cells[1].MergeRight = 0;
                    //row.Cells[1].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(walls[i].Qty.ToString());
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[2].MergeDown = 1;
                    b++;
                }
                this.table.SetEdge(0, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
                this.table.SetEdge(3, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
                this.table.SetEdge(0, 0, 9, r + 1, Edge.Box, BorderStyle.Single, 1, Colors.Black);
            }
            //--------------------------------------------------------------------------//
            //------//-----------//----  Tie Downs Table     -----//----------//--------//
            //--------------------------------------------------------------------------//

            // Create the item table
            this.table                     = section.AddTable();
            table.Rows.Alignment           = RowAlignment.Center;
            this.table.Style               = "Table";
            this.table.Borders.Color       = Colors.Black;
            this.table.Borders.Width       = 0.5;
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;

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

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

            column4 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column4 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column4 = this.table.AddColumn("0.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column4 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column4 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column4 = this.table.AddColumn("0.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column4 = this.table.AddColumn("4.08cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            column4 = this.table.AddColumn("0.75cm");
            column.Format.Alignment = ParagraphAlignment.Right;

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

            // Create the header of the table
            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = Colors.LightGray;

            row.Cells[0].AddParagraph("Tie-Downs");
            row.Cells[0].Format.Font.Bold  = true;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[0].MergeRight        = 8;

            // Get count of tie down items
            int TieDownTableSize = Counts.TieDowns.Count;

            // Extract to smaller list
            List <TentItems> TieDown = Counts.TieDowns;

            b = 0;
            r = 0;

            for (int i = 0; i < TieDownTableSize; ++i)
            {
                if (i == 0 || i % 3 == 0)
                {
                    row = table.AddRow();
                    row.HeadingFormat    = true;
                    row.Format.Alignment = ParagraphAlignment.Center;
                    row.Format.Font.Bold = true;
                    row.Shading.Color    = Colors.White;
                    b = 0;
                    r++;
                }

                row.Cells[b].AddParagraph("□");
                row.Cells[b].Format.Font.Bold  = true;
                row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                //row.Cells[0].MergeDown = 1;
                b++;
                row.Cells[b].AddParagraph(TieDown[i].Type);
                row.Cells[b].Format.Alignment = ParagraphAlignment.Center;
                //row.Cells[1].MergeRight = 0;
                //row.Cells[1].MergeDown = 1;
                b++;
                row.Cells[b].AddParagraph(TieDown[i].Qty.ToString());
                row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                //row.Cells[2].MergeDown = 1;
                b++;
            }

            this.table.SetEdge(0, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
            this.table.SetEdge(3, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
            this.table.SetEdge(0, 0, 9, r + 1, Edge.Left, BorderStyle.Single, 1, Colors.Black);
            this.table.SetEdge(0, 0, 9, r + 1, Edge.Right, BorderStyle.Single, 1, Colors.Black);
            //this.table.SetEdge(0, 0, 9, r + 1, Edge.Box, BorderStyle.Single, 0.5, Colors.Black);

            if (Acc == null)
            {
                //adds an invisible row to space out the two tables
                this.table.SetEdge(0, 0, 9, r + 1, Edge.Bottom, BorderStyle.Single, 1, Colors.Black);
                row = table.AddRow();
                row.Borders.Visible = false;
            }
            //--------------------------------------------------------------------------//
            //------//-----------//----   Accessories Table  -----//----------//--------//
            //--------------------------------------------------------------------------//
            if (Acc != null)
            {
                // Create the item table
                this.table                     = section.AddTable();
                table.Rows.Alignment           = RowAlignment.Center;
                this.table.Style               = "Table";
                this.table.Borders.Color       = Colors.Black;
                this.table.Borders.Width       = 0.5;
                this.table.Borders.Left.Width  = 0.5;
                this.table.Borders.Right.Width = 0.5;
                this.table.Rows.LeftIndent     = 0;

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

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

                column5 = this.table.AddColumn("4.08cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                column5 = this.table.AddColumn("0.75cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                column5 = this.table.AddColumn("0.5cm");
                column.Format.Alignment = ParagraphAlignment.Center;

                column5 = this.table.AddColumn("4.08cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                column5 = this.table.AddColumn("0.75cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                column5 = this.table.AddColumn("0.5cm");
                column.Format.Alignment = ParagraphAlignment.Center;

                column5 = this.table.AddColumn("4.08cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                column5 = this.table.AddColumn("0.75cm");
                column.Format.Alignment = ParagraphAlignment.Right;

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

                // Create the header of the table
                row = table.AddRow();
                row.HeadingFormat    = true;
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Format.Font.Bold = true;
                row.Shading.Color    = Colors.LightGray;

                row.Cells[0].AddParagraph("Accessories");
                row.Cells[0].Format.Font.Bold  = true;
                row.Cells[0].Format.Alignment  = ParagraphAlignment.Center;
                row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
                row.Cells[0].MergeRight        = 8;

                // Get count of accessories
                int AccTableSize = Acc.Count;

                b = 0;
                r = 0;
                for (int i = 0; i < AccTableSize; ++i)
                {
                    if (i == 0 || i % 3 == 0)
                    {
                        row = table.AddRow();
                        row.HeadingFormat    = true;
                        row.Format.Alignment = ParagraphAlignment.Center;
                        row.Format.Font.Bold = true;
                        row.Shading.Color    = Colors.White;
                        b = 0;
                        r++;
                    }
                    row.Cells[b].AddParagraph("□");
                    row.Cells[b].Format.Font.Bold  = true;
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[0].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(Acc[i].Item);
                    row.Cells[b].Format.Alignment = ParagraphAlignment.Center;
                    //row.Cells[1].MergeRight = 0;
                    //row.Cells[1].MergeDown = 1;
                    b++;
                    row.Cells[b].AddParagraph(Acc[i].Qty.ToString());
                    row.Cells[b].Format.Alignment  = ParagraphAlignment.Center;
                    row.Cells[b].VerticalAlignment = VerticalAlignment.Center;
                    //row.Cells[2].MergeDown = 1;
                    b++;
                }

                this.table.SetEdge(0, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
                this.table.SetEdge(3, 1, 3, r, Edge.Right, BorderStyle.Single, 2, Colors.Black);
                this.table.SetEdge(0, 0, 9, r + 1, Edge.Box, BorderStyle.Single, 0.5, Colors.Black); // check this out later *****
                //adds an invisible row to space out the two tables
                row = table.AddRow();
                row.Borders.Visible = false;
            }

            // not sure what this does yet but pretty sure it makes an edge that surrounds the table kind of like thick borders
            //this.table.SetEdge(0, 0, 3, 1, Edge.Box, BorderStyle.Single, 1, Color.Empty);

            //--------------------------------------------------------------------------//
            //------//-----------//---- Stuff After Tables  ------//----------//--------//
            //--------------------------------------------------------------------------//

            //section.AddPageBreak();

            //document.AddSection();

            //MigraDoc.DocumentObjectModel.Paragraph paragraph1 = section.AddParagraph();
            //paragraph1.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly;
            //paragraph1.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(40);

            //--------------------------------------------------------------------------//
            //------//-----------//---  Unforgetables Table  -----//----------//--------//
            //--------------------------------------------------------------------------//

            // Create the item table
            //this.document.LastSection.AddSection();
            this.table1           = section.AddTable();
            table1.Rows.Alignment = RowAlignment.Center;
            //table1.Rows.Alignment = VerticalAlignment.Bottom;
            this.table1.Style               = "Table";
            this.table1.Borders.Color       = Colors.Black;
            this.table1.Borders.Width       = 0.5;
            this.table1.Borders.Left.Width  = 0.5;
            this.table1.Borders.Right.Width = 0.5;
            this.table1.Rows.LeftIndent     = 0;

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

            // Before you can add a row, you must define the columns
            Column column6 = this.table1.AddColumn("0.5cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column6 = this.table1.AddColumn("3cm");
            column6.Format.Alignment = ParagraphAlignment.Right;

            column6 = this.table1.AddColumn("0.5cm");
            column6.Format.Alignment = ParagraphAlignment.Right;

            column6 = this.table1.AddColumn("4cm");
            column6.Format.Alignment = ParagraphAlignment.Right;

            column6 = this.table1.AddColumn("0.5cm");
            column6.Format.Alignment = ParagraphAlignment.Right;

            column6 = this.table1.AddColumn("3cm");
            column6.Format.Alignment = ParagraphAlignment.Right;

            column6 = this.table1.AddColumn("0.5cm");
            column6.Format.Alignment = ParagraphAlignment.Right;

            column6 = this.table1.AddColumn("4cm");
            column6.Format.Alignment = ParagraphAlignment.Right;

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

            // Create the header of the table

            Row row6 = table1.AddRow();
            row6.HeadingFormat    = true;
            row6.Format.Alignment = ParagraphAlignment.Center;
            row6.Format.Font.Bold = true;
            row6.Shading.Color    = Colors.White;

            row6.Cells[0].AddParagraph("□");
            row6.Cells[0].Format.Font.Bold = true;
            row6.Cells[0].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[1].AddParagraph("Blue Tarp");
            row6.Cells[1].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[2].AddParagraph("□");
            row6.Cells[2].Format.Font.Bold = true;
            row6.Cells[2].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[3].AddParagraph("Clips");
            row6.Cells[3].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[4].AddParagraph("□");
            row6.Cells[4].Format.Font.Bold = true;
            row6.Cells[4].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[5].AddParagraph("Patch Kit");
            row6.Cells[5].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[6].AddParagraph("□");
            row6.Cells[6].Format.Font.Bold = true;
            row6.Cells[6].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[7].AddParagraph("Jack Hammer/Fuel");
            row6.Cells[7].Format.Alignment = ParagraphAlignment.Center;

            row6 = table1.AddRow();
            row6.HeadingFormat    = true;
            row6.Format.Alignment = ParagraphAlignment.Center;
            row6.Format.Font.Bold = true;
            row6.Shading.Color    = Colors.White;

            row6.Cells[0].AddParagraph("□");
            row6.Cells[0].Format.Font.Bold = true;
            row6.Cells[0].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[1].AddParagraph("Spray 9/Rags");
            row6.Cells[1].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[2].AddParagraph("□");
            row6.Cells[2].Format.Font.Bold = true;
            row6.Cells[2].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[3].AddParagraph("Sledge Hammer");
            row6.Cells[3].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[4].AddParagraph("□");
            row6.Cells[4].Format.Font.Bold = true;
            row6.Cells[4].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[5].AddParagraph("Step Ladder");
            row6.Cells[5].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[6].AddParagraph("□");
            row6.Cells[6].Format.Font.Bold = true;
            row6.Cells[6].Format.Alignment = ParagraphAlignment.Center;

            row6.Cells[7].AddParagraph("Impact/Screws");
            row6.Cells[7].Format.Alignment = ParagraphAlignment.Center;
            this.table1.SetEdge(0, 0, 8, 2, Edge.Box, BorderStyle.Single, 1, Colors.Black);

            // Add the notes paragraph
            paragraph = section.AddParagraph();
            //this.document.LastSection.AddParagraph();
            paragraph.Format.SpaceBefore = "0.5cm";
            paragraph.Format.SpaceAfter  = "0.5cm";
            //paragraph.Format.Alignment = ParagraphAlignment.Bottom;
            paragraph.Format.Borders.Width    = 0.75;
            paragraph.Format.Borders.Distance = 3;
            paragraph.Format.Borders.Color    = Colors.Black;
            paragraph.Format.Shading.Color    = Colors.LightGray;
            paragraph.AddText("notes \n \n \n \n");
        }
Example #35
0
        /// <summary>
        /// This method creates the document layout for this pdf file
        /// </summary>
        /// <param name="document">A species information document object holding all the information that should be included in the pdf file</param>
        /// <returns>A formated pdf document</returns>
        private Document createPdfDocument(Data.ArtDatabankenService.SpeciesInformationDocument document)
        {
            Document pdfFile = new Document();

            pdfFile.DefaultPageSetup.TopMargin      = Unit.FromCentimeter(1.2);
            pdfFile.DefaultPageSetup.RightMargin    = Unit.FromCentimeter(1.2);
            pdfFile.DefaultPageSetup.BottomMargin   = Unit.FromCentimeter(2.6);
            pdfFile.DefaultPageSetup.FooterDistance = Unit.FromCentimeter(0.8);
            pdfFile.DefaultPageSetup.LeftMargin     = Unit.FromCentimeter(1.2);
            pdfFile.DefaultPageSetup.DifferentFirstPageHeaderFooter = true;
            pdfFile.DefaultPageSetup.OddAndEvenPagesHeaderFooter    = true;

            pdfFile.Info.Title   = "Arfaktablad om " + document.Taxon.Label + " [DyntaxaTaxonId: " + document.Taxon.Id.ToString() + "]";
            pdfFile.Info.Subject = "Arfaktablad med beskrivning, utbredningsuppgifter, ekologi, hot och naturvårdsåtgärder, litteratur";
            pdfFile.Info.Author  = document.AuthorAndYear;

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

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

            //Colors
            MigraDoc.DocumentObjectModel.Color colorOfRedlistPeriodBox   = Color.FromCmyk(35, 25, 25, 5);  // light grey
            MigraDoc.DocumentObjectModel.Color colorOfRedlistCategoryBox = Color.FromCmyk(5, 95, 100, 0);  // Red
            MigraDoc.DocumentObjectModel.Color colorOfFrameLine          = Color.FromCmyk(50, 10, 75, 0);  // light green
            MigraDoc.DocumentObjectModel.Color colorOfHeaderTitleText    = Color.FromCmyk(80, 60, 70, 80); // dark grey
            MigraDoc.DocumentObjectModel.Color colorOfHeaderText         = Color.FromCmyk(35, 25, 25, 5);  // light grey


            Section section = pdfFile.AddSection();

            // Create main frame first
            TextFrame firstMainFrame = section.Headers.FirstPage.AddTextFrame();

            firstMainFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            firstMainFrame.RelativeVertical   = RelativeVertical.Margin;
            firstMainFrame.Height             = "26cm";
            firstMainFrame.Width            = "18,6cm";
            firstMainFrame.LineFormat.Width = 1.5;
            firstMainFrame.LineFormat.Color = colorOfFrameLine;
            // End header first

            // Create header odd
            TextFrame mainFrame = section.Headers.Primary.AddTextFrame();

            mainFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            mainFrame.RelativeVertical   = RelativeVertical.Margin;
            mainFrame.Height             = "26cm";
            mainFrame.Width            = "18,6cm";
            mainFrame.LineFormat.Width = 1.5;
            mainFrame.LineFormat.Color = colorOfFrameLine;
            // End header odd

            // Create header even
            TextFrame evenMainFrame = section.Headers.EvenPage.AddTextFrame();

            evenMainFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            evenMainFrame.RelativeVertical   = RelativeVertical.Margin;
            evenMainFrame.Height             = "26cm";
            evenMainFrame.Width            = "18,6cm";
            evenMainFrame.LineFormat.Width = 1.5;
            evenMainFrame.LineFormat.Color = colorOfFrameLine;
            // End header even

            //Create Line text on first page
            Paragraph borderLineTextFrameFirstPageText;
            TextFrame borderLineTextFrameFirstPage;

            borderLineTextFrameFirstPage                       = section.AddTextFrame();
            borderLineTextFrameFirstPage.MarginTop             = -7;
            borderLineTextFrameFirstPage.MarginLeft            = "133mm";
            borderLineTextFrameFirstPageText                   = borderLineTextFrameFirstPage.AddParagraph("ARTFAKTABLAD");
            borderLineTextFrameFirstPageText.Format.Font.Color = colorOfFrameLine;
            borderLineTextFrameFirstPageText.Format.Font.Size  = Unit.FromPoint(12);
            borderLineTextFrameFirstPage.Height                = 0;

            // Header 1
            Paragraph commonName;

            if (document.CommonName.IsNotEmpty())
            {
                //Swedish name with first letter upper case in title
                commonName = section.AddParagraph(char.ToUpper(document.CommonName[0]) + document.CommonName.Substring(1));
                commonName.Format.Font.Color = colorOfHeaderTitleText;
            }
            else
            {
                commonName = section.AddParagraph("(Svenskt namn saknas)");
                commonName.Format.Font.Color = colorOfHeaderText;
            }
            commonName.Format.Font.Size   = Unit.FromPoint(20);
            commonName.Format.Alignment   = ParagraphAlignment.Left;
            commonName.Format.LeftIndent  = "0.5cm";
            commonName.Format.RightIndent = "0.5cm";
            commonName.Format.SpaceAfter  = "0.2cm";
            commonName.Format.SpaceBefore = "1cm";


            //Header2
            Paragraph scientificName = section.AddParagraph(document.ScientificName);

            scientificName.Format.Font.Size   = Unit.FromPoint(12);
            scientificName.Format.Font.Color  = colorOfHeaderTitleText;
            scientificName.Format.Font.Italic = true;
            scientificName.Format.Alignment   = ParagraphAlignment.Left;
            scientificName.Format.LeftIndent  = "0.5cm";
            scientificName.Format.RightIndent = "0.5cm";
            scientificName.Format.SpaceAfter  = "1.2cm";
            scientificName.Format.SpaceBefore = "0.2cm";
            if (document.Taxon.Author.IsNotEmpty())
            {
                scientificName.AddFormattedText(" " + document.Taxon.Author, TextFormat.NotItalic);
            }

            //Redlist information
            Table redlistSpeciesInformation = section.AddTable();
            //redlistSpeciesInformation.Format.LeftIndent = "0.5cm";
            //redlistSpeciesInformation.Borders.Width = 1.5;
            //redlistSpeciesInformation.Borders.Color = colorOfFrameLine;

            Column columnLeft = redlistSpeciesInformation.AddColumn(Unit.FromCentimeter(9.2));

            columnLeft.Format.Alignment = ParagraphAlignment.Left;
            Column columnRight = redlistSpeciesInformation.AddColumn(Unit.FromCentimeter(9.2));

            columnRight.Format.Alignment = ParagraphAlignment.Left;

            Row  row           = redlistSpeciesInformation.AddRow();
            Cell cellTaxonInfo = row.Cells[0];
            Cell cellCriteria  = row.Cells[1];

            List <ParagraphItem> paragraphItems = null;

            //Taxonomic information
            cellTaxonInfo = row.Cells[0];
            Paragraph taxonomicInformation = cellTaxonInfo.AddParagraph();

            taxonomicInformation.Format.Font.Color  = colorOfHeaderText;
            taxonomicInformation.Format.Font.Size   = Unit.FromPoint(8);
            taxonomicInformation.Format.LeftIndent  = "0.5cm";
            taxonomicInformation.Format.RightIndent = "0.5cm";
            taxonomicInformation.Format.SpaceAfter  = "0.2cm";
            cellTaxonInfo.VerticalAlignment         = VerticalAlignment.Bottom;

            paragraphItems = GetParagraphItems(document.AutomaticTaxonomicParagraph, document.ItalicStringsInText);
            foreach (ParagraphItem item in paragraphItems)
            {
                if (item.Italic)
                {
                    taxonomicInformation.AddFormattedText(item.Text, TextFormat.Italic);
                    taxonomicInformation.AddText(" ");
                }
                else
                {
                    taxonomicInformation.AddText(item.Text);
                    taxonomicInformation.AddText(" ");
                }
            }

            //Redlist Criteria
            if (document.RedlistCriteria.IsNotEmpty())
            {
                Paragraph redlistCriteriaText = cellCriteria.AddParagraph(document.RedlistCriteria);
                redlistCriteriaText.Format.Font.Color = colorOfHeaderText;
                redlistCriteriaText.Format.Font.Size  = Unit.FromPoint(8);
                redlistCriteriaText.Format.LeftIndent = "4cm";
                redlistCriteriaText.Format.SpaceAfter = "0.2cm";
                redlistCriteriaText.Format.Alignment  = ParagraphAlignment.Left;
                cellCriteria.VerticalAlignment        = VerticalAlignment.Bottom;
            }

            // Create Image
            if (_taxonImage.IsNotNull())
            {
                Paragraph taxonParagraph = section.AddParagraph();
                taxonParagraph.Format.Alignment   = ParagraphAlignment.Left;
                taxonParagraph.Format.LeftIndent  = "0.5cm";
                taxonParagraph.Format.RightIndent = "0.5cm";
                taxonParagraph.Format.SpaceAfter  = "0.2cm";
                _taxonImage.Save("taxon.png");
                Image taxonImage = taxonParagraph.AddImage("taxon.png");
                taxonImage.Height           = Unit.FromCentimeter(9);
                taxonImage.LockAspectRatio  = true;
                taxonImage.WrapFormat.Style = WrapStyle.TopBottom;
            }

            // Create Map
            if (_mapImage.IsNotNull())
            {
                Paragraph mapParagraph = section.AddParagraph();
                mapParagraph.Format.Alignment   = ParagraphAlignment.Right;
                mapParagraph.Format.LeftIndent  = "0.5cm";
                mapParagraph.Format.RightIndent = "0.5cm";
                mapParagraph.Format.SpaceAfter  = "0.2cm";
                _mapImage.Save("map.png");
                Image mapImage = mapParagraph.AddImage("map.png");
                mapImage.Height           = Unit.FromCentimeter(9);
                mapImage.LockAspectRatio  = true;
                mapImage.WrapFormat.Style = WrapStyle.TopBottom;
            }

            //Main document paragraphs
            Paragraph paragraph;

            if (_document.DescriptionParagraph.IsNotEmpty())
            {
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "0.5cm";
                paragraph.Format.LeftIndent  = "0.5cm";
                paragraph.Format.RightIndent = "0.5cm";
                paragraph.Format.Alignment   = ParagraphAlignment.Left;
                paragraph.AddFormattedText("Beskrivning".ToUpper(), TextFormat.Bold);
                paragraph.AddLineBreak();
                paragraph.Format.Alignment = ParagraphAlignment.Justify;
                paragraphItems             = GetParagraphItems(document.DescriptionParagraph, document.ItalicStringsInText);
                foreach (ParagraphItem item in paragraphItems)
                {
                    if (item.Italic)
                    {
                        paragraph.AddFormattedText(item.Text, TextFormat.Italic);
                    }
                    else
                    {
                        paragraph.AddText(item.Text);
                    }
                }
            }

            if (_document.DistributionParagraph.IsNotEmpty())
            {
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "0.5cm";
                paragraph.Format.LeftIndent  = "0.5cm";
                paragraph.Format.RightIndent = "0.5cm";
                paragraph.Format.Alignment   = ParagraphAlignment.Left;
                paragraph.AddFormattedText("Utbredning och status".ToUpper(), TextFormat.Bold);
                paragraph.AddLineBreak();
                paragraphItems = GetParagraphItems(document.DistributionParagraph, document.ItalicStringsInText);
                foreach (ParagraphItem item in paragraphItems)
                {
                    if (item.Italic)
                    {
                        paragraph.AddFormattedText(item.Text, TextFormat.Italic);
                    }
                    else
                    {
                        paragraph.AddText(item.Text);
                    }
                }
            }

            if (_document.EcologyParagraph.IsNotEmpty())
            {
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "0.5cm";
                paragraph.Format.LeftIndent  = "0.5cm";
                paragraph.Format.RightIndent = "0.5cm";
                paragraph.Format.Alignment   = ParagraphAlignment.Left;
                paragraph.AddFormattedText("Ekologi".ToUpper(), TextFormat.Bold);
                paragraph.AddLineBreak();
                paragraph.Format.Alignment = ParagraphAlignment.Justify;
                paragraphItems             = GetParagraphItems(document.EcologyParagraph, document.ItalicStringsInText);
                foreach (ParagraphItem item in paragraphItems)
                {
                    if (item.Italic)
                    {
                        paragraph.AddFormattedText(item.Text, TextFormat.Italic);
                    }
                    else
                    {
                        paragraph.AddText(item.Text);
                    }
                }
            }

            if (_document.ThreatsParagraph.IsNotEmpty())
            {
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "0.5cm";
                paragraph.Format.LeftIndent  = "0.5cm";
                paragraph.Format.RightIndent = "0.5cm";
                paragraph.Format.Alignment   = ParagraphAlignment.Left;
                paragraph.AddFormattedText("Hot".ToUpper(), TextFormat.Bold);
                paragraph.AddLineBreak();
                paragraph.Format.Alignment = ParagraphAlignment.Justify;
                paragraphItems             = GetParagraphItems(document.ThreatsParagraph, document.ItalicStringsInText);
                foreach (ParagraphItem item in paragraphItems)
                {
                    if (item.Italic)
                    {
                        paragraph.AddFormattedText(item.Text, TextFormat.Italic);
                    }
                    else
                    {
                        paragraph.AddText(item.Text);
                    }
                }
            }

            if (_document.MeasuresParagraph.IsNotEmpty())
            {
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "0.5cm";
                paragraph.Format.LeftIndent  = "0.5cm";
                paragraph.Format.RightIndent = "0.5cm";
                paragraph.Format.Alignment   = ParagraphAlignment.Left;
                paragraph.AddFormattedText("Åtgärder".ToUpper(), TextFormat.Bold);
                paragraph.AddLineBreak();
                paragraph.Format.Alignment = ParagraphAlignment.Justify;
                paragraphItems             = GetParagraphItems(document.MeasuresParagraph, document.ItalicStringsInText);
                foreach (ParagraphItem item in paragraphItems)
                {
                    if (item.Italic)
                    {
                        paragraph.AddFormattedText(item.Text, TextFormat.Italic);
                    }
                    else
                    {
                        paragraph.AddText(item.Text);
                    }
                }
            }

            if (_document.ExtraParagraph.IsNotEmpty())
            {
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "0.5cm";
                paragraph.Format.LeftIndent  = "0.5cm";
                paragraph.Format.RightIndent = "0.5cm";
                paragraph.Format.Alignment   = ParagraphAlignment.Left;
                paragraph.AddFormattedText("Övrigt".ToUpper(), TextFormat.Bold);
                paragraph.AddLineBreak();
                paragraph.Format.Alignment = ParagraphAlignment.Justify;
                paragraphItems             = GetParagraphItems(document.ExtraParagraph, document.ItalicStringsInText);
                foreach (ParagraphItem item in paragraphItems)
                {
                    if (item.Italic)
                    {
                        paragraph.AddFormattedText(item.Text, TextFormat.Italic);
                    }
                    else
                    {
                        paragraph.AddText(item.Text);
                    }
                }
            }

            //Reference list
            if (_document.ReferenceParagraph.IsNotEmpty())
            {
                paragraph = section.AddParagraph();
                paragraph.Format.SpaceBefore = "0.5cm";
                paragraph.Format.LeftIndent  = "0.5cm";
                paragraph.Format.RightIndent = "0.5cm";
                paragraph.Format.Alignment   = ParagraphAlignment.Left;
                paragraph.AddFormattedText("Litteratur".ToUpper(), TextFormat.Bold);
                paragraph.AddLineBreak();


                string[] references = _document.ReferenceParagraph.Split('\n');

                foreach (string reference in references)
                {
                    Paragraph referenceParagraph = section.AddParagraph();
                    referenceParagraph.Format.LeftIndent      = "1cm";
                    referenceParagraph.Format.FirstLineIndent = "-1cm";
                    referenceParagraph.Format.Alignment       = ParagraphAlignment.Justify;
                    referenceParagraph.Format.Font.Size       = Unit.FromPoint(10);
                    paragraphItems = GetParagraphItems(reference, document.ItalicStringsInReferences);
                    foreach (ParagraphItem item in paragraphItems)
                    {
                        if (item.Italic)
                        {
                            referenceParagraph.AddFormattedText(item.Text, TextFormat.Italic);
                        }
                        else
                        {
                            referenceParagraph.AddText(item.Text);
                        }
                    }
                }
            }

            paragraph = section.AddParagraph(LINE);
            paragraph.Format.SpaceBefore = "4mm";

            //Author information
            Table authorInformationBox = section.AddTable();

            //authorInformationBox.Format.SpaceBefore = "5mm";
            authorInformationBox.Borders.Width = 0;
            //authorInformationBox.Borders.Top.Width = Unit.FromPoint(0.25);
            Column columnAuthor = authorInformationBox.AddColumn(Unit.FromCentimeter(16));

            columnAuthor.Format.Alignment = ParagraphAlignment.Justify;
            row           = authorInformationBox.AddRow();
            cellTaxonInfo = row.Cells[0];
            Paragraph authorParagraph = cellTaxonInfo.AddParagraph();

            authorParagraph.AddText(getUpdateInformation());

            // Create footer first page
            IOResources.IOResource.slu_logotyp_web1.Save("slu.png");
            Image firstFooterImage = section.Footers.FirstPage.AddImage("slu.png");

            firstFooterImage.Height             = Unit.FromCentimeter(1.9);
            firstFooterImage.LockAspectRatio    = true;
            firstFooterImage.RelativeVertical   = RelativeVertical.Line;
            firstFooterImage.RelativeHorizontal = RelativeHorizontal.Margin;
            firstFooterImage.WrapFormat.Style   = WrapStyle.None;

            Paragraph firstFooterParagraph = section.Footers.FirstPage.AddParagraph();

            firstFooterParagraph.AddLineBreak();
            firstFooterParagraph.AddText("ArtDatabanken");
            firstFooterParagraph.Format.Font.Size = 16;
            firstFooterParagraph.Format.Font.Bold = true;
            firstFooterParagraph.Format.Font.Name = "Arial";
            firstFooterParagraph.Format.Alignment = ParagraphAlignment.Right;
            // end footer first page

            // Create footer
            Paragraph footerParagraph = section.Footers.Primary.AddParagraph();

            footerParagraph.AddText("www.slu.se/artdatabanken");
            footerParagraph.Format.Font.Size = 13;
            footerParagraph.Format.Font.Bold = true;
            footerParagraph.Format.Alignment = ParagraphAlignment.Center;

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

            footerPageNo.AddPageField();
            footerPageNo.Format.Font.Color = colorOfFrameLine;
            footerPageNo.Format.Font.Size  = 13;
            footerPageNo.Format.Alignment  = ParagraphAlignment.Right;
            // end footer

            // Create even footer
            Paragraph EvenFooterParagraph = section.Footers.EvenPage.AddParagraph();

            EvenFooterParagraph.AddText("www.slu.se/artdatabanken");
            EvenFooterParagraph.Format.Font.Size = 13;
            EvenFooterParagraph.Format.Font.Bold = true;
            EvenFooterParagraph.Format.Alignment = ParagraphAlignment.Center;

            Paragraph evenfooterPageNo = section.Footers.EvenPage.AddParagraph();

            evenfooterPageNo.AddPageField();
            evenfooterPageNo.Format.Font.Color = colorOfFrameLine;
            evenfooterPageNo.Format.Font.Size  = 13;
            evenfooterPageNo.Format.Alignment  = ParagraphAlignment.Left;
            // end even footer

            return(pdfFile);
        }
Example #36
0
        public Document CriaRelatorio()
        {
            Document relatorio = new Document();
            Section  section   = relatorio.AddSection();

            MigraDoc.DocumentObjectModel.Shapes.Image img = section.Headers.Primary.AddImage("gustavo2.png");
            img.Height             = "15cm";
            img.LockAspectRatio    = true;
            img.RelativeVertical   = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Page;
            img.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Page;
            img.Top              = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center;
            img.Left             = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center;
            img.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through;

            section.PageSetup.TopMargin    = 25;
            section.PageSetup.LeftMargin   = 25;
            section.PageSetup.RightMargin  = 25;
            section.PageSetup.BottomMargin = 25;
            section.PageSetup.PageFormat   = PageFormat.A4;

            #region HeaderRelatorio
            Paragraph primeira_linha = section.AddParagraph("RELATÓRIO DE ENTRADA DÍZIMOS E OFERTAS - IGREJA BATISTA RENOVO");
            primeira_linha.Format.Alignment = ParagraphAlignment.Center;

            MigraDoc.DocumentObjectModel.Tables.Table tabela_header = new MigraDoc.DocumentObjectModel.Tables.Table();
            MigraDoc.DocumentObjectModel.Tables.Row   linha_header;
            tabela_header.Borders.Width = 0.5;

            MigraDoc.DocumentObjectModel.Tables.Column coluna_header = tabela_header.AddColumn("18cm");
            coluna_header.Format.Font.Name = "Calibri";
            coluna_header.Shading.Color    = Colors.WhiteSmoke;
            linha_header = tabela_header.AddRow();
            linha_header.Format.Alignment = ParagraphAlignment.Center;
            linha_header.Format.Font.Bold = true;
            linha_header.Cells[0].AddParagraph(System.DateTime.Now.ToString("dd/MM/yyyy") + " - " + Util.Funcoes.RetornaDia() + "(" + Util.Funcoes.RetornaPeriodo() + ")");
            tabela_header.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_header);
            #endregion
            Paragraph quebra_linha_headerReport = section.AddParagraph("");

            #region HeaderTabela
            MigraDoc.DocumentObjectModel.Tables.Table tabela_dizimistas;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_dizimistas;

            tabela_dizimistas = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_dizimistas.Borders.Width = 0.5;

            MigraDoc.DocumentObjectModel.Tables.Column coluna1 = tabela_dizimistas.AddColumn("14cm");
            coluna1.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna2 = tabela_dizimistas.AddColumn("4cm");
            coluna2.Format.Font.Name = "Calibri";

            linha_dizimistas = tabela_dizimistas.AddRow();
            linha_dizimistas.Shading.Color     = Colors.Black;
            linha_dizimistas.Format.Font.Color = Colors.White;
            linha_dizimistas.Format.Font.Bold  = true;
            linha_dizimistas.Format.Alignment  = ParagraphAlignment.Center;
            linha_dizimistas.Cells[0].AddParagraph("DIZIMISTA");
            linha_dizimistas.Cells[1].AddParagraph("VALOR");
            #endregion

            #region ItensTabela
            decimal total_dizimos = 0;

            var listaDetalhes = _unitOfWork.CabecalhosEntradas.ListaDetalhes(Convert.ToInt32(Util.DataCript.Decriptar(HttpContext.Session.GetString("_hash"))));

            EntradaResponse total = new EntradaResponse
            {
                VlTotalDizimo  = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 1).Sum(s => s.Valor),
                VlTotalOferta  = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 2).Sum(s => s.Valor),
                VlTotalMissoes = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 3).Sum(s => s.Valor),
                VlTotalReforma = listaDetalhes[0].ItensCategoria.Where(w => w.IdCategoria == 4).Sum(s => s.Valor),

                VlTotalNotas   = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 1).Sum(s => s.Valor),
                VlTotalMoedas  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 2).Sum(s => s.Valor),
                VlTotalCheque  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 3).Sum(s => s.Valor),
                VlTotalDebito  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 4).Sum(s => s.Valor),
                VlTotalCredito = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 5).Sum(s => s.Valor),
                VlTotalTransf  = listaDetalhes[0].ItensTipo.Where(w => w.IdTipo == 6).Sum(s => s.Valor),
            };
            total.VlTotalCategoria = total.VlTotalDizimo + total.VlTotalOferta + total.VlTotalMissoes + total.VlTotalReforma;
            total.VlTotalTipo      = total.VlTotalNotas + total.VlTotalMoedas + total.VlTotalCheque + total.VlTotalDebito + total.VlTotalCredito + total.VlTotalTransf;

            var lista = _unitOfWork.CabecalhosEntradas.ListarResponse(Convert.ToInt32(Util.DataCript.Decriptar(HttpContext.Session.GetString("_hash"))));

            RetornoResponse retorno = new RetornoResponse
            {
                retornoTotais = total,
                retornoLista  = lista
            };

            foreach (var linha in retorno.retornoLista.Where(w => w.Dizimo > 0))
            {
                linha_dizimistas = tabela_dizimistas.AddRow();
                linha_dizimistas.Format.Font.Size = 9;
                //linha_dizimistas.Cells[0].AddParagraph(Util.DataCript.Decriptar(linha.Pessoa.Nome).ToUpper());
                linha_dizimistas.Cells[0].AddParagraph(linha.Pessoa.Nome.ToUpper());
                linha_dizimistas.Cells[1].AddParagraph(linha.Dizimo.ToString());
                total_dizimos += linha.Dizimo;
            }

            tabela_dizimistas.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_dizimistas);
            #endregion

            Paragraph quebra_linha_totalizadores  = section.AddParagraph("");
            Paragraph quebra_linha_totalizadores2 = section.AddParagraph("");
            #region Totalizadores
            decimal total_ofertas  = 0;
            decimal total_missoes  = 0;
            decimal total_infantil = 0;
            decimal total_reforma  = 0;

            total_ofertas  = retorno.retornoTotais.VlTotalOferta;
            total_missoes  = retorno.retornoTotais.VlTotalMissoes;
            total_infantil = 0;
            total_reforma  = retorno.retornoTotais.VlTotalReforma;

            MigraDoc.DocumentObjectModel.Tables.Table tabela_total;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_total;

            tabela_total = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_total.Borders.Width = 0.5;
            MigraDoc.DocumentObjectModel.Tables.Column coluna_total1 = tabela_total.AddColumn("14cm");
            coluna_total1.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna_total2 = tabela_total.AddColumn("4cm");
            coluna_total2.Format.Font.Name = "Calibri";

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL DIZIMOS");
            linha_total.Cells[1].AddParagraph(total_dizimos.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL OFERTAS");
            linha_total.Cells[1].AddParagraph(total_ofertas.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL MISSÕES");
            linha_total.Cells[1].AddParagraph(total_missoes.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL REFORMA");
            linha_total.Cells[1].AddParagraph(total_reforma.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.Gray;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL INFANTIL");
            linha_total.Cells[1].AddParagraph(total_infantil.ToString());

            linha_total = tabela_total.AddRow();
            linha_total.Shading.Color    = Colors.DarkGray;
            linha_total.Format.Font.Bold = true;
            linha_total.Format.Alignment = ParagraphAlignment.Center;
            linha_total.Cells[0].AddParagraph("TOTAL");
            var totalCateg = total_dizimos + total_ofertas + total_missoes + total_reforma + total_infantil;
            linha_total.Cells[1].AddParagraph(totalCateg.ToString());

            tabela_total.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_total);
            #endregion

            Paragraph quebra_linha_tipo  = section.AddParagraph("");
            Paragraph quebra_linha_tipo2 = section.AddParagraph("");
            #region RelatorioTipo
            MigraDoc.DocumentObjectModel.Tables.Table tabela_tipo;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_tipo;

            tabela_tipo = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_tipo.Borders.Width = 0.5;
            MigraDoc.DocumentObjectModel.Tables.Column coluna_nota    = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_moeda   = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_cheque  = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_debito  = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_credito = tabela_tipo.AddColumn("3cm");
            MigraDoc.DocumentObjectModel.Tables.Column coluna_transf  = tabela_tipo.AddColumn("3cm");

            coluna_nota.Format.Font.Name    = "Calibri";
            coluna_moeda.Format.Font.Name   = "Calibri";
            coluna_cheque.Format.Font.Name  = "Calibri";
            coluna_debito.Format.Font.Name  = "Calibri";
            coluna_credito.Format.Font.Name = "Calibri";
            coluna_transf.Format.Font.Name  = "Calibri";

            linha_tipo = tabela_tipo.AddRow();
            linha_tipo.Shading.Color     = Colors.Black;
            linha_tipo.Format.Font.Color = Colors.White;
            linha_tipo.Format.Font.Bold  = true;
            linha_tipo.Cells[0].AddParagraph("Notas");
            linha_tipo.Cells[1].AddParagraph("Moedas");
            linha_tipo.Cells[2].AddParagraph("Cheques");
            linha_tipo.Cells[3].AddParagraph("C. Déb.");
            linha_tipo.Cells[4].AddParagraph("C. Créd.");
            linha_tipo.Cells[5].AddParagraph("Transf.");

            decimal total_notas   = 0;
            decimal total_moedas  = 0;
            decimal total_cheques = 0;
            decimal total_debito  = 0;
            decimal total_credito = 0;
            decimal total_transf  = 0;

            total_notas   = retorno.retornoTotais.VlTotalNotas;
            total_moedas  = retorno.retornoTotais.VlTotalMoedas;
            total_cheques = retorno.retornoTotais.VlTotalCheque;
            total_debito  = retorno.retornoTotais.VlTotalDebito;
            total_credito = retorno.retornoTotais.VlTotalCredito;
            total_transf  = retorno.retornoTotais.VlTotalTransf;

            linha_tipo = tabela_tipo.AddRow();
            linha_tipo.Cells[0].AddParagraph(total_notas.ToString());
            linha_tipo.Cells[1].AddParagraph(total_moedas.ToString());
            linha_tipo.Cells[2].AddParagraph(total_cheques.ToString());
            linha_tipo.Cells[3].AddParagraph(total_debito.ToString());
            linha_tipo.Cells[4].AddParagraph(total_credito.ToString());
            linha_tipo.Cells[5].AddParagraph(total_transf.ToString());
            Paragraph quebra_linha5 = section.AddParagraph("");

            tabela_tipo.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_tipo);

            #endregion

            Paragraph quebra_linha_conferidoPor  = section.AddParagraph("");
            Paragraph quebra_linha_conferidoPor2 = section.AddParagraph("");
            Paragraph quebra_linha_conferidoPor3 = section.AddParagraph("");
            #region ConferidoPor
            MigraDoc.DocumentObjectModel.Tables.Table tabela_conferidoPor;
            MigraDoc.DocumentObjectModel.Tables.Row   linha_conferidoPor;

            tabela_conferidoPor = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabela_conferidoPor.Borders.Width = 0;
            MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor = tabela_conferidoPor.AddColumn("3cm");
            coluna_conferidoPor.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor1 = tabela_conferidoPor.AddColumn("7cm");
            coluna_conferidoPor1.Format.Font.Name = "Calibri";

            MigraDoc.DocumentObjectModel.Tables.Column coluna_conferidoPor2 = tabela_conferidoPor.AddColumn("7cm");
            coluna_conferidoPor2.Format.Font.Name = "Calibri";

            linha_conferidoPor = tabela_conferidoPor.AddRow();
            linha_conferidoPor.Format.Alignment = ParagraphAlignment.Center;
            linha_conferidoPor.Cells[0].AddParagraph("CONFERIDO POR:");
            linha_conferidoPor.Cells[1].AddParagraph(Util.DataCript.Decriptar(HttpContext.Session.GetString("_header1")));
            linha_conferidoPor.Cells[1].Format.Borders.Top.Width = 0.5;
            linha_conferidoPor.Cells[2].AddParagraph(Util.DataCript.Decriptar(HttpContext.Session.GetString("_header2")));
            linha_conferidoPor.Cells[2].Format.Borders.Top.Width = 0.5;

            tabela_conferidoPor.SetEdge(0, 0, 0, 1, MigraDoc.DocumentObjectModel.Tables.Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, Colors.Black);
            relatorio.LastSection.Add(tabela_conferidoPor);
            #endregion

            return(relatorio);
        }
Example #37
0
        static public void SaveBigAudit(string pathDB, string pathSaveFile, IEnumerable <ListDisplay.ListItem> data,
                                        DateTime?dateFrom, DateTime?dateTo, string sumPaid)
        {
            Document document = new Document();

            document.Info.Title = "Duży audyt";

            Section section = document.AddSection();

            section.PageSetup.LeftMargin = "1cm";

            Paragraph paragraph;
            Table     table;
            Column    column;
            Row       row;

            paragraph = section.AddParagraph("Wyciąg z audytu wygenerowany " + DateTime.Now);
            paragraph.Format.Font.Size = 6;

            if (dateFrom == null)
            {
                paragraph = section.AddParagraph("Data od: " + DateTime.Parse(data.First().ItemDate).ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }
            else
            {
                paragraph = section.AddParagraph("Data od: " + dateFrom.Value.ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }

            if (dateTo == null)
            {
                paragraph = section.AddParagraph("Data do: " + DateTime.Parse(data.Last().ItemDate).ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }
            else
            {
                paragraph = section.AddParagraph("Data do: " + dateTo.Value.ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }
            paragraph = section.AddParagraph("\n\n");

            //Table section
            table                     = section.AddTable();
            table.Style               = "Table";
            table.Borders.Color       = Color.Parse("Black");
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Format.Alignment    = ParagraphAlignment.Left;
            table.Rows.LeftIndent     = 0;

            column = table.AddColumn("2,5cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("2,5cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("2,5cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("2cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;

            row = table.AddRow();
            row.Format.Font.Bold = true;
            row.Format.Font.Size = 6;
            row.Cells[0].AddParagraph("Kod pracownika");
            row.Cells[1].AddParagraph("ID");
            row.Cells[2].AddParagraph("Televend ID");
            row.Cells[3].AddParagraph("Data");
            row.Cells[4].AddParagraph("Cena");
            row.Cells[5].AddParagraph("Produkt");
            row.Cells[6].AddParagraph("Maszyna");

            for (int i = 0; i < data.Count(); i++)
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph(data.ToList()[i].ItemWorkerID);
                row.Cells[2].AddParagraph(data.ToList()[i].ItemID);
                row.Cells[1].AddParagraph(data.ToList()[i].ItemStickerID);
                row.Cells[3].AddParagraph(data.ToList()[i].ItemDate);
                row.Cells[4].AddParagraph(data.ToList()[i].ItemPurchase);
                row.Cells[5].AddParagraph(data.ToList()[i].ItemProduct);
                row.Cells[6].AddParagraph(data.ToList()[i].ItemMachine);
            }

            row = table.AddRow();
            row.Format.Font.Bold = true;
            row.Format.Font.Size = 7;
            row.Cells[0].AddParagraph("Suma");
            row.Cells[4].AddParagraph(sumPaid);

            //Final PDF generation
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);

            renderer.Document = document;
            renderer.RenderDocument();

            if (!pathSaveFile.EndsWith(".pdf"))
            {
                pathSaveFile += ".pdf";
            }

            renderer.PdfDocument.Save(pathSaveFile);
            Process.Start(pathSaveFile);
        }
Example #38
0
        private void AddTableTitle(Section section, string title)
        {
            var p = section.AddParagraph(title, StyleNames.Heading2);

            p.Format.KeepWithNext = true;
        }
Example #39
0
        static public void SaveSmallAudit(string path, string pathSaveFile, IEnumerable <ListDisplay.ListItem> data,
                                          DateTime?dateFrom, DateTime?dateTo, string sumPaid)
        {
            Document document = new Document();

            document.Info.Title = "Mały audyt";

            Section section = document.AddSection();

            section.PageSetup.LeftMargin = "1cm";
            Paragraph paragraph;
            Table     table;
            Column    column;
            Row       row;

            paragraph = section.AddParagraph("Wyciąg z audytu wygenerowany " + DateTime.Now);
            paragraph.Format.Font.Size = 6;

            if (dateFrom == null)
            {
                paragraph = section.AddParagraph("Data od: " + DateTime.Parse(data.First().ItemDate).ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }
            else
            {
                paragraph = section.AddParagraph("Data od: " + dateFrom.Value.ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }

            if (dateTo == null)
            {
                paragraph = section.AddParagraph("Data do: " + DateTime.Parse(data.Last().ItemDate).ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }
            else
            {
                paragraph = section.AddParagraph("Data do: " + dateTo.Value.ToShortDateString());
                paragraph.Format.Font.Size = 6;
            }

            paragraph = section.AddParagraph("\n\n");

            //Table section
            table                     = section.AddTable();
            table.Style               = "Table";
            table.Borders.Color       = Color.Parse("Black");
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Format.Alignment    = ParagraphAlignment.Center;
            table.Rows.LeftIndent     = 0;

            column = table.AddColumn("2,5cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("2,5cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("2,5cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;
            column = table.AddColumn("2cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 5;

            row = table.AddRow();
            row.Format.Font.Bold = true;
            row.Format.Font.Size = 6;
            row.Cells[0].AddParagraph("Kod pracownika");
            row.Cells[1].AddParagraph("ID");
            row.Cells[2].AddParagraph("Televend ID");
            row.Cells[3].AddParagraph("Suma zakupów");

            List <string> IDs = DatabaseHandling.GetCardIDs(path);

            int i;
            IEnumerable <ListDisplay.ListItem> currentIDItem;

            for (i = 0; i < IDs.Count(); i++)
            {
                currentIDItem = (data as IEnumerable <ListDisplay.ListItem>).Where(item => item.ItemID == IDs[i]);
                if (currentIDItem.FirstOrDefault().ItemID == null)
                {
                    continue;
                }
                row = table.AddRow();
                row.Cells[0].AddParagraph(currentIDItem.FirstOrDefault().ItemWorkerID);
                row.Cells[2].AddParagraph(IDs[i]);
                row.Cells[1].AddParagraph(currentIDItem.FirstOrDefault().ItemStickerID);
                row.Cells[3].AddParagraph(currentIDItem.Sum(item => Convert.ToDecimal(item.ItemPurchase)).ToString());
            }

            row = table.AddRow();
            row.Format.Font.Bold = true;
            row.Format.Font.Size = 7;
            row.Cells[0].AddParagraph("Suma");
            row.Cells[3].AddParagraph(sumPaid);

            //Final PDF generation
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);

            renderer.Document = document;
            renderer.RenderDocument();

            if (!pathSaveFile.EndsWith(".pdf"))
            {
                pathSaveFile += ".pdf";
            }

            renderer.PdfDocument.Save(pathSaveFile);
            Process.Start(pathSaveFile);
        }
Example #40
0
 /// <summary>
 /// The add html text.
 /// </summary>
 /// <param name="section">The section.</param>
 /// <param name="html">The html.</param>
 /// <returns>The <see cref="FormattedText" />.</returns>
 public static Paragraph AddHtmlText(this Section section, string html)
 {
     return(section.AddParagraph());
 }
Example #41
0
        /// <summary>Creates the graph.</summary>
        /// <param name="writer">The writer.</param>
        /// <param name="graphAndTable">The graph and table to convert to html.</param>
        /// <param name="workingDirectory">The working directory.</param>
        private void CreateGraphPDF(Section section, AutoDocumentation.GraphAndTable graphAndTable, string workingDirectory)
        {
            // Create a 2 column, 1 row table. Image in first cell, X/Y data in second cell.
            Table table = section.AddTable();

            table.Style           = "GraphAndTable";
            table.Rows.LeftIndent = graphAndTable.indent + "cm";

            Column column1 = table.AddColumn();

            column1.Width = "8cm";
            //column1.Format.Alignment = ParagraphAlignment.Right;
            Column column2 = table.AddColumn();

            column2.Width = "8cm";
            //column2.Format.Alignment = ParagraphAlignment.Right;
            Row row = table.AddRow();

            // Ensure graphs directory exists.
            string graphDirectory = Path.Combine(workingDirectory, "Graphs");

            Directory.CreateDirectory(graphDirectory);

            // Determine the name of the .png file to write.
            string pngFileName = Path.Combine(graphDirectory,
                                              graphAndTable.xyPairs.Parent.Parent.Name + graphAndTable.xyPairs.Parent.Name + ".png");
            int count = 0;

            // If there are multiple graphs with the same name, they may overwrite each other.
            // Therefore, we attempt to generate a unique name. After 20 attempts, we give up.
            while (File.Exists(pngFileName) && count < 20)
            {
                count++;
                pngFileName = Path.Combine(graphDirectory, graphAndTable.xyPairs.Parent.Parent.Name + graphAndTable.xyPairs.Parent.Name + Guid.NewGuid() + ".png");
            }
            // Setup graph.
            GraphView graph = new GraphView();

            graph.Clear();
            graph.Width  = 400;
            graph.Height = 250;

            // Create a line series.
            graph.DrawLineAndMarkers("", graphAndTable.xyPairs.X, graphAndTable.xyPairs.Y, null,
                                     Models.Graph.Axis.AxisType.Bottom, Models.Graph.Axis.AxisType.Left,
                                     System.Drawing.Color.Blue, Models.Graph.LineType.Solid, Models.Graph.MarkerType.None,
                                     Models.Graph.LineThicknessType.Normal, Models.Graph.MarkerSizeType.Normal, true);

            graph.ForegroundColour = OxyPlot.OxyColors.Black;
            graph.BackColor        = OxyPlot.OxyColors.White;
            // Format the axes.
            graph.FormatAxis(Models.Graph.Axis.AxisType.Bottom, graphAndTable.xName, false, double.NaN, double.NaN, double.NaN, false);
            graph.FormatAxis(Models.Graph.Axis.AxisType.Left, graphAndTable.yName, false, double.NaN, double.NaN, double.NaN, false);
            graph.FontSize = 10;
            graph.Refresh();

            // Export graph to bitmap file.
            Bitmap image = new Bitmap(graph.Width, graph.Height);

            using (Graphics gfx = Graphics.FromImage(image))
                using (SolidBrush brush = new SolidBrush(System.Drawing.Color.White))
                {
                    gfx.FillRectangle(brush, 0, 0, image.Width, image.Height);
                }
            graph.Export(ref image, new Rectangle(0, 0, image.Width, image.Height), false);
            graph.MainWidget.Destroy();
            image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png);
            MigraDoc.DocumentObjectModel.Shapes.Image sectionImage = row.Cells[0].AddImage(pngFileName);
            sectionImage.LockAspectRatio = true;
            sectionImage.Width           = "8cm";

            // Add x/y data.
            Paragraph xyParagraph = row.Cells[1].AddParagraph();

            xyParagraph.Style = "xyStyle";
            AddFixedWidthText(xyParagraph, "X", 10);
            AddFixedWidthText(xyParagraph, "Y", 10);
            xyParagraph.AddLineBreak();
            for (int i = 0; i < graphAndTable.xyPairs.X.Length; i++)
            {
                AddFixedWidthText(xyParagraph, graphAndTable.xyPairs.X[i].ToString(), 10);
                AddFixedWidthText(xyParagraph, graphAndTable.xyPairs.Y[i].ToString(), 10);
                xyParagraph.AddLineBreak();
            }

            // Add an empty paragraph for spacing.
            section.AddParagraph();
        }
Example #42
0
        private void InsertCover(Section section)
        {
            ParagraphStyle small = new ParagraphStyle(section.Document);
            small.Name = "small";
            small.CharacterFormat.FontName = "Arial";
            small.CharacterFormat.FontSize = 9;
            small.CharacterFormat.TextColor = Color.Gray;
            section.Document.Styles.Add(small);

            Paragraph paragraph = section.AddParagraph();
            paragraph.AppendText("The sample demonstrates how to insert a header and footer into a document.");
            paragraph.ApplyStyle(small.Name);

            Paragraph title = section.AddParagraph();
            TextRange text = title.AppendText("Field Types Supported by Spire.Doc");
            text.CharacterFormat.FontName = "Arial";
            text.CharacterFormat.FontSize = 36;
            text.CharacterFormat.Bold = true;
            title.Format.BeforeSpacing
                = section.PageSetup.PageSize.Height / 2 - 3 * section.PageSetup.Margins.Top;
            title.Format.AfterSpacing = 8;
            title.Format.HorizontalAlignment
                = Spire.Doc.Documents.HorizontalAlignment.Right;

            paragraph = section.AddParagraph();
            paragraph.AppendText("e-iceblue Spire.Doc team.");
            paragraph.ApplyStyle(small.Name);
            paragraph.Format.HorizontalAlignment
                = Spire.Doc.Documents.HorizontalAlignment.Right;
        }
Example #43
0
        private void InsertContent(Section section)
        {
            //title
            Paragraph paragraph = section.AddParagraph();
            TextRange title = paragraph.AppendText("Summary of Science");
            title.CharacterFormat.Bold = true;
            title.CharacterFormat.FontName = "Arial";
            title.CharacterFormat.FontSize = 14;
            paragraph.Format.HorizontalAlignment
                = Spire.Doc.Documents.HorizontalAlignment.Center;
            paragraph.Format.AfterSpacing = 10;

            //style
            ParagraphStyle style1 = new ParagraphStyle(section.Document);
            style1.Name = "style1";
            style1.CharacterFormat.FontName = "Arial";
            style1.CharacterFormat.FontSize = 9;
            style1.ParagraphFormat.LineSpacing = 1.5F * 12F;
            style1.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
            section.Document.Styles.Add(style1);

            ParagraphStyle style2 = new ParagraphStyle(section.Document);
            style2.Name = "style2";
            style2.ApplyBaseStyle(style1.Name);
            style2.CharacterFormat.Font = new Font("Arial", 10f);
            section.Document.Styles.Add(style2);

            paragraph = section.AddParagraph();
            paragraph.AppendText("(All text and pictures are from ");
            String link = "http://en.wikipedia.org/wiki/Science";
            paragraph.AppendHyperlink(link, "Wikipedia", HyperlinkType.WebLink);
            paragraph.AppendText(", the free encyclopedia)");
            paragraph.ApplyStyle(style1.Name);

            Paragraph paragraph1 = section.AddParagraph();
            String str1
                = "Science (from the Latin scientia, meaning \"knowledge\") "
                + "is an enterprise that builds and organizes knowledge in the form "
                + "of testable explanations and predictions about the natural world. "
                + "An older meaning still in use today is that of Aristotle, "
                + "for whom scientific knowledge was a body of reliable knowledge "
                + "that can be logically and rationally explained "
                + "(see \"History and etymology\" section below).";
            paragraph1.AppendText(str1);

            //Insert a picture in the right of the paragraph1
            DocPicture picture
                = paragraph1.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\Data\Wikipedia_Science.png"));
            picture.TextWrappingStyle = TextWrappingStyle.Square;
            picture.TextWrappingType = TextWrappingType.Left;
            picture.VerticalOrigin = VerticalOrigin.Paragraph;
            picture.VerticalPosition = 0;
            picture.HorizontalOrigin = HorizontalOrigin.Column;
            picture.HorizontalAlignment = ShapeHorizontalAlignment.Right;

            paragraph1.ApplyStyle(style2.Name);

            Paragraph paragraph2 = section.AddParagraph();
            String str2
                = "Since classical antiquity science as a type of knowledge was closely linked "
                + "to philosophy, the way of life dedicated to discovering such knowledge. "
                + "And into early modern times the two words, \"science\" and \"philosophy\", "
                + "were sometimes used interchangeably in the English language. "
                + "By the 17th century, \"natural philosophy\" "
                + "(which is today called \"natural science\") could be considered separately "
                + "from \"philosophy\" in general. But \"science\" continued to also be used "
                + "in a broad sense denoting reliable knowledge about a topic, in the same way "
                + "it is still used in modern terms such as library science or political science.";
            paragraph2.AppendText(str2);
            paragraph2.ApplyStyle(style2.Name);

            Paragraph paragraph3 = section.AddParagraph();
            String str3
                = "The more narrow sense of \"science\" that is common today developed as a part "
                + "of science became a distinct enterprise of defining \"laws of nature\", "
                + "based on early examples such as Kepler's laws, Galileo's laws, and Newton's "
                + "laws of motion. In this period it became more common to refer to natural "
                + "philosophy as  \"natural science\". Over the course of the 19th century, the word "
                + "\"science\" became increasingly associated with the disciplined study of the "
                + "natural world including physics, chemistry, geology and biology. This sometimes "
                + "left the study of human thought and society in a linguistic limbo, which was "
                + "resolved by classifying these areas of academic study as social science. "
                + "Similarly, several other major areas of disciplined study and knowledge "
                + "exist today under the general rubric of \"science\", such as formal science "
                + "and applied science.";
            paragraph3.AppendText(str3);
            paragraph3.ApplyStyle(style2.Name);
        }