Exemplo n.º 1
0
        public static MigraDoc.DocumentObjectModel.Document CreateDocument(string input)
        {
            MigraDoc.DocumentObjectModel.Document document = new MigraDoc.DocumentObjectModel.Document();
            document.DefaultPageSetup.Orientation    = MigraDoc.DocumentObjectModel.Orientation.Portrait;
            document.DefaultPageSetup.HeaderDistance = 1;
            Section section = document.AddSection();

            section.PageSetup.TopMargin    = 90;
            section.PageSetup.BottomMargin = 20;
            section.PageSetup.RightMargin  = 5;
            section.PageSetup.LeftMargin   = 50;
            Paragraph header = section.Headers.Primary.AddParagraph();

            MigraDoc.DocumentObjectModel.Shapes.Image img = new MigraDoc.DocumentObjectModel.Shapes.Image();
            header.AddImage(@"\\192.168.201.6\Telex\white.png");
            Paragraph paragraph = section.AddParagraph();

            MigraDoc.DocumentObjectModel.Shapes.Image img2 = new MigraDoc.DocumentObjectModel.Shapes.Image();
            header.AddImage(@"\\192.168.201.6\Telex\logo.png");
            Paragraph paragraph2 = section.AddParagraph();

            paragraph.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.FromCmyk(0, 0, 0, 100);
            paragraph.Format.Font.Name  = "Courier New";
            paragraph.Format.Font.Size  = 9;
            paragraph.AddText(input.Replace(" ", " "));
            return(document);
        }//--------------------------------------
