Example #1
0
 CreateParagraphProperties(WordParagraphProperties paragraphProperties)
 {
     if (paragraphProperties != null)
     {
         ParagraphProperties properties = new ParagraphProperties();
         properties.AppendChild(new Justification()
         {
             Val = paragraphProperties.JustificationValues
         });
         properties.AppendChild(new SpacingBetweenLines
         {
             LineRule = LineSpacingRuleValues.Auto
         });
         properties.AppendChild(new Indentation());
         ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties();
         if (!string.IsNullOrEmpty(paragraphProperties.Size))
         {
             paragraphMarkRunProperties.AppendChild(new FontSize
             {
                 Val = paragraphProperties.Size
             });
         }
         if (paragraphProperties.Bold)
         {
             paragraphMarkRunProperties.AppendChild(new Bold());
         }
         properties.AppendChild(paragraphMarkRunProperties);
         return(properties);
     }
     return(null);
 }
Example #2
0
        private static TableCell SetupCell(HetOwner owner, double widthInCm, double start)
        {
            try
            {
                var tableCell = new TableCell();

                var tableCellProperties = new TableCellProperties();
                tableCellProperties.AppendChild(new TableCellWidth {
                    Width = CentimeterToDxa(widthInCm).ToString(), Type = TableWidthUnitValues.Dxa
                });
                tableCellProperties.AppendChild(new TableCellVerticalAlignment()
                {
                    Val = TableVerticalAlignmentValues.Center
                });
                tableCell.AppendChild(tableCellProperties);

                var paragraphProperties = new ParagraphProperties();

                var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
                paragraphMarkRunProperties.AppendChild(new Color {
                    Val = "000000"
                });
                paragraphMarkRunProperties.AppendChild(new RunFonts {
                    Ascii = "Arial"
                });
                paragraphMarkRunProperties.AppendChild(new FontSize()
                {
                    Val = "13pt"
                });
                paragraphProperties.AppendChild(paragraphMarkRunProperties);

                paragraphProperties.AppendChild(new Justification {
                    Val = JustificationValues.Left
                });
                paragraphProperties.AppendChild(new Indentation {
                    Start = CentimeterToDxa(start).ToString()
                });

                var paragraph = new Paragraph();
                paragraph.AppendChild(paragraphProperties);

                if (owner != null)
                {
                    PopulateParagraph(owner, paragraph);
                }

                tableCell.AppendChild(paragraph);

                return(tableCell);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #3
0
        private static TableCell SetupCell(string text, bool center = false)
        {
            try
            {
                TableCell tableCell = new TableCell();

                TableCellProperties tableCellProperties = new TableCellProperties();

                // border & padding
                TableCellBorders borders = new TableCellBorders();

                TopBorder topBorder = new TopBorder {
                    Val = new EnumValue <BorderValues>(BorderValues.Thick), Color = "A1A2A3"
                };
                borders.AppendChild(topBorder);

                BottomBorder bottomBorder = new BottomBorder {
                    Val = new EnumValue <BorderValues>(BorderValues.Thick), Color = "A1A2A3"
                };
                borders.AppendChild(bottomBorder);

                RightBorder rightBorder = new RightBorder {
                    Val = new EnumValue <BorderValues>(BorderValues.Nil)
                };
                borders.AppendChild(rightBorder);

                LeftBorder leftBorder = new LeftBorder {
                    Val = new EnumValue <BorderValues>(BorderValues.Nil)
                };
                borders.AppendChild(leftBorder);

                TableCellMargin margin    = new TableCellMargin();
                TopMargin       topMargin = new TopMargin()
                {
                    Width = "40"
                };
                BottomMargin bottomMargin = new BottomMargin()
                {
                    Width = "40"
                };
                margin.AppendChild(topMargin);
                margin.AppendChild(bottomMargin);

                tableCellProperties.AppendChild(borders);
                tableCellProperties.AppendChild(margin);

                tableCell.AppendChild(tableCellProperties);

                // add text (with specific formatting)
                Paragraph paragraph = new Paragraph()
                {
                    RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6ED85602", TextId = "77777777"
                };

                ParagraphProperties        paragraphProperties        = new ParagraphProperties();
                ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties();

                paragraphMarkRunProperties.AppendChild(new Color {
                    Val = "000000"
                });
                paragraphMarkRunProperties.AppendChild(new RunFonts {
                    Ascii = "Arial"
                });
                paragraphMarkRunProperties.AppendChild(new FontSize()
                {
                    Val = "7pt"
                });

                Justification justification = new Justification()
                {
                    Val = JustificationValues.Left
                };
                if (center)
                {
                    justification.Val = JustificationValues.Center;
                }

                paragraphProperties.AppendChild(paragraphMarkRunProperties);
                paragraphProperties.AppendChild(justification);
                paragraph.AppendChild(paragraphProperties);

                paragraph.AppendChild(new Text(text));

                // add to table cell
                tableCell.AppendChild(paragraph);

                return(tableCell);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #4
0
        private static TableCell SetupHeaderCell(string text, string width, bool center = false)
        {
            try
            {
                TableCell tableCell = new TableCell();

                TableCellProperties tableCellProperties = new TableCellProperties();
                TableCellWidth      tableCellWidth      = new TableCellWidth()
                {
                    Width = width, Type = TableWidthUnitValues.Dxa
                };
                Shading shading = new Shading()
                {
                    Val = ShadingPatternValues.Clear, Fill = "FFFFFF", Color = "auto"
                };

                // border & padding
                TableCellBorders borders = new TableCellBorders();

                TopBorder topBorder = new TopBorder {
                    Val = new EnumValue <BorderValues>(BorderValues.Thick), Color = "000000"
                };
                borders.AppendChild(topBorder);

                BottomBorder bottomBorder = new BottomBorder {
                    Val = new EnumValue <BorderValues>(BorderValues.Thick), Color = "000000"
                };
                borders.AppendChild(bottomBorder);

                TableCellMargin margin    = new TableCellMargin();
                TopMargin       topMargin = new TopMargin()
                {
                    Width = "40"
                };
                BottomMargin bottomMargin = new BottomMargin()
                {
                    Width = "40"
                };
                margin.AppendChild(topMargin);
                margin.AppendChild(bottomMargin);

                tableCellProperties.AppendChild(tableCellWidth);
                tableCellProperties.AppendChild(shading);
                tableCellProperties.AppendChild(borders);
                tableCellProperties.AppendChild(margin);
                tableCellProperties.AppendChild(new TableCellVerticalAlignment()
                {
                    Val = TableVerticalAlignmentValues.Center
                });

                tableCell.AppendChild(tableCellProperties);

                // add text (with specific formatting)
                Paragraph paragraph = new Paragraph()
                {
                    RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6ED85602", TextId = "77777777"
                };

                ParagraphProperties        paragraphProperties        = new ParagraphProperties();
                ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties();

                paragraphMarkRunProperties.AppendChild(new Color {
                    Val = "000000"
                });
                paragraphMarkRunProperties.AppendChild(new RunFonts {
                    Ascii = "Arial"
                });
                paragraphMarkRunProperties.AppendChild(new FontSize()
                {
                    Val = "8pt"
                });
                paragraphMarkRunProperties.AppendChild(new Bold());

                Justification justification = new Justification()
                {
                    Val = JustificationValues.Left
                };
                if (center)
                {
                    justification.Val = JustificationValues.Center;
                }

                paragraphProperties.AppendChild(paragraphMarkRunProperties);
                paragraphProperties.AppendChild(justification);
                paragraph.AppendChild(paragraphProperties);

                paragraph.AppendChild(new Text(text));

                // add to table cell
                tableCell.AppendChild(paragraph);

                return(tableCell);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }