コード例 #1
0
ファイル: DocxToHtml.cs プロジェクト: mguerrer/Salma
        /// <summary>
        /// Add text box
        /// </summary>
        /// <param name="textBox"></param>
        /// <returns></returns>
        private string AddTextBox(DocumentFormat.OpenXml.Vml.TextBox textBox)
        {
            foreach (OpenXmlElement element in textBox.Elements())
            {
                if (element is TextBoxContent)
                {
                    return(AddTextBoxContent((TextBoxContent)element));
                }
            }

            return("");
        }
コード例 #2
0
ファイル: WordEdit.cs プロジェクト: fialot/CardGenIDE
        public void FillTableCell(int tableIndex, int colIndex, int rowIndex, TextBoxProps tbp)
        {
            Table table = doc.MainDocumentPart.Document.Body.Elements <Table>().ElementAt(tableIndex);

            // Find the second row in the table.
            TableRow row = table.Elements <TableRow>().ElementAt(rowIndex);

            // Find the third cell in the row.
            TableCell cell = row.Elements <TableCell>().ElementAt(colIndex);

            // Find the first paragraph in the table cell.
            Paragraph p = cell.Elements <Paragraph>().First();

            Picture pict = new Picture();

            DocumentFormat.OpenXml.Vml.Shape s = new DocumentFormat.OpenXml.Vml.Shape()
            {
                Style = "position:absolute;top:" + (tbp.y * 3.79).ToString() + ";left:" + (tbp.x * 4).ToString() + ";width:" + (tbp.width * 3.79).ToString() + ";height:" + (tbp.height * 3.79).ToString() + ";margin-left:0pt;margin-top:0pt;rotation:0;v-rotate-letters:true;mso-rotate:90", Filled = false, Stroked = false
            };
            //DocumentFormat.OpenXml.Vml.Shapetype st = new DocumentFormat.OpenXml.Vml.Shapetype();
            //st.

            DocumentFormat.OpenXml.Vml.TextBox tb = new DocumentFormat.OpenXml.Vml.TextBox()
            {
                Inset = "0,0,0,0"
            };
            Paragraph           par = new Paragraph();
            ParagraphProperties paragraphProperties = new ParagraphProperties();
            SpacingBetweenLines spacing             = new SpacingBetweenLines()
            {
                Line = "240", LineRule = LineSpacingRuleValues.Auto, Before = "0", After = "0"
            };

            paragraphProperties.Append(spacing);
            paragraphProperties.Append(new ParagraphStyleId()
            {
                Val = "No Spacing"
            });
            par.Append(paragraphProperties);
            Run           r   = new Run();
            RunProperties rPr = new RunProperties(new RunFonts()
            {
                HighAnsi = tbp.font.Name, Ascii = tbp.font.Name, ComplexScript = tbp.font.Name
            }, new FontSize()
            {
                Val = ((int)(tbp.font.Size * 2)).ToString()
            }, new DocumentFormat.OpenXml.Wordprocessing.Color()
            {
                Val = tbp.color.R.ToString("X2") + tbp.color.G.ToString("X2") + tbp.color.B.ToString("X2")
            });                                                                                                                                                                                                                                                                                                                                                           // fontsize in half-points

            r.PrependChild <RunProperties>(rPr);
            r.Append(new Text(tbp.text));
            par.Append(r);
            TextBoxContent tbc = new TextBoxContent();

            tbc.Append(par);
            tb.Append(tbc);
            s.Append(tb);
            pict.Append(s);
            p.Append(new Run(pict));


            // Set the text for the run.
            //Text t = r.Elements<Text>().First();
            //t.Text = txt;
        }