当前位置: 首页>>代码示例>>C#>>正文


C# DocumentBuilder.MoveToField方法代码示例

本文整理汇总了C#中DocumentBuilder.MoveToField方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.MoveToField方法的具体用法?C# DocumentBuilder.MoveToField怎么用?C# DocumentBuilder.MoveToField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentBuilder的用法示例。


在下文中一共展示了DocumentBuilder.MoveToField方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MailMerge_MergeField

        private void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)
        {
            #region 處理照片
            if (e.FieldName == "照片")
            {
                DocumentBuilder builder1 = new DocumentBuilder(e.Document);
                builder1.MoveToField(e.Field, true);

                byte[] photoBytes = null;
                try
                {
                    photoBytes = Convert.FromBase64String("" + e.FieldValue);
                }
                catch (Exception ex)
                {
                    //builder1.Write("照片粘貼處");
                    e.Field.Remove();
                    return;
                }

                if (photoBytes == null || photoBytes.Length == 0)
                {
                    //builder1.Write("照片粘貼處");
                    e.Field.Remove();
                    return;
                }

                e.Field.Remove();

                Shape photoShape = new Shape(e.Document, ShapeType.Image);
                photoShape.ImageData.SetImage(photoBytes);
                photoShape.WrapType = WrapType.Inline;

                #region AutoResize

                double origHWRate = photoShape.ImageData.ImageSize.HeightPoints / photoShape.ImageData.ImageSize.WidthPoints;
                double shapeHeight = (builder1.CurrentParagraph.ParentNode.ParentNode as Row).RowFormat.Height;
                double shapeWidth = (builder1.CurrentParagraph.ParentNode as Cell).CellFormat.Width;
                if ((shapeHeight / shapeWidth) < origHWRate)
                    shapeWidth = shapeHeight / origHWRate;
                else
                    shapeHeight = shapeWidth * origHWRate;

                #endregion

                photoShape.Height = shapeHeight * 0.9;
                photoShape.Width = shapeWidth * 0.9;

                builder1.InsertNode(photoShape);
            }
            #endregion
        }
开发者ID:ChunTaiChen,项目名称:KaoHsiung.StudentRecordReport,代码行数:52,代码来源:StudentBasicInfo.cs

示例2: MailMerge_MergeField

        private void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)
        {
            #region 本學期應修及格方可畢業之科目及學分
            //13字數12號,14字數11號,15字數10號
            if (e.FieldName.IndexOf("本學期必修科目") >= 0)
            {
                DocumentBuilder builder = new DocumentBuilder(e.Document);
                builder.MoveToField(e.Field, true);
                string dn = e.FieldValue + "";
                e.Field.Remove();

                //builder.Font.Size = (dn.Length <= 10) ? 12 : (12 - (dn.Length - 10));
                Aspose.Words.Cell SCell = (Aspose.Words.Cell)builder.CurrentParagraph.ParentNode;
                Paragraph p = SCell.FirstParagraph;
                var par = SCell.FirstParagraph;
                var run = new Run(e.Document);
                run.Text = dn;
                run.Font.Name = "標楷體";
                if (dn.Length > 10)
                {
                    par.ParagraphFormat.Alignment = ParagraphAlignment.Distributed;
                    run.Font.Size = (dn.Length <= 13) ? 12 : (12 - (dn.Length - 13));
                }
                par.Runs.Add(run);

                //  以下的寫法皆為無效
                //SCell.CellFormat.ClearFormatting();
                //Aspose.Words.Style style = null;
                //if (e.Document.Styles["MyStyle1"] == null)
                //    style = e.Document.Styles.Add(StyleType.Paragraph, "MyStyle1");
                //else
                //    style = e.Document.Styles["MyStyle1"];
                //style.ParagraphFormat.Alignment = ParagraphAlignment.Distributed;
                //style.ParagraphFormat.KeepTogether = true;

                //p.ParagraphFormat.Style = style;
                //builder.Write(e.FieldValue + "");

                //string dn = e.FieldValue as string;
                //builder.Write(dn);
                //SCell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Distributed | ParagraphAlignment.Left;
                //SCell.CellFormat.WrapText = false;
                //builder.CellFormat.FitText = true;
                //builder.CellFormat.WrapText = false;
                //SCell.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(198, 217, 241);
            }
            #endregion
        }