Exemplo n.º 2
0
        public static void DefCover(Document document)
        {
            Section   section   = document.AddSection();
            Paragraph paragraph = section.AddParagraph();
            var       image     = paragraph.AddImage($"images/1.jpg");

            image.Width  = "6cm";
            image.Height = "3cm";
            paragraph.Format.SpaceAfter     = "-3cm";
            paragraph.Format.SpaceBefore    = "-2cm";
            paragraph.Format.Borders.Bottom = new Border {
                Width = "2pt", Color = Colors.DarkGray
            };
            paragraph = section.AddParagraph("Energy Service Report", "Zero");
            paragraph.Format.Font.Color = Colors.DarkBlue;
            paragraph.Format.Font.Size  = 22;
            paragraph.Format.Font.Bold  = true;
            paragraph.Format.LeftIndent = "7cm";
            paragraph = section.AddParagraph("Cordium: Real-time heat control", "Zero");
            paragraph.Format.Font.Color  = Colors.LightBlue;
            paragraph.Format.SpaceBefore = "1cm";
            paragraph.Format.LeftIndent  = "7cm";
            paragraph.Format.Font.Size   = 18;
            paragraph = section.AddParagraph("Period:", "Title");
            paragraph = section.AddParagraph();
            var data = paragraph.AddDateField();

            data.Format = "MM, yyyy";
            paragraph.Format.Font.Size   = 16;
            paragraph.Format.SpaceBefore = "-1.3cm";
            paragraph.Format.Alignment   = ParagraphAlignment.Right;
            ProjectDetails(section);
            ExecutiveSum(section);
            ProjectOverview(section);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add an image to the section.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="section"></param>
        /// <param name="imagePath">Path for images.</param>
        /// <returns></returns>
        private static DocumentObject AddImage(HtmlNode node, DocumentObject section, string imagePath)
        {
            HtmlAttribute srcAttribute = node.Attributes["src"];

            if (srcAttribute != null)
            {
                string fullPath;
                if (String.IsNullOrEmpty(imagePath))
                {
                    fullPath = srcAttribute.Value;
                }
                else
                {
                    fullPath = Path.Combine(imagePath, srcAttribute.Value);
                }
                if (!File.Exists(fullPath))
                {
                    // Look in documentation folder.
                    string binDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    fullPath = Path.Combine(binDirectory, @"..\Documentation\Images", Path.GetFileName(fullPath));
                    fullPath = Path.GetFullPath(fullPath);
                }

                if (File.Exists(fullPath))
                {
                    Paragraph para = section.Section.AddParagraph();
                    para.AddImage(fullPath);
                }
            }
            return(section);
        }
Exemplo n.º 4
0
        private void AddLogoDateProducerNameAddressAndCicle(Document document, DateTime date, Producer producer, string cicle)
        {
            string          producerName     = producer.Name + " " + producer.PaternalSurname + " " + producer.MaternalSurname;
            SelectableModel state            = new CatalogBL(settlementDL.ConnectionString).GetStates().Where(x => x.Id == producer.StateId).FirstOrDefault();
            string          producerAddress  = producer.Address + ". C.P: " + producer.ZipCode + ". Colonia " + producer.DistrinctOrColony + ". " + producer.City + ", " + state.Name;
            TextInfo        textInfo         = new CultureInfo("en-US", false).TextInfo;
            string          dateString       = textInfo.ToUpper(date.ToString("D", CultureInfo.CreateSpecificCulture("es-MX")));
            var             assembly         = Assembly.GetExecutingAssembly();
            Paragraph       currentParagraph = document.LastSection.AddParagraph();

            using (Stream stream = assembly.GetManifestResourceStream("LasMargaritas.BL.Images.LogoMargaritasMedium.jpg"))
            {
                if (stream == null)
                {
                    throw new ArgumentException("No resource with name");
                }
                int    count = (int)stream.Length;
                byte[] data  = new byte[count];
                stream.Read(data, 0, count);
                currentParagraph.Format.Alignment = ParagraphAlignment.Right;
                currentParagraph.AddImage("base64:" + Convert.ToBase64String(data));
            }
            currentParagraph = document.LastSection.AddParagraph();
            currentParagraph.AddFormattedText("Ciclo: ", "Heading2");
            currentParagraph.AddText(cicle);
            currentParagraph = document.LastSection.AddParagraph();
            currentParagraph.AddFormattedText("Fecha: ", "Heading2");
            currentParagraph.AddText(dateString);
            currentParagraph = document.LastSection.AddParagraph();
            currentParagraph.AddFormattedText("Productor: ", "Heading2");
            currentParagraph.AddText(producerName);
            currentParagraph = document.LastSection.AddParagraph();
            currentParagraph.AddFormattedText("Domicilio: ", "Heading2");
            currentParagraph.AddText(producerAddress);
        }
Exemplo n.º 5
0
        private void PageSettings(Section section)
        {
            Paragraph naglowek = section.Headers.Primary.AddParagraph();

            naglowek.Format.Font.Underline = Underline.Single;
            //  vugraph.tytul = "EJCH";
            naglowek.AddFormattedText("European Youth Bridge Championship");
            // string tekst = vugraph.tytul;

            //   if (tekst.Count() > 40)
            //        tekst = tekst.Substring(0, 40);

            naglowek.AddSpace(5);
            naglowek.AddImage("images\\mini_b24dwa.jpg");
            naglowek.AddSpace(10);
            naglowek.AddFormattedText(game.data.ToShortDateString());

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

            stopka.Format.Borders.Top.Width = Unit.FromCentimeter(0.1);
            stopka.AddFormattedText(mail);
            stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab();
            stopka.Format.Alignment = ParagraphAlignment.Justify;
            stopka.AddFormattedText("Strona ");
            stopka.AddPageField();
            stopka.AddFormattedText(" z " + (Ustawienia.ilosc_rozdan + 2).ToString());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add an image to the section.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="section"></param>
        /// <param name="imagePath">Path for images.</param>
        /// <param name="relativePath">If images are provided as a relative path name, the full path name will be resolved relative to this path.</param>
        /// <returns></returns>
        private static DocumentObject AddImage(HtmlNode node, DocumentObject section, string imagePath, string relativePath)
        {
            HtmlAttribute srcAttribute = node.Attributes["src"];

            if (srcAttribute != null)
            {
                string absolutePath = PathUtilities.GetAbsolutePath(srcAttribute.Value, relativePath);
                string fullPath;
                if (String.IsNullOrEmpty(imagePath))
                {
                    fullPath = srcAttribute.Value;
                }
                else if (File.Exists(absolutePath))
                {
                    fullPath = absolutePath;
                }
                else if (File.Exists(srcAttribute.Value))
                {
                    fullPath = srcAttribute.Value;
                }
                else
                {
                    fullPath = GetImagePath(srcAttribute.Value, imagePath);
                }

                if (File.Exists(fullPath))
                {
                    Paragraph para = section.Section.AddParagraph();
                    para.AddImage(fullPath);
                }
            }
            return(section);
        }
Exemplo n.º 7
0
        private void PageSettings(Section section)
        {
            Paragraph naglowek = section.Headers.Primary.AddParagraph();

            naglowek.Format.Font.Underline = Underline.Single;

            naglowek.AddFormattedText("Trening licytacyjny");


            naglowek.AddSpace(22);
            naglowek.AddImage("images\\mini_b24dwa.jpg");
            naglowek.AddSpace(15);
            naglowek.AddFormattedText(DateTime.Now.ToShortDateString());


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

            stopka.Format.Borders.Top.Width = Unit.FromCentimeter(0.1);
            stopka.AddFormattedText(mail);
            stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab();
            stopka.AddSpace(4);
            stopka.Format.Alignment = ParagraphAlignment.Justify;
            stopka.AddFormattedText("Strona ");
            stopka.AddPageField();
            stopka.AddFormattedText(" z " + (Ustawienia.ilosc_rozdan + 1).ToString());
        }
Exemplo n.º 8
0
        private void PageSettings(Section section)
        {
            Paragraph naglowek = section.Headers.Primary.AddParagraph();

            naglowek.Format.Font.Underline = Underline.Single;

            naglowek.AddFormattedText(vugraph1.tytul);
            string tekst = vugraph1.tytul;

            if (tekst.Count() > 40)
            {
                tekst = tekst.Substring(0, 40);
            }

            naglowek.AddSpace(40 - vugraph1.tytul.Count());
            naglowek.AddImage("images\\mini_b24dwa.jpg");
            naglowek.AddSpace(15);
            naglowek.AddFormattedText(DateTime.Now.ToShortDateString());


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

            stopka.Format.Borders.Top.Width = Unit.FromCentimeter(0.1);
            stopka.AddFormattedText(mail);
            stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab(); stopka.AddTab();
            stopka.AddSpace(4);
            stopka.Format.Alignment = ParagraphAlignment.Justify;
            stopka.AddFormattedText("Strona ");
            stopka.AddPageField();
            stopka.AddFormattedText(" z " + (Ustawienia.ilosc_rozdan + 1).ToString());
        }
Exemplo n.º 9
0
        private void печатьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (!webControl1.IsLive)
                {
                    return;
                }

                Graphics g = webControl1.CreateGraphics();
                File.Delete(AppDomain.CurrentDomain.BaseDirectory + @"\temp.png");
                int bmpHeight;
                int bmpWidth;
                using (Bitmap bmp = new Bitmap(webControl1.Width, webControl1.Height))
                {
                    webControl1.DrawToBitmap(bmp, new Rectangle(0, 0, webControl1.Width, webControl1.Height));
                    bmp.Save(AppDomain.CurrentDomain.BaseDirectory + @"\temp.png", System.Drawing.Imaging.ImageFormat.Png);
                    bmpHeight = bmp.Height;
                    bmpWidth  = bmp.Width;
                }
                document = new Document();
                Style style = document.Styles["Normal"];
                style.Font.Name = "Times New Roman";
                style.Font.Size = 10;
                Section   page = document.AddSection();
                PageSetup p    = new PageSetup();
                p.OddAndEvenPagesHeaderFooter = true;
                p.StartingNumber = 1;
                p.BottomMargin   = "5mm";
                p.LeftMargin     = "5mm";
                p.RightMargin    = "5mm";
                p.TopMargin      = "5mm";
                p.PageFormat     = PageFormat.A4;
                if (bmpHeight > 700 | bmpWidth > 1070 && bmpHeight <= 1050 && bmpWidth <= 1530)
                {
                    p.PageFormat = PageFormat.A3;
                }
                else if (bmpHeight > 1050 | bmpWidth > 1530 && bmpHeight <= 1530 && bmpWidth <= 2100)
                {
                    p.PageFormat = PageFormat.A2;
                }
                p.Orientation  = MigraDoc.DocumentObjectModel.Orientation.Landscape;
                page.PageSetup = p;
                Paragraph paragraph = page.AddParagraph(this.Text);
                paragraph.Style = "Normal";
                paragraph       = page.AddParagraph("");
                paragraph.Style = "Normal";
                MigraDoc.DocumentObjectModel.Shapes.Image map = paragraph.AddImage(@"temp.png");
                paragraph.Style   = "Normal";
                paragraph         = page.AddParagraph(toolStripStatusLabel1.Text);
                renderer          = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
                renderer.Document = document;
                renderer.RenderDocument();
                renderer.Save(saveFileDialog1.FileName);
                Process.Start(saveFileDialog1.FileName);
            }
        }
Exemplo n.º 10
0
        Document CreateDocument()
        {
            // Create a new MigraDoc document
            Document document = new Document();

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

            // Add a paragraph to the section
            Paragraph paragraph = section.AddParagraph();

            // Add some text to the paragraph
            paragraph.AddImage(Application.StartupPath + "\\images\\logo.png");
            paragraph.AddFormattedText("Braze number: " + textBox1.Text + "\n", TextFormat.Bold);
            paragraph.AddFormattedText("Date: " + textBox2.Text + "\n", TextFormat.NotBold);
            paragraph.AddFormattedText("Duration: " + textBox3.Text + "\n", TextFormat.NotBold);
            paragraph.AddFormattedText("Status: " + textBox5.Text + "\n\n", TextFormat.NotBold);
            paragraph.AddFormattedText("Log: " + "\n", TextFormat.Bold);
            int loCount = 0;

            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (listView1.Items[i].Text.Contains("The large Nitrogen valve is opened."))
                {
                    if (loCount < 2)
                    {
                        paragraph.AddFormattedText(listView1.Items[i].Text + "\n", TextFormat.NotBold);
                    }
                    loCount++;
                    if (loCount == 2)
                    {
                        paragraph.AddFormattedText("...\n", TextFormat.NotBold);
                    }
                }
                else if (listView1.Items[i].Text.Contains("The large Nitrogen valve is closed."))
                {
                    if (loCount < 2)
                    {
                        paragraph.AddFormattedText(listView1.Items[i].Text + "\n", TextFormat.NotBold);
                    }
                }
                else
                {
                    paragraph.AddFormattedText(listView1.Items[i].Text + "\n", TextFormat.NotBold);
                }
            }
            //paragraph.AddImage("../../SomeImage.png");
            //paragraph.AddImage("../../Logo.pdf");
            //section.AddImage("../../Logo.pdf");
            section.AddImage(Application.StartupPath + "\\temp\\testa.png");
            section.AddImage(Application.StartupPath + "\\temp\\testb.png");

            return(document);
        }
Exemplo n.º 11
0
 private void AddImageFileToDocument(string filePath)
 {
     currentSection = document.AddSection();
     currentSection.PageSetup.PageFormat   = PageFormat.A4;
     currentSection.PageSetup.TopMargin    = MARGIN;
     currentSection.PageSetup.BottomMargin = MARGIN;
     currentSection.PageSetup.LeftMargin   = MARGIN;
     currentSection.PageSetup.RightMargin  = MARGIN;
     currentParagraph = currentSection.AddParagraph();
     currentParagraph.Format.Alignment = ParagraphAlignment.Center;
     MigraDoc.DocumentObjectModel.Shapes.Image image = currentParagraph.AddImage(filePath);
     ChooseDimensions(filePath, image);
 }
Exemplo n.º 12
0
        private void setProfilePhoto(Section i_Section)
        {
            const string height = "2.5cm";
            const string Width  = "2.5cm";

            Paragraph paragraph = i_Section.AddParagraph();

            paragraph.Format.Alignment = ParagraphAlignment.Right;
            Image image = paragraph.AddImage(m_PicturePath);

            image.Height = height;
            image.Width  = Width;
        }
Exemplo n.º 13
0
        public static void PopulatePage(Document document, Owner owner, string city = null)
        {
            if (city == null)
            {
                using (var db = new DB.DomenaDBContext())
                {
                    city = db.Settings.FirstOrDefault(s => s.Key == "city-name")?.Value;
                }
            }

            // Create header
            Section section = document.AddSection();

            section.PageSetup.LeftMargin = Unit.FromCentimeter(1);
            section.PageSetup.TopMargin  = Unit.FromCentimeter(5.5);
            Paragraph paragraph = section.Headers.Primary.AddParagraph();

            paragraph.Format.RightIndent = "9cm";
            paragraph.Format.SpaceBefore = "-1cm";
            Image image = paragraph.AddImage("Images/DomenaLogo.png");

            image.ScaleWidth = 0.4;

            paragraph = section.Headers.Primary.AddParagraph();
            paragraph.Format.Alignment   = ParagraphAlignment.Right;
            paragraph.Format.RightIndent = "0";
            paragraph.AddText(city + DateTime.Today.ToString("dd.MM.yyyy"));
            paragraph.Format.SpaceBefore = "-5.5cm";
            paragraph.Format.SpaceAfter  = "6.5cm";

            paragraph = section.Headers.Primary.AddParagraph();
            paragraph.Format.Alignment   = ParagraphAlignment.Right;
            paragraph.Format.RightIndent = "0";
            paragraph.AddText(owner.OwnerName + Environment.NewLine + owner.MailAddress);
            paragraph.Format.SpaceBefore = "1.5cm";
            paragraph.Format.SpaceAfter  = "3.5cm";

            // Create footer
            paragraph = section.Footers.Primary.AddParagraph();
            paragraph.AddText("Zarządzanie Nieruchomościami \"Domena\"   ·   +48 509 940 020   ·   [email protected]");
            paragraph.Format.Font.Color = Colors.Gray;
            paragraph.Format.Font.Size  = 9;
            paragraph.Format.Alignment  = ParagraphAlignment.Center;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Add an image to the section.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="section"></param>
        /// <param name="imagePath">Path for images.</param>
        /// <returns></returns>
        private static DocumentObject AddImage(HtmlNode node, DocumentObject section, string imagePath)
        {
            HtmlAttribute srcAttribute = node.Attributes["src"];
            if (srcAttribute != null)
            {
                string fullPath;
                if (String.IsNullOrEmpty(imagePath))
                    fullPath = srcAttribute.Value;
                else
                    fullPath = GetImagePath(srcAttribute.Value, imagePath);

                if (File.Exists(fullPath))
                {
                    Paragraph para = section.Section.AddParagraph();
                    para.AddImage(fullPath);
                }
            }
            return section;
        }
        private void createHeader()
        {
            Section      currentSection = (Section)serviceSheetDoc.Sections.LastObject;
            HeaderFooter header         = currentSection.Headers.Primary;
            Paragraph    headerPara     = header.AddParagraph("Report No. " + currentSheet.SubmissionNumber);

            headerPara.Format.Alignment = ParagraphAlignment.Right;
            header.Style = "Normal";

            //Separate header for first page
            HeaderFooter firstPageHeader     = currentSection.Headers.FirstPage;
            Paragraph    headerParaFirstPage = firstPageHeader.AddParagraph();

            headerParaFirstPage.Format.Alignment = ParagraphAlignment.Right;
            //RT 30/1/17 - Adding US logo
            Image imgHeaderLogo = null;

            if (currentSheet.UkServiceSheet == true)
            {
                imgHeaderLogo = Service_Reader.Properties.Resources.MTTHeaderLogo;
            }
            else if (currentSheet.UkServiceSheet == false)
            {
                imgHeaderLogo = Service_Reader.Properties.Resources.MTTIncHeaderlogo;
            }
            else
            {
                Console.WriteLine("UK/US job not identified");
            }

            string headerLogoStr   = imageToMigradocString(imgHeaderLogo);
            var    headerFirstPage = headerParaFirstPage.AddImage(headerLogoStr);

            if (currentSheet.UkServiceSheet == false)
            {
                headerFirstPage.Height          = new Unit(1.31, UnitType.Centimeter);
                headerFirstPage.LockAspectRatio = true;
            }
            headerFirstPage.Top  = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Top;
            headerFirstPage.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Right;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Add an image to the section.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="section"></param>
        /// <param name="imagePath">Path for images.</param>
        /// <returns></returns>
        private static DocumentObject AddImage(HtmlNode node, DocumentObject section, string imagePath)
        {
            HtmlAttribute srcAttribute = node.Attributes["src"];

            if (srcAttribute != null)
            {
                string fullPath = Path.Combine(imagePath, srcAttribute.Value);
                if (File.Exists(fullPath))
                {
                    Paragraph para   = section.Section.AddParagraph();
                    Image     image1 = para.AddImage(fullPath);
                    //image1.Height = "8cm";
                    //image1.Width = "8cm";
                    //image1.LockAspectRatio = true;
                    //Image image = section.Section.AddImage(fullPath);
                    //image.Height = new Unit(100, UnitType.Millimeter);
                    //image.
                }
            }
            return(section);
        }
Exemplo n.º 17
0
        private void GetPDF()
        {
            string   name     = textBox1.Text + ".pdf";
            Document document = new Document();
            Section  section  = document.AddSection();

            section.PageSetup.PageFormat   = PageFormat.A4;                                     //стандартный размер страницы
            section.PageSetup.Orientation  = MigraDoc.DocumentObjectModel.Orientation.Portrait; //ориентация
            section.PageSetup.BottomMargin = 0;                                                 //нижний отступ
            section.PageSetup.TopMargin    = 0;                                                 //верхний отступ
            section.PageSetup.RightMargin  = 0;                                                 //
            section.PageSetup.LeftMargin   = 0;


            foreach (Page page in pages)
            {
                //MigraDoc.DocumentObjectModel.Shapes.Image image = new MigraDoc.DocumentObjectModel.Shapes.Image(page.FName)
                Paragraph paragraph = new Paragraph();

                paragraph.AddImage(page.FName);
                var tmp = paragraph.Elements.LastObject;
                if (tmp is MigraDoc.DocumentObjectModel.Shapes.Image)
                {
                    tmp123(tmp);
                }


                section.Add(paragraph);
            }


            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            string name1 = string.Format(@"C:\2\{0}.pdf", Guid.NewGuid());

            pdfRenderer.PdfDocument.Save(name1);
            MessageBox.Show(name1);
        }
Exemplo n.º 18
0
        private static void cargarEncabezado(Section seccion, string apellidoPaciente, string nombrePaciente, string equipo, string IDPaciente, string nombrePlantilla, string realizadoPor, string plan, string presc)
        {
            seccion.AddParagraph("Analisis de restricciones en plan de tratamiento", "Titulo");
            string paciente = "";
            string fecha    = "";

            if (apellidoPaciente != "" || nombrePaciente != "")
            {
                paciente = apellidoPaciente + ", " + nombrePaciente;
                fecha    = DateTime.Today.ToShortDateString();
            }

            MigraDoc.DocumentObjectModel.Tables.Table tabla = new MigraDoc.DocumentObjectModel.Tables.Table();
            tabla.AddColumn(270);
            tabla.AddColumn(230);
            tabla.Borders.Width = 0.5;
            for (int i = 0; i < 8; i++)
            {
                tabla.AddRow();
            }
            tabla.Rows[0].Cells[0].Add(Estilos.etiquetaYValor("Paciente", paciente));
            tabla.Rows[1].Cells[0].Add(Estilos.etiquetaYValor("HC", IDPaciente));
            tabla.Rows[2].Cells[0].Add(Estilos.etiquetaYValor("Equipo", equipo));
            tabla.Rows[3].Cells[0].Add(Estilos.etiquetaYValor("Plantilla", nombrePlantilla));
            tabla.Rows[4].Cells[0].Add(Estilos.etiquetaYValor("Realizado por", realizadoPor));
            tabla.Rows[5].Cells[0].Add(Estilos.etiquetaYValor("Fecha", fecha));
            tabla.Rows[6].Cells[0].Add(Estilos.etiquetaYValor("Nombre del Plan", plan));
            tabla.Rows[7].Cells[0].Add(Estilos.etiquetaYValor("Dosis de prescripción (Gy)", presc));

            tabla.Rows[0].Cells[1].MergeDown = 7;
            Paragraph parrafoImage = new Paragraph();

            parrafoImage.Format.Alignment = ParagraphAlignment.Right;
            parrafoImage.AddImage(Properties.Settings.Default.Path + @"\PlanExplorer\LogoMeva.png");
            tabla.Rows[0].Cells[1].Add(parrafoImage);
            seccion.Add(tabla);
            seccion.AddParagraph();
            seccion.AddParagraph();
        }
Exemplo n.º 19
0
        /// <summary>
        /// Tworzy nagłówek. Formatowania na sztywno, ale zależne od szeokosci strony. Obrazek na sztywno, wymaga istnienia pliku z obrazkiem
        /// </summary>
        /// <returns>Tabele z zawartoscia tego co ma byc w nagłówku</returns>
        protected Table SetHeader()
        {
            Table header = new Table();

            header.AddColumn(Unit.FromCentimeter(0.4 * szerokosc_strony));  // kolumna na tytul
            header.AddColumn(Unit.FromCentimeter(szerokosc_strony / 4));    //kolumna na obrazek
            header.AddColumn(Unit.FromCentimeter(0.35 * szerokosc_strony)); // kolumna na datę

            header.AddRow();
            header.Borders.Bottom.Width = 1.0;

            // Przygotowanie napisu nagłowkowego
            Paragraph title = new Paragraph();

            title.AddFormattedText(napisTytulowy, new Font("Verdana", 10));
            header[0, 0].Format.Alignment  = ParagraphAlignment.Left;
            header[0, 0].VerticalAlignment = VerticalAlignment.Bottom;
            header[0, 0].Add(title);

            // Przygotowanie loga
            Paragraph logo = new Paragraph();

            logo.AddImage("mini_b24.jpg");
            header[0, 1].Format.Alignment = ParagraphAlignment.Left;
            header[0, 1].Add(logo);

            // Przygotowanie daty

            Paragraph data = new Paragraph();

            data.AddFormattedText(date, new Font("Verdana", 10));
            header[0, 2].Format.Alignment  = ParagraphAlignment.Right;
            header[0, 2].VerticalAlignment = VerticalAlignment.Bottom;
            header[0, 2].Add(data);

            return(header);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Adds an image to the specified document object, resizing the
        /// image as necessary to ensure that it fits on the page.
        /// </summary>
        /// <param name="doc">The document object.</param>
        /// <param name="fullPath">Path to the image on disk.</param>
        public static void AddResizeImage(this DocumentObject doc, string fullPath)
        {
            Section section = doc.Section ?? doc as Section;

            if (section == null)
            {
                return;
            }
            Paragraph paragraph = doc as Paragraph ?? section.AddParagraph();

            // The image could potentially be too large. Therfore we read it,
            // adjust the size to fit the page better (if necessary), and add
            // the modified image to the paragraph.

            // fixme - ResizeImage() expects units in pixels
            GetPageSize(section, out double pageWidth, out double pageHeight);
#if NETFRAMEWORK
            string path = Path.ChangeExtension(Path.GetTempFileName(), ".png");
            ReadAndResizeImage(fullPath, pageWidth, pageHeight).Save(path, ImageFormat.Png);
            section.AddImage(path);
#else
            if (paragraph != null)
            {
                // Note: the first argument passed to the FromStream() function
                // is the name of the image. Thist must be unique throughout the document,
                // otherwise you will run into problems with duplicate imgages.
                paragraph.AddImage(ImageSource.FromStream(fullPath, () =>
                {
                    Image image   = ReadAndResizeImage(fullPath, pageWidth, pageHeight);
                    Stream stream = new MemoryStream();
                    image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    stream.Seek(0, SeekOrigin.Begin);
                    return(stream);
                }));
            }
#endif
        }
Exemplo n.º 21
0
        private static void AddCompetitionAndLogo(Client.DataAccess c, Section sec)
        {
            String    competitionName = "Competition: " + c.SelectedCompetition.Name;
            Paragraph pg = sec.AddParagraph();

            pg.Format.Alignment    = ParagraphAlignment.Left;
            pg.Format.KeepTogether = false;
            pg.Format.KeepWithNext = false;
            pg.Format.AddTabStop(Unit.FromCentimeter(21));

            FormattedText ft = pg.AddFormattedText(competitionName);

            ft.Bold = true;
            ft.Size = Unit.FromPoint(16);
            pg.AddTab();


            MigraDoc.DocumentObjectModel.Shapes.Image logo = pg.AddImage(@"Resources\ANR_LOGO.jpg");
            logo.Height          = Unit.FromCentimeter(1.912);
            logo.Width           = Unit.FromCentimeter(2.873);
            logo.LockAspectRatio = true;
            logo.Left            = Unit.FromCentimeter(24);
            logo.Top             = Unit.FromCentimeter(0);
        }
Exemplo n.º 22
0
        // [UnitTestFunction]
        public static void Test()
        {
            Document doc  = new Document();
            Style    styl = doc.AddStyle("TestStyle1", Style.DefaultParagraphFontName);

            styl.Font.Bold = true;
            Section sec = doc.AddSection();

            sec.PageSetup.PageHeight = "30cm";

            sec.Headers.FirstPage.Format.Font.Bold = true;
            sec.Headers.Primary.AddParagraph("This is the Primary Header.");
            sec.Headers.FirstPage.AddParagraph("This is the First Page Header.");
            sec.Headers.EvenPage.AddParagraph("This is the Even Page Header.");

            Paragraph par = sec.AddParagraph("Paragraph 1");

//      par.Style = "TestStyle1";
            par.Format.ListInfo.NumberPosition = 2;


            par = sec.AddParagraph("Paragraph 2");
            par.Format.ListInfo.ListType = ListType.BulletList3;
            Image img1 = par.AddImage("logo.gif");

//      Image img1 = par.AddImage("tick_green.png");
            img1.ScaleHeight            = 5;
            img1.ScaleWidth             = 2;
            img1.Height                 = "0.3cm";
            img1.Width                  = "5cm";
            img1.PictureFormat.CropLeft = "-2cm";
            img1.FillFormat.Color       = Color.PowderBlue;
            img1.LineFormat.Width       = 2;


            par = sec.AddParagraph("Paragraph 3");
            par.AddLineBreak();
            par.Format.ListInfo.NumberPosition = 2;

            TextFrame tf = sec.AddTextFrame();

            tf.WrapFormat.Style   = WrapStyle.None;
            tf.RelativeHorizontal = RelativeHorizontal.Page;
            tf.RelativeVertical   = RelativeVertical.Page;

            tf.Top                  = Unit.FromCm(2);
            tf.Left                 = ShapePosition.Center;
            tf.Height               = "20cm";
            tf.Width                = "10cm";
            tf.FillFormat.Color     = Color.LemonChiffon;
            tf.LineFormat.Color     = Color.BlueViolet;
            tf.LineFormat.DashStyle = DashStyle.DashDotDot;
            tf.LineFormat.Width     = 2;
            tf.AddParagraph("in a text frame");
            tf.MarginTop   = "3cm";
            tf.Orientation = TextOrientation.Downward;

            Image img = sec.AddImage("test1.jpg");

            img.ScaleHeight            = 500;
            img.ScaleWidth             = 200;
            img.Height                 = "10cm";
            img.Width                  = "10cm";
            img.PictureFormat.CropLeft = "-2cm";
            img.FillFormat.Color       = Color.LawnGreen;
            img.LineFormat.Width       = 3;
            img.WrapFormat.Style       = WrapStyle.None;

            sec = doc.AddSection();//.AddParagraph("test");
            sec.PageSetup.PageWidth = "30cm";
            sec.AddParagraph("Section 2");

            DocumentRenderer docRenderer = new DocumentRenderer();

            docRenderer.Render(doc, "RtfListInfo.txt", null);
            DdlWriter.WriteToFile(doc, "RtfListInfo.mdddl");
            System.IO.File.Copy("RtfListInfo.txt", "RtfListInfo.rtf", true);
            System.Diagnostics.Process.Start("RtfListInfo.txt");
        }
Exemplo n.º 23
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());
        }
Exemplo n.º 24
0
        private void RightSide(IPdfStyling pdfStyling, Section section)
        {
            MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();

            table.TopPadding    = 0;
            table.RightPadding  = 0;
            table.BottomPadding = 0;
            table.LeftPadding   = 0;
            table.Borders.Width = 0;

            table.Rows.LeftIndent = GetTableIndent(pdfStyling);
            table.AddColumn(_tableLeftWidth);
            table.AddColumn(_tableRightWidth);

            Row row = table.AddRow();

            Cell header = row.Cells[0];

            header.MergeRight = 1;

            Paragraph logoWrapper = header.AddParagraph();

            logoWrapper.Format.Alignment = ParagraphAlignment.Center;

            Image logo = logoWrapper.AddImage(@"D:\DEVELOPMENT\GIT\OPTEN Solutions\tests\Opten.Web.Infrastructure.Pdf.Test\Images\logo_rimuss_secco.jpg");

            logo.LockAspectRatio           = true;
            logo.Height                    = Unit.FromMillimeter(18);
            logoWrapper.Format.SpaceBefore = 0;
            logoWrapper.Format.SpaceAfter  = Unit.FromCentimeter(1);

            Paragraph h1 = header.AddParagraph();

            h1.AddText("WINTER-BOWLE");
            h1.Format.Font.Size = 16;
            //h1.Format.Font.Bold = true;
            h1.Format.SpaceBefore = 0;
            h1.Format.SpaceAfter  = Unit.FromCentimeter(0.5);
            h1.Format.Alignment   = ParagraphAlignment.Center;

            h1.AddBookmark("Receipt1");
            h1.Format.OutlineLevel = OutlineLevel.Level1;

            TextFrame pWrapper = header.AddTextFrame();

            pWrapper.Height = Unit.FromCentimeter(1);
            pWrapper.Width  = _leftSideWidth;
            Paragraph p = pWrapper.AddParagraph();

            p.Format.Font.Color      = pdfStyling.ParagraphSmallColor;
            p.Format.LineSpacing     = Unit.FromCentimeter(0.5);
            p.Format.LineSpacingRule = LineSpacingRule.AtLeast;
            p.Format.SpaceAfter      = Unit.FromCentimeter(-0.25);        // Line spacing
            p.AddText("Warum eigentlich eine Fruchtbowle nur im Sommer geniessen?\nDiese Bowleiessen?\nDiese Bowle verhilft auch an kalten und unliessen?\nDiese Bowle verhilft auch an kalten und unl verhilft auch an kalten und unlustigen Winterabenden zu\neiner beschwingten Leichtigkeit.");
            p.Format.Alignment = ParagraphAlignment.Center;

            HorizontalRule(pdfStyling, header);

            Paragraph h2 = header.AddParagraph();

            h2.AddText("ZUBEREITUNG FÜR 1 GLAS");
            h2.Format.Font.Size   = 12;
            h2.Format.SpaceBefore = 0;
            h2.Format.SpaceAfter  = Unit.FromCentimeter(0.5);
            h2.Format.LeftIndent  = Unit.FromCentimeter(1);
            h2.Format.Alignment   = ParagraphAlignment.Left;

            IDictionary <string, string> rows = new Dictionary <string, string> {
                { "frische Babyananas", "1" },
                { "Kiwi", "1" },
                { "Clementine, alle Früchte schneiden", "1" },
                { "Zitrone, Saft", "1" },
                { "Esslöffel Zucker, ales mischen", "1" },
                { "Secco dazugiessen, zugedeckt", "7 dl" },
                { "kühl stellen", "ca. 1 Std." },
                { "kaltes Mineralwasser kurz vor dem Servieren dazugiessen", "3 dl" }
            };

            Table(pdfStyling, table, rows);

            row = table.AddRow();

            Cell bottom = row.Cells[0];

            bottom.MergeRight = 1;

            Paragraph small = bottom.AddParagraph();

            small.AddText("Deko: 1 Schnitz Grapefruit");
            small.Format.SpaceBefore = Unit.FromCentimeter(0.5);
            small.Format.SpaceAfter  = 0;
            small.Format.LeftIndent  = Unit.FromCentimeter(1);
            small.Format.Font.Size   = 10;
            small.Format.Font.Color  = pdfStyling.ParagraphSmallColor;
            small.Format.Alignment   = ParagraphAlignment.Left;

            HorizontalRule(pdfStyling, bottom);
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        public IActionResult OnGet(string pdf, int?WIdentity)
        {
            //get the session first!
            UserName  = HttpContext.Session.GetString(SessionKeyName1);
            FirstName = HttpContext.Session.GetString(SessionKeyName2);
            SessionID = HttpContext.Session.GetString(SessionKeyName3);

            if (string.IsNullOrEmpty(UserName) && string.IsNullOrEmpty(FirstName) && string.IsNullOrEmpty(SessionID))
            {
                return(RedirectToPage("/Login/Login"));
            }


            DatabaseConnect dbstring     = new DatabaseConnect();     //creating an object from the class
            string          DbConnection = dbstring.DatabaseString(); //calling the method from the class

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            ExerciseChoice = new List <ChooseExercise>();
            ChooseExercise Choice = new ChooseExercise();

            using (SqlCommand Ecommand = new SqlCommand())
            {
                Ecommand.Connection  = conn;
                Ecommand.CommandText = @"SELECT * FROM Workout WHERE Id=@WIdentity";
                if (pdf != "1")
                {
                    Ecommand.Parameters.AddWithValue("@WIdentity", WIdentity);
                    WID = (int)WIdentity;
                }
                else
                {
                    Ecommand.Parameters.AddWithValue("@WIdentity", WID);
                }
                var ExerciseCheck = Ecommand.ExecuteReader();

                while (ExerciseCheck.Read())
                {
                    Choice.WholeBody = ExerciseCheck.GetString(1);
                    Choice.Arm       = ExerciseCheck.GetString(2);
                    Choice.Leg       = ExerciseCheck.GetString(3);
                    Choice.Back      = ExerciseCheck.GetString(4);
                    Choice.Core      = ExerciseCheck.GetString(5);
                    Choice.Cardio    = ExerciseCheck.GetString(6);
                    ExerciseChoice.Add(Choice);
                }
            }

            using (SqlCommand command = new SqlCommand())
            {
                string[] LetterArray = { "A", "B", "C", "D", "E", "F" };
                command.Connection  = conn;
                command.CommandText = @"";
                int ExerciseCounter = (0);
                if (Choice.WholeBody == "true")
                {
                    command.CommandText = command.CommandText + "SELECT * FROM (SELECT TOP 2 * FROM AllExercises WHERE ExerciseArea ='Whole body' ORDER BY NEWID()) A";
                    ExerciseCounter++;
                }
                if (Choice.Arm == "true")
                {
                    if (ExerciseCounter > 0)
                    {
                        command.CommandText = command.CommandText + " UNION ALL ";
                    }
                    command.CommandText = command.CommandText + "SELECT * FROM (SELECT TOP 2 * FROM AllExercises WHERE ExerciseArea ='Arm' ORDER BY NEWID())";
                    command.CommandText = command.CommandText + " " + LetterArray[ExerciseCounter] + " ";
                    ExerciseCounter++;
                }
                if (Choice.Leg == "true")
                {
                    if (ExerciseCounter > 0)
                    {
                        command.CommandText = command.CommandText + " UNION ALL ";
                    }
                    command.CommandText = command.CommandText + "SELECT * FROM (SELECT TOP 2 * FROM AllExercises WHERE ExerciseArea ='Leg' ORDER BY NEWID())";
                    command.CommandText = command.CommandText + " " + LetterArray[ExerciseCounter] + " ";
                    ExerciseCounter++;
                }
                if (Choice.Back == "true")
                {
                    if (ExerciseCounter > 0)
                    {
                        command.CommandText = command.CommandText + " UNION ALL ";
                    }
                    command.CommandText = command.CommandText + "SELECT * FROM (SELECT TOP 2 * FROM AllExercises WHERE ExerciseArea ='Back' ORDER BY NEWID())";
                    command.CommandText = command.CommandText + " " + LetterArray[ExerciseCounter] + " ";
                    ExerciseCounter++;
                }
                if (Choice.Core == "true")
                {
                    if (ExerciseCounter > 0)
                    {
                        command.CommandText = command.CommandText + " UNION ALL ";
                    }
                    command.CommandText = command.CommandText + "SELECT * FROM (SELECT TOP 2 * FROM AllExercises WHERE ExerciseArea ='Core' ORDER BY NEWID())";
                    command.CommandText = command.CommandText + " " + LetterArray[ExerciseCounter];
                    ExerciseCounter++;
                }
                if (Choice.Cardio == "true")
                {
                    if (ExerciseCounter > 0)
                    {
                        command.CommandText = command.CommandText + " UNION ALL ";
                    }
                    command.CommandText = command.CommandText + "SELECT * FROM (SELECT TOP 2 * FROM AllExercises WHERE ExerciseArea ='Cardio' ORDER BY NEWID())";
                    command.CommandText = command.CommandText + " " + LetterArray[ExerciseCounter] + " ";
                    ExerciseCounter++;
                }
                if (ExerciseCounter == 0)
                {
                    return(RedirectToPage("/UserPages/ChooseWorkout"));
                }

                var reader = command.ExecuteReader();

                Exercise = new List <Exercise>();
                while (reader.Read())
                {
                    Exercise Row = new Exercise(); //each record found from the table
                    Row.ExerciseName        = reader.GetString(1);
                    Row.RepNoTime           = reader.GetString(2);
                    Row.SetNo               = reader.GetString(3);
                    Row.ExerciseDescription = reader.GetString(4);
                    Row.ExerciseArea        = reader.GetString(5); //ExerciseImage not yet included
                    Exercise.Add(Row);
                }

                //PDF code here!
                if (pdf == "1")
                {
                    //Create an object for pdf document
                    Document  doc  = new Document();
                    Section   sec  = doc.AddSection();
                    Paragraph para = sec.AddParagraph();

                    para.Format.Font.Name  = "Arial";
                    para.Format.Font.Size  = 14;
                    para.Format.Font.Color = Color.FromCmyk(0, 0, 0, 100); //black colour
                    para.AddFormattedText("Your Workout", TextFormat.Bold);
                    para.Format.SpaceAfter = "1.0cm";

                    //Adding picture
                    ImageSource.ImageSourceImpl = new ImageSharpImageSource <Rgba32>();
                    Paragraph para2   = sec.AddParagraph();
                    var       picpath = Path.Combine(_env.WebRootPath, "Files", "ExerciseImage.png");
                    var       image   = para2.AddImage(ImageSource.FromFile(picpath));
                    image.Width             = Unit.FromCentimeter(4);
                    para2.Format.SpaceAfter = Unit.FromCentimeter(2);

                    //Table
                    Table tab = new Table();
                    tab.Borders.Width = 0.75;
                    tab.TopPadding    = 5;
                    tab.BottomPadding = 5;

                    //Column
                    Column col = tab.AddColumn(Unit.FromCentimeter(2));
                    col.Format.Alignment = ParagraphAlignment.Justify;
                    tab.AddColumn(Unit.FromCentimeter(3));
                    tab.AddColumn(Unit.FromCentimeter(3));
                    tab.AddColumn(Unit.FromCentimeter(5));
                    tab.AddColumn(Unit.FromCentimeter(3));

                    //Row
                    Row row = tab.AddRow();
                    row.Shading.Color = Colors.Coral;

                    //Cell for header
                    Cell cell = new Cell();
                    cell = row.Cells[0];
                    cell.AddParagraph("Exercise Name");
                    cell = row.Cells[1];
                    cell.AddParagraph("Number/Time of Reps");
                    cell = row.Cells[2];
                    cell.AddParagraph("Number of Sets");
                    cell = row.Cells[3];
                    cell.AddParagraph("Exercise Description");
                    cell = row.Cells[4];
                    cell.AddParagraph("Exercise Area");


                    //Add data to table
                    for (int i = 0; i < Exercise.Count; i++)
                    {
                        row  = tab.AddRow();
                        cell = row.Cells[0];
                        cell.AddParagraph(Exercise[i].ExerciseName);
                        cell = row.Cells[1];
                        cell.AddParagraph(Exercise[i].RepNoTime);
                        cell = row.Cells[2];
                        cell.AddParagraph(Exercise[i].SetNo);
                        cell = row.Cells[3];
                        cell.AddParagraph(Exercise[i].ExerciseDescription);
                        cell = row.Cells[4];
                        cell.AddParagraph(Exercise[i].ExerciseArea);
                    }

                    tab.SetEdge(0, 0, 4, (Exercise.Count + 1), Edge.Box, BorderStyle.Single, 1.5, Colors.Black);
                    sec.Add(tab);

                    //Rendering
                    PdfDocumentRenderer pdfRen = new PdfDocumentRenderer();
                    pdfRen.Document = doc;
                    pdfRen.RenderDocument();

                    //Create 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 = ListofExercises.pdf" });
                    return(File(stream, "application/pdf"));
                }
            }

            return(Page());
        }
Exemplo n.º 27
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();
        }
Exemplo n.º 28
0
 private void AddHospitalLogo(Paragraph p)
 {
     p.AddImage(HospitalLogo.GetMigraDocFileName());
 }
Exemplo n.º 29
0
 private void AddPlanningItemSymbol(Paragraph p, ReportPlanningItem reportPlanningItem)
 {
     p.AddImage(new PlanningItemSymbol(reportPlanningItem).GetMigraDocFileName());
 }
Exemplo n.º 30
0
 private void AddSexSymbol(Paragraph p, Sex sex)
 {
     p.AddImage(new SexSymbol(sex).GetMigraDocFileName());
 }