开发者ID:jungfengpaulwang,项目名称:EMBACore,代码行数:48,代码来源:GraduationAuditReport.cs

示例3: MailMerge_MergeField

        private static void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)
        {
            if (string.IsNullOrEmpty(e.FieldValue + ""))
                e.Field.Remove();

            if (e.FieldValue is Image)
            {
                DocumentBuilder builder = new DocumentBuilder(e.Document);
                builder.MoveToField(e.Field, false);
                double width1 = (builder.CurrentParagraph.ParentNode as Aspose.Words.Cell).CellFormat.Width;
                double width2 = (e.FieldValue as Image).Width / 6;
                double width = Math.Min(width1, width2);
                builder.InsertImage(e.FieldValue as Image, width, 40);
                e.Field.Remove();
            }
        }
开发者ID:kobeaaron110,项目名称:mdhs,代码行数:16,代码来源:ReceiptDocument.cs

示例4: MailMerge_MergeField

        void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)
        {
            if (e.FieldName == "入學照片" || e.FieldName == "入學照片2" ||e.FieldName == "畢業照片" || e.FieldName == "畢業照片2")
            {
                if (e.FieldValue != null && e.FieldValue.ToString()!="")
                {
                    byte[] photo = Convert.FromBase64String(e.FieldValue.ToString()); //e.FieldValue as byte[];

                    if (photo != null && photo.Length > 0)
                    {
                        DocumentBuilder photoBuilder = new DocumentBuilder(e.Document);
                        photoBuilder.MoveToField(e.Field, true);
                        e.Field.Remove();
                        Shape photoShape = new Shape(e.Document, ShapeType.Image);
                        photoShape.ImageData.SetImage(photo);
                        photoShape.WrapType = WrapType.Inline;
                        Cell cell = photoBuilder.CurrentParagraph.ParentNode as Cell;
                        //cell.CellFormat.LeftPadding = 0;
                        //cell.CellFormat.RightPadding = 0;
                        if (e.FieldName == "入學照片" || e.FieldName == "畢業照片")
                        {
                            // 1吋
                            photoShape.Width = ConvertUtil.MillimeterToPoint(25);
                            photoShape.Height = ConvertUtil.MillimeterToPoint(35);
                        }
                        else
                        {
                            //2吋
                            photoShape.Width = ConvertUtil.MillimeterToPoint(35);
                            photoShape.Height = ConvertUtil.MillimeterToPoint(45);
                        }
                        photoBuilder.InsertNode(photoShape);
                    }
                }
            }
        }
开发者ID:ChunTaiChen,项目名称:Counsel_System,代码行数:36,代码来源:StudABCardReportForm.cs

示例5: MailMerge_MergeField

        //最好這程式有人能維護的了.......
        private void MailMerge_MergeField(object sender, MergeFieldEventArgs e)
        {
            //不是 Fix 開頭的合併欄位不處理。
            if (!e.FieldName.ToUpper().StartsWith("Fix".ToUpper())) return;

            DocumentBuilder builder = new DocumentBuilder(e.Document);

            ReportStudent student = e.FieldValue as ReportStudent;

            //如果合併值不是 ReportStudent 就跳過...意思是有問題...。
            if (student == null) return;

            builder.MoveToField(e.Field, true);
            e.Field.Remove();

            if (e.FieldName == "Fix:科目資訊")
            {
                #region 列印年級學期資訊(有點複雜)。
                SemesterDataCollection semses = student.SHistory.GetGradeYearSemester();
                //Row SemesterRow = builder.CurrentParagraph.ParentNode.ParentNode.NextSibling as Row; //下一個 Row。
                //Paragraph originParagraph = builder.CurrentParagraph;

                int count = 0;//, offset = 1;

                foreach (SemesterData each in semses)
                {
                    //string currentGradeyear = Util.GetGradeyearString(each.GradeYear.ToString());

                    ////如果沒有年級,就跳過。
                    //if (string.IsNullOrEmpty(currentGradeyear)) continue;

                    //builder.Write(currentGradeyear + "年級");
                    Paragraph nextPh = Util.NextCell(builder.CurrentParagraph);
                    if (nextPh == null) break; //沒有下一個 Cell ,就不印資料了。
                    builder.MoveTo(nextPh);

                    //Paragraph resetParagraph = builder.CurrentParagraph;
                    //SemesterRow.Cells[count + offset].Write(builder, GetSemesterString(each));

                    SemesterData semester = new SemesterData(0, each.SchoolYear, each.Semester);
                    if (!student.HeaderList.ContainsKey(semester))
                        student.HeaderList.AddRaw(each, count); //不要懷疑,這是對的。

                    //builder.MoveTo(resetParagraph);
                    count++;
                }

                //builder.MoveTo(originParagraph);
                //Paragraph nextParagrap = originParagraph;
                //string previousGradeyear = GetText(originParagraph);
                //while ((nextParagrap = Util.NextCell(nextParagrap)) != null)
                //{
                //    if (GetText(nextParagrap) == previousGradeyear)
                //        (nextParagrap.ParentNode as Cell).CellFormat.HorizontalMerge = CellMerge.Previous;

                //    previousGradeyear = GetText(nextParagrap);
                //}
                #endregion

                #region 列印科目資料(爆炸複雜)

                Row template = builder.CurrentParagraph.ParentNode.ParentNode as Row;
                Table table = template.ParentNode as Table;

                if (PrintSetting.ListMethod == ListMethod.DomainOnly)
                    PrintDomainOnly(builder, student, template, table);
                else
                    PrintSubjectOnly(builder, student, template, table);

                //設定表格下方線寬。
                double borderWidth = (template.NextSibling as Row).Cells[0].CellFormat.Borders.Bottom.LineWidth;
                foreach (Cell each in (template.PreviousSibling as Row).Cells)
                    each.CellFormat.Borders.Bottom.LineWidth = borderWidth;

                template.NextSibling.Remove();
                template.Remove();
                #endregion
            }
            if (e.FieldName == "Fix:照片")
            {
                if (student.GraduatePhoto != null)
                {
                    Shape photo = builder.InsertImage(student.GraduatePhoto);
                    Cell cell = builder.CurrentParagraph.ParentNode as Cell;
                    Row row = cell.ParentRow;

                    double rectHeight = row.RowFormat.Height, rectWidth = cell.CellFormat.Width;

                    double heightRate = (rectHeight / photo.Height);
                    double widthRate = (rectWidth / photo.Width);
                    double rate = 0;
                    if (heightRate < widthRate)
                        rate = heightRate;
                    else
                        rate = widthRate;

                    photo.Width = photo.Width * rate;
                    photo.Height = photo.Height * rate;
                }
//.........这里部分代码省略.........
开发者ID:ChunTaiChen,项目名称:JointAdmissionModule,代码行数:101,代码来源:ReportEnglish.cs

示例6: MoveToFieldEx

        public void MoveToFieldEx()
        {
            //ExStart
            //ExFor:MoveToField
            //ExId:MoveToFieldEx
            //ExSummary:Shows how to use MoveToField.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "Document.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            Aspose.Words.Fields.Field field = builder.InsertField("MERGEFIELD field");

            builder.MoveToField(field, true);
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:14,代码来源:ExDocumentBuilder.cs

示例7: MoveToFieldEx

        public void MoveToFieldEx()
        {
            //ExStart
            //ExFor:DocumentBuilder.MoveToField
            //ExSummary:Shows how to move document builder's cursor to a specific field.
            Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Document.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            Field field = builder.InsertField("MERGEFIELD field");

            builder.MoveToField(field, true);
            //ExEnd
        }
开发者ID:animaal,项目名称:Aspose_Words_NET,代码行数:13,代码来源:ExDocumentBuilder.cs

示例8: MailMerge_MergeField

        //最好這程式有人能維護的了.......
        private void MailMerge_MergeField(object sender, MergeFieldEventArgs e)
        {
            //不是 Fix 開頭的合併欄位不處理。
            if (!e.FieldName.ToUpper().StartsWith("Fix".ToUpper())) return;

            DocumentBuilder builder = new DocumentBuilder(e.Document);

            ReportStudent student = e.FieldValue as ReportStudent;

            //如果合併值不是 ReportStudent 就跳過...意思是有問題...。
            if (student == null) return;

            builder.MoveToField(e.Field, true);
            e.Field.Remove();

            if (e.FieldName == "Fix:年級學期")
            {
                #region 列印年級學期資訊(有點複雜)。
                SemesterDataCollection semesters = student.SHistory.GetGradeYearSemester().GetSemesters(PrintSetting.PrintSemesters);
                Row SemesterRow = builder.CurrentParagraph.ParentNode.ParentNode.NextSibling as Row; //下一個 Row。
                Paragraph originParagraph = builder.CurrentParagraph;

                int count = 0, offset = 1;

                foreach (SemesterData each in semesters)
                {
                    string currentGradeyear = Util.GetGradeyearString(each.GradeYear.ToString());

                    //如果沒有年級,就跳過。
                    if (string.IsNullOrEmpty(currentGradeyear)) continue;

                    builder.Write(currentGradeyear + "年級");
                    Paragraph nextPh = Util.NextCell(builder.CurrentParagraph);
                    if (nextPh == null) break; //沒有下一個 Cell ,就不印資料了。
                    builder.MoveTo(nextPh);

                    Paragraph resetParagraph = builder.CurrentParagraph;
                    SemesterRow.Cells[count + offset].Write(builder, GetSemesterString(each));

                    SemesterData semester = new SemesterData(0, each.SchoolYear, each.Semester);
                    if (!student.HeaderList.ContainsKey(semester))
                        student.HeaderList.AddRaw(each, count); //不要懷疑,這是對的。

                    builder.MoveTo(resetParagraph);
                    count++;
                }

                builder.MoveTo(originParagraph);
                (originParagraph.ParentNode as Cell).CellFormat.HorizontalMerge = CellMerge.First;
                Paragraph nextParagrap = originParagraph;
                string previousGradeyear = GetText(originParagraph);
                while ((nextParagrap = Util.NextCell(nextParagrap)) != null)
                {
                    if (GetText(nextParagrap) == previousGradeyear && !string.IsNullOrEmpty(previousGradeyear))
                    {
                        (nextParagrap.ParentNode as Cell).CellFormat.HorizontalMerge = CellMerge.Previous;
                        (nextParagrap.ParentNode as Cell).Paragraphs[0].Runs.Clear();
                    }
                    else
                        (nextParagrap.ParentNode as Cell).CellFormat.HorizontalMerge = CellMerge.First;

                    previousGradeyear = GetText(nextParagrap);
                }
                #endregion
            }
            else if (e.FieldName == "Fix:科目資訊")
            {
                #region 列印科目資料(爆炸複雜)

                Row template = builder.CurrentParagraph.ParentNode.ParentNode as Row;
                Table table = template.ParentNode as Table;

                if (PrintSetting.ListMethod == ListMethod.DomainOnly)
                {
                    #region 列印領域
                    UniqueSet<RowHeader> RowIndexs = new UniqueSet<RowHeader>();
                    //Environment.OSVersion.Platform
                    #region 列印 RowHeader
                    foreach (SemesterData semester in student.SHistory.GetGradeYearSemester().GetSemesters(PrintSetting.PrintSemesters))
                    {
                        SemesterData sysems = new SemesterData(0, semester.SchoolYear, semester.Semester);

                        //如果不包含該學期成績資料,就跳過。
                        if (!student.SemestersScore.Contains(sysems)) continue;

                        SemesterScore semsscore = student.SemestersScore[sysems];

                        ////準備彈性課程的科目(要詳列出來)。
                        //foreach (string strSubject in semsscore.Subject)
                        //{
                        //    SemesterSubjectScore subject = semsscore.Subject[strSubject];

                        //    if (DetailDomain.Contains(subject.Domain))
                        //    {
                        //        RefineDomain(subject);

                        //        RowHeader header = new RowHeader(subject.Domain, strSubject);
                        //        header.IsDomain = false;

//.........这里部分代码省略.........
开发者ID:ChunTaiChen,项目名称:JointAdmissionModule,代码行数:101,代码来源:Report.cs

示例9: MailMerge_MergeField

        void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)
        {
            if (e.FieldName == "照片" || e.FieldName == "照片2")
            {
                if (e.FieldValue != null)
                {
                    byte[] photo = Convert.FromBase64String(e.FieldValue.ToString()); //e.FieldValue as byte[];

                    if (photo != null && photo.Length > 0)
                    {
                        DocumentBuilder photoBuilder = new DocumentBuilder(e.Document);
                        photoBuilder.MoveToField(e.Field, true);
                        e.Field.Remove();
                        //Paragraph paragraph = photoBuilder.InsertParagraph();// new Paragraph(e.Document);
                        Shape photoShape = new Shape(e.Document, ShapeType.Image);
                        photoShape.ImageData.SetImage(photo);
                        photoShape.WrapType = WrapType.Inline;
                        //Cell cell = photoBuilder.CurrentParagraph.ParentNode as Cell;
                        //cell.CellFormat.LeftPadding = 0;
                        //cell.CellFormat.RightPadding = 0;
                        if (e.FieldName == "照片")
                        {
                            // 1吋
                            photoShape.Width = ConvertUtil.MillimeterToPoint(25);
                            photoShape.Height = ConvertUtil.MillimeterToPoint(35);
                        }
                        else
                        {
                            //2吋
                            photoShape.Width = ConvertUtil.MillimeterToPoint(35);
                            photoShape.Height = ConvertUtil.MillimeterToPoint(45);
                        }
                        //paragraph.AppendChild(photoShape);
                        photoBuilder.InsertNode(photoShape);
                    }
                }
            }

            if (e.FieldName == "畢業照片" || e.FieldName == "畢業照片2")
            {
                if (e.FieldValue != null)
                {
                    byte[] photo = Convert.FromBase64String(e.FieldValue.ToString()); //e.FieldValue as byte[];

                    if (photo != null && photo.Length > 0)
                    {
                        DocumentBuilder photoBuilder = new DocumentBuilder(e.Document);
                        photoBuilder.MoveToField(e.Field, true);
                        e.Field.Remove();
                        //Paragraph paragraph = photoBuilder.InsertParagraph();// new Paragraph(e.Document);
                        Shape photoShape = new Shape(e.Document, ShapeType.Image);
                        photoShape.ImageData.SetImage(photo);
                        photoShape.WrapType = WrapType.Inline;
                        //Cell cell = photoBuilder.CurrentParagraph.ParentNode as Cell;
                        //cell.CellFormat.LeftPadding = 0;
                        //cell.CellFormat.RightPadding = 0;
                        if (e.FieldName == "畢業照片")
                        {
                            // 1吋
                            photoShape.Width = ConvertUtil.MillimeterToPoint(25);
                            photoShape.Height = ConvertUtil.MillimeterToPoint(35);
                        }
                        else
                        {
                            //2吋
                            photoShape.Width = ConvertUtil.MillimeterToPoint(35);
                            photoShape.Height = ConvertUtil.MillimeterToPoint(45);
                        }
                        //paragraph.AppendChild(photoShape);
                        photoBuilder.InsertNode(photoShape);
                    }
                }
            }

            if (e.FieldName == "條碼")
            {
                DocumentBuilder builder = new DocumentBuilder(e.Document);
                builder.MoveToField(e.Field, true);
                e.Field.Remove();
                BarCodeBuilder bb = new BarCodeBuilder();
                if (e.FieldValue != null && e.FieldValue.ToString() != "")
                {
                    bb.CodeText = e.FieldValue.ToString();
                    bb.SymbologyType = Symbology.Code128;
                    bb.CodeLocation = CodeLocation.None;
                    bb.xDimension = 0.5f;
                    bb.BarHeight = 6.0f;
                    MemoryStream stream = new MemoryStream();
                    bb.Save(stream, ImageFormat.Jpeg);
                    builder.InsertImage(stream);
                }
            }
        }
开发者ID:purpnxu,项目名称:SHSContacts,代码行数:93,代码来源:SHSContactsForm.cs


注:本文中的DocumentBuilder.MoveToField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。