protected void GridWeb1_RowDoubleClick(object sender, Aspose.Cells.GridWeb.RowColumnEventArgs e)
    {
        string msg = "You just clicked <";
        msg += "Row header: " + (e.Num + 1) + ">";

        GridWeb1.Message = msg;
    }
        protected void AddRow(Aspose.Pdf.Table tblInfo, string strLabel, string strValue)
        {
            try
            {
                //create a new row...
                Aspose.Pdf.Row row = tblInfo.Rows.Add();

                //create a new cell...
                Aspose.Pdf.Cell cellLabel = row.Cells.Add();
                //add value in cell...
                cellLabel.Paragraphs.Add(new TextFragment(strLabel));
                //set font properties...
                cellLabel.DefaultCellTextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Calibri");
                cellLabel.DefaultCellTextState.FontSize = 8;
                cellLabel.DefaultCellTextState.FontStyle = FontStyles.Bold;
                //add new cell in row...
                Aspose.Pdf.Cell cell = row.Cells.Add();
                //add value in the cell...
                cell.Paragraphs.Add(new TextFragment(strValue));
                cell.DefaultCellTextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Calibri");
                cell.DefaultCellTextState.FontSize = 8;

            }
            catch (Exception exp)
            {
                msg.Text = "<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>Exception Occured:" + exp.Message + "</div>";
            }
        }
        // ExEnd:ColumnDoubleClickEvent

        // ExStart:RowDoubleClickEvent
        // Event Handler for RowDoubleClick event
        protected void GridWeb1_RowDoubleClick(object sender, Aspose.Cells.GridWeb.RowColumnEventArgs e)
        {
            // Displaying the number of the row (whose header is double clicked) in GridWeb's Message Box
            string msg = "You just clicked <";
            msg += "Row header: " + (e.Num + 1) + ">";
            GridWeb1.Message = msg;
        }
Example #4
0
        private void PutAdress(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo)
        {
            //create table to add address of the customer
            Table adressTable = new Table();
            adressTable.IsFirstParagraph = true;
            adressTable.ColumnWidths = "60 180 60 180";
            adressTable.DefaultCellTextInfo.FontSize = 10;
            adressTable.DefaultCellTextInfo.LineSpacing = 3;
            adressTable.DefaultCellPadding.Bottom = 3;
            //add this table in the first section/page
            Section section = pdf.Sections[0];
            section.Paragraphs.Add(adressTable);
            //add a new row in the table
            Row row1AdressTable = new Row(adressTable);
            adressTable.Rows.Add(row1AdressTable);
            //add cells and text
            Aspose.Pdf.Generator.TextInfo tf1 = new Aspose.Pdf.Generator.TextInfo();
            tf1.Color = new Aspose.Pdf.Generator.Color(111, 146, 188);
            tf1.FontName = "Helvetica-Bold";

            row1AdressTable.Cells.Add("Bill To:", tf1);
            row1AdressTable.Cells.Add(passengerInfo.Name + "#$NL" +
                passengerInfo.Address + "#$NL" + passengerInfo.Email + "#$NL" +
                passengerInfo.PhoneNumber);

        }
Example #5
0
 protected static void SetMergeAndStyle(Aspose.Cells.Style style, Cells cls, int startRow, int startCol, int rowNumber, int colNumber)
 {
     cls.Merge(startRow, startCol, rowNumber, colNumber);
     for (int i = 0; i < rowNumber; i++)
         for (int j = 0; j < colNumber; j++)
             cls[startRow + i, startCol + j].Style = style;
 }
 // ExStart:CellDoubleClickEvent
 // Event Handler for CellDoubleClick event
 protected void GridWeb1_CellDoubleClick(object sender, Aspose.Cells.GridWeb.CellEventArgs e)
 {
     // Displaying the name of the cell (that is double clicked) in GridWeb's Message Box
     string msg = "You just clicked <";
     msg += "Row: " + (e.Cell.Row + 1) + " Column: " + (e.Cell.Column + 1) + " Cell Name: " + e.Cell.Name + ">";
     GridWeb1.Message = msg;
 }
 // Uses the cell command type bind column to create a link for each row to switch to the form view.
 protected void GridWeb1_CellCommand(object sender, Aspose.Cells.GridWeb.CellEventArgs e)
 {
   if (e.Argument.Equals("VIEWDETAIL"))
   {
     //Show grid form and line no
     GridWebForm2.ShowForm();
     GridWebForm2.LineNumber = e.Cell.Row;
   }
 }
 // Handles the BindingChildView event to set the UnitPrice column.
 protected void GridWeb1_BindingChildView(Aspose.Cells.GridWeb.GridWeb childGrid, Aspose.Cells.GridWeb.Data.WebWorksheet childSheet)
 {
   DataView view = (DataView)childSheet.DataSource;
   if (view.Table.TableName == "Order Details")
   {
     //Set column data type
     childSheet.BindColumns["UnitPrice"].NumberType = NumberType.Currency3;
   }
 }
Example #9
0
 private void RenderConvictToPdf(Convict convict, Aspose.Pdf.Generator.Pdf pdf)
 {
     var section = pdf.Sections.Add();
     RenderPersonInfoToSection(convict, section);
     foreach (var crime in convict.Crimes)
     {
         RenderCrimeInfoToSection(crime,section);
     }
 }
Example #10
0
        private void PutOrder(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo, FlightInfo flightInfo, BookingInfo bookingInfo)
		{
            //ticket for leaving             
            PutSummary(pdf, passengerInfo, bookingInfo, flightInfo, false);

            //ticket for returning
            PutSummary(pdf, passengerInfo, bookingInfo, flightInfo, true);

		}
 private void gridDesktop1_SelectedCellRangeChanged(object sender, Aspose.Cells.GridDesktop.CellRangeEventArgs e)
 {
     // Checking if the range of cells is not empty
     if ((e.CellRange.EndColumn - e.CellRange.StartColumn > 0) ||
                           (e.CellRange.EndRow - e.CellRange.StartRow > 0))
     {
         // Assigning the updated CellRange to global variable
         range = e.CellRange;
     }
 }
        // ExStart:PrintTables
        public static void PrintTables(Workbook workbook, Aspose.Cells.ExternalConnections.ExternalConnection ec)
        {
            // Iterate all the worksheets
            for (int j = 0; j < workbook.Worksheets.Count; j++)
            {
                Worksheet worksheet = workbook.Worksheets[j];

                // Check all the query tables in a worksheet
                for (int k = 0; k < worksheet.QueryTables.Count; k++)
                {
                    Aspose.Cells.QueryTable qt = worksheet.QueryTables[k];

                    // Check if query table is related to this external connection
                    if (ec.Id == qt.ConnectionId
                        && qt.ConnectionId >= 0)
                    {
                        // Print the query table name and print its refersto range
                        Console.WriteLine("querytable " + qt.Name);
                        string n = qt.Name.Replace('+', '_').Replace('=', '_');
                        Name name = workbook.Worksheets.Names["'" + worksheet.Name + "'!" + n];
                        if (name != null)
                        {
                            Range range = name.GetRange();
                            if (range != null)
                            {
                                Console.WriteLine("refersto: " + range.RefersTo);
                            }
                        }
                    }
                }

                // Iterate all the list objects in this worksheet
                for (int k = 0; k < worksheet.ListObjects.Count; k++)
                {
                    ListObject table = worksheet.ListObjects[k];

                    // Check the data source type if it is query table
                    if (table.DataSourceType == Aspose.Cells.Tables.TableDataSourceType.QueryTable)
                    {
                        // Access the query table related to list object
                        QueryTable qt = table.QueryTable;

                        // Check if query table is related to this external connection
                        if (ec.Id == qt.ConnectionId
                        && qt.ConnectionId >= 0)
                        {
                            // Print the query table name and print its refersto range
                            Console.WriteLine("querytable " + qt.Name);
                            Console.WriteLine("Table " + table.DisplayName);
                            Console.WriteLine("refersto: " + worksheet.Name + "!" + CellsHelper.CellIndexToName(table.StartRow, table.StartColumn) + ":" + CellsHelper.CellIndexToName(table.EndRow, table.EndColumn));
                        }
                    }
                }
            }
        }
//ExStart
//ExId:XpsPrint_PrintDocument
//ExSummary:Convert an Aspose.Words document into an XPS stream and print.
        /// <summary>
        /// Sends an Aspose.Words document to a printer using the XpsPrint API.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="printerName"></param>
        /// <param name="jobName">Job name. Can be null.</param>
        /// <param name="isWait">True to wait for the job to complete. False to return immediately after submitting the job.</param>
        /// <exception cref="Exception">Thrown if any error occurs.</exception>
        public static void Print(Aspose.Words.Document document, string printerName, string jobName, bool isWait)
        {
            if (document == null)
                throw new ArgumentNullException("document");

            // Use Aspose.Words to convert the document to XPS and store in a memory stream.
            MemoryStream stream = new MemoryStream();
            document.Save(stream, Aspose.Words.SaveFormat.Xps);
            stream.Position = 0;

            Print(stream, printerName, jobName, isWait);
        }
        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
        }
Example #15
0
 public void AsposeCreateCell(Aspose.Words.DocumentBuilder builder, double width, string text)
 {
     builder.InsertCell();
     builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
     builder.CellFormat.Borders.Color = System.Drawing.Color.Black;
     builder.CellFormat.Width = width;//单元格的宽度
     builder.CellFormat.LeftPadding = 3;//单元格的左内边距
     builder.CellFormat.RightPadding = 3;//单元格的右内边距
     builder.RowFormat.Height = 20;//行高
     builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
     builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
     builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;//水平居中对齐
     builder.Write(text);
 }
Example #16
0
        /// <summary>
        /// 儲存 Excel 報表。
        /// </summary>
        /// <param name="workbook">要儲存的報表物件</param>
        /// <param name="filename">儲存的檔案名稱</param>
        public static void SaveWorkbook(Aspose.Cells.Workbook workbook, string filename)
        {
            string path = CreatePath(filename, ".xls");

            try
            {
                workbook.Save(path);
                OpenFile(path, path);
            }
            catch (Exception ex)
            {
                //MsgBox.Show("儲存失敗" + ex.Message);
            }
        }
Example #17
0
        private void PutOrder(Aspose.Pdf.Generator.Pdf pdf, FlightInfo flightInfo, PassengerInfo passengerInfo, BookingInfo bookingInfo)
        {

            //add customer address at the top       
            PutAdress(pdf, passengerInfo);
            //add order summary
            PutSummary(pdf, passengerInfo, flightInfo);
            //create a table and add order details in row(s)
            Table table = AddTable(pdf);
            AddRow(pdf, table, flightInfo);
            PutAmount(pdf, flightInfo.Fare, 0);
           

        }
Example #18
0
        public static void createFileDownload(string reportTemplate, DataSet reportData, string saveName, Aspose.Words.SaveFormat saveFormat, Aspose.Words.SaveType saveType, HttpResponse Response)
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");

            //Open the template document
            Aspose.Words.Document reportDoc = new Aspose.Words.Document(reportTemplate);

            // Fill the fields in the document with user data.
            reportDoc.MailMerge.ExecuteWithRegions(reportData);

            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            reportDoc.Save(saveName, saveFormat, saveType, Response);
        }
        private static void GetShapeText(Aspose.Diagram.Shape shape)
        {
            // Filter shape text
            if (shape.Text.Value.Text != "")
                text += Regex.Replace(shape.Text.Value.Text, "\\<.*?>", "");

            // For image shapes
            if (shape.Type == TypeValue.Foreign)
                text += (shape.Name);

            // For group shapes
            if (shape.Type == TypeValue.Group)
                foreach (Aspose.Diagram.Shape subshape in shape.Shapes)
                {
                    GetShapeText(subshape);
                }
        }
 // ExStart:AddRectangle
 private static void AddRectangle(Aspose.Pdf.Page page, float x, float y, float width, float height, Aspose.Pdf.Color color, int zindex)
 {
     // Create graph object with dimensions same as specified for Rectangle object
     Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(width, height);
     // Can we change the position of graph instance
     graph.IsChangePosition = false;
     // Set Left coordinate position for Graph instance
     graph.Left = x;
     // Set Top coordinate position for Graph object
     graph.Top = y;
     // Add a rectangle inside the "graph"
     Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(0, 0, width, height);
     // Set rectangle fill color
     rect.GraphInfo.FillColor = color;
     // Color of graph object
     rect.GraphInfo.Color = color;
     // Add rectangle to shapes collection of graph instance
     graph.Shapes.Add(rect);
     // Set Z-Index for rectangle object
     graph.ZIndex = zindex;
     // Add graph to paragraphs collection of page object
     page.Paragraphs.Add(graph);
 }
 protected void AddHeading(Aspose.Pdf.Page page, string strValue, float fontSize, bool IsUnderline)
 {
     try
     {
         //add a empty line in the page...
         page.Paragraphs.Add(new TextFragment(" "));
         //create a new text fragment...
         TextFragment txtHeading1 = new TextFragment(strValue);
         txtHeading1.TextState.FontSize = fontSize;
         txtHeading1.TextState.FontStyle = FontStyles.Bold;
         if (IsUnderline)
         {
             txtHeading1.TextState.Underline = true;
         }
         //add text fragment in the paragraph of the page...
         page.Paragraphs.Add(txtHeading1);
         //add empty line in the page...
         page.Paragraphs.Add(new TextFragment(" "));
     }
     catch (Exception exp)
     {
         msg.Text = "<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>Exception Occured:" + exp.Message + "</div>";
     }
 }
Example #22
0
        private void PutSummary(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo, BookingInfo bookingInfo, FlightInfo flightInfo, bool isReturn)
		{
            //create table structure for the ticket
			Table summaryTable  = new Table();
            Aspose.Pdf.Generator.Color color = new Aspose.Pdf.Generator.Color(111, 146, 188);
			summaryTable.Margin.Top = 20;
			summaryTable.ColumnWidths = "80 80 80 80";
			summaryTable.DefaultCellTextInfo.FontSize = 10;
			summaryTable.DefaultCellPadding.Bottom = summaryTable.DefaultCellPadding.Top = 3;
            summaryTable.Border = new BorderInfo((int)BorderSide.Box, 0.5f ,color);
            summaryTable.BackgroundColor = new Color(173, 202, 225);

            //add table to the PDF page
			Section section = pdf.Sections[0];
			section.Paragraphs.Add(summaryTable);

            //declare temporary variables
            Aspose.Pdf.Generator.TextInfo textInfo = new Aspose.Pdf.Generator.TextInfo();
            Cell tempCell;

            //add logo and barcode images
            Row row1SummaryTable = summaryTable.Rows.Add();
            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            Cell cell1 = new Cell(row1SummaryTable);
            cell1.ColumnsSpan = 2;
            cell1.DefaultCellTextInfo = textInfo;

            Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
            img.ImageInfo.File = path + "\\FlyNowLogoOnly.jpg";
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

            img.ImageInfo.FixWidth = 90;
            img.ImageInfo.FixHeight = 30;
            
            cell1.Paragraphs.Add(img);
            row1SummaryTable.Cells.Add(cell1);

            Cell cell2 = new Cell(row1SummaryTable);
            cell2.ColumnsSpan = 2;
            cell2.DefaultCellTextInfo = textInfo;
            cell2.Alignment = AlignmentType.Right;

            img = new Aspose.Pdf.Generator.Image();
            if(!isReturn)
                 img.ImageInfo.File = path + "\\barcodeleave.jpg";
            else
                img.ImageInfo.File = path + "\\barcodereturn.jpg";
            
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            img.ImageInfo.FixWidth = 160;
            img.ImageInfo.FixHeight = 30;
            
            cell2.Paragraphs.Add(img);
            row1SummaryTable.Cells.Add(cell2);


            Row row2SummaryTable = summaryTable.Rows.Add();
            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Class:", row2SummaryTable, textInfo, true);
            row2SummaryTable.Cells.Add(tempCell);

            //cell2 = new Cell(row2SummaryTable);
            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            tempCell = AddTextToCell("Economy", row2SummaryTable, textInfo, false);
            row2SummaryTable.Cells.Add(tempCell);

            //add emptry cells
            Cell cell3 = new Cell(row2SummaryTable);
            row2SummaryTable.Cells.Add(cell3);
            Cell cell4 = new Cell(row2SummaryTable);
            row2SummaryTable.Cells.Add(cell4);


            //add flight details
            Row row3SummaryTable = summaryTable.Rows.Add();
            
            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Flight:  ", row3SummaryTable, textInfo,true);
            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            
            if(!isReturn)
                tempCell = AddTextToCell(flightInfo.FlightNumberLeave, row3SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.FlightNumberReturn, row3SummaryTable, textInfo, false);

            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Seat Number:  ", row3SummaryTable, textInfo, true);
            row3SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            tempCell = AddTextToCell(passengerInfo.SeatNumber, row3SummaryTable, textInfo, false);
            row3SummaryTable.Cells.Add(tempCell);

            Row row4SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("From:  ", row3SummaryTable, textInfo, true);
            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                tempCell = AddTextToCell(flightInfo.DepartureLocation, row3SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.Destination, row3SummaryTable, textInfo, false);

            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("To:  ", row3SummaryTable, textInfo, true);
            row4SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                tempCell = AddTextToCell(flightInfo.Destination, row3SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.DepartureLocation, row3SummaryTable, textInfo, false);

            row4SummaryTable.Cells.Add(tempCell);


            Row row5SummaryTable = summaryTable.Rows.Add();

            textInfo = SetTextInfo("Times-Roman",9, "Black", true);
            tempCell = AddTextToCell("Departure:", row5SummaryTable, textInfo, true);
            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                 tempCell = AddTextToCell(flightInfo.DepartureDateandTime.ToString(), row5SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.ReturnDateandTime.ToString(), row5SummaryTable, textInfo, false);

            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", true);
            tempCell = AddTextToCell("Arrival:", row5SummaryTable, textInfo, true);
            row5SummaryTable.Cells.Add(tempCell);

            textInfo = SetTextInfo("Times-Roman", 9, "Black", false);
            if(!isReturn)
                 tempCell = AddTextToCell(flightInfo.ArrivalDateandTimeDest.ToString(), row5SummaryTable, textInfo, false);
            else
                tempCell = AddTextToCell(flightInfo.ArrivalDateandTimeBack.ToString(), row5SummaryTable, textInfo, false);

            row5SummaryTable.Cells.Add(tempCell);


            
		}
Example #23
0
        //create a new cell
        private Cell AddTextToCell(string strText, Row currentRow, Aspose.Pdf.Generator.TextInfo textInfo, bool isRightAligned)
        {
            Cell tempCell = new Cell(currentRow);
            Text text = new Text(strText);
            text.TextInfo = textInfo;

            if (isRightAligned)
                text.TextInfo.Alignment = AlignmentType.Right;
            else
                text.TextInfo.Alignment = AlignmentType.Left;

            tempCell.Paragraphs.Add(text);

            return tempCell;
        }
Example #24
0
 /// <summary>
 /// Called when a HeaderFooter node is encountered in the document.
 /// </summary>
 public override VisitorAction VisitHeaderFooterStart(Aspose.Words.HeaderFooter headerFooter)
 {
     // Returning this value from a visitor method causes visiting of this
     // node to stop and move on to visiting the next sibling node.
     // The net effect in this example is that the text of headers and footers
     // is not included in the resulting output.
     return VisitorAction.SkipThisNode;
 }
        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
        }
Example #26
0
        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();
            }
        }
Example #27
0
        private void PutAmount(Aspose.Pdf.Generator.Pdf pdf, float fare, float tax)
        {

            //add total amount for this invoice
            Aspose.Pdf.Generator.Color color = new Aspose.Pdf.Generator.Color(111, 146, 188);

            CultureInfo culture = new CultureInfo("en-US");
            Table amountTable = new Table();
            amountTable.Margin.Top = 20;
            amountTable.Margin.Left = 370;
            amountTable.ColumnWidths = "60 60";
            amountTable.DefaultCellBorder = new BorderInfo((int)BorderSide.Bottom, color);
            amountTable.DefaultCellPadding.Bottom = amountTable.DefaultCellPadding.Top = 5;
            amountTable.DefaultCellTextInfo.FontSize = 10;

            Section section = pdf.Sections[0];
            section.Paragraphs.Add(amountTable);

            Row row1AmountTable = amountTable.Rows.Add();

            Aspose.Pdf.Generator.TextInfo tf1 = new Aspose.Pdf.Generator.TextInfo();
            tf1.FontSize = 10;
            tf1.Color = color;
            tf1.FontName = "Helvetica-Bold";

            row1AmountTable.Cells.Add("Subtotal", tf1);
            row1AmountTable.Cells.Add(fare.ToString("c", culture));

            Row row2AmountTable = amountTable.Rows.Add();

            row2AmountTable.Cells.Add("Tax", tf1);
            row2AmountTable.Cells.Add(tax.ToString("c", culture));

            Row row3AmountTable = amountTable.Rows.Add();

            row3AmountTable.Cells.Add("Total", tf1);
            row3AmountTable.Cells.Add((fare + tax).ToString("c", culture));
        }
Example #28
0
            /// <summary>
            /// Called when a Comment is encountered in the document.
            /// </summary>
            public override VisitorAction VisitCommentStart(Aspose.Words.Comment comment)
            {
                if (isHidden(comment))
                    comment.Remove();

                return VisitorAction.Continue;
            }
Example #29
0
            /// <summary>
            /// Returns true if the node passed is set as hidden, returns false if it is visible.
            /// </summary>
            private bool isHidden(Aspose.Words.Node node)
            {
                if (node is Aspose.Words.Inline)
                {
                    // If the node is Inline then cast it to retrieve the Font property which contains the hidden property
                    Aspose.Words.Inline currentNode = (Aspose.Words.Inline)node;
                    return currentNode.Font.Hidden;
                }
                else if (node.NodeType == NodeType.Paragraph)
                {
                    // If the node is a paragraph cast it to retrieve the ParagraphBreakFont which contains the hidden property
                    Paragraph para = (Paragraph)node;
                    return para.ParagraphBreakFont.Hidden;
                }
                else if (node is ShapeBase)
                {
                    // Node is a shape or groupshape.
                    ShapeBase shape = (ShapeBase)node;
                    return shape.Font.Hidden;
                }
                else if (node is InlineStory)
                {
                    // Node is a comment or footnote.
                    InlineStory inlineStory = (InlineStory)node;
                    return inlineStory.Font.Hidden;
                }

                // A node that is passed to this method which does not contain a hidden property will end up here.
                // By default nodes are not hidden so return false.
                return false;
            }
Example #30
0
        private void PutSummary(Aspose.Pdf.Generator.Pdf pdf, PassengerInfo passengerInfo, FlightInfo flightInfo)
        {
            //create a  table to hold summary of the order
            Table summaryTable = new Table();
            Aspose.Pdf.Generator.Color color = new Aspose.Pdf.Generator.Color(111, 146, 188);
            summaryTable.Margin.Top = 20;
            summaryTable.ColumnWidths = "60 80 80 80 80 80";
            summaryTable.DefaultCellTextInfo.FontSize = 10;
            summaryTable.DefaultCellBorder = new BorderInfo((int)BorderSide.All, color);
            summaryTable.DefaultCellPadding.Bottom = summaryTable.DefaultCellPadding.Top = 3;
            //add table to the first section/page
            Section section = pdf.Sections[0];
            section.Paragraphs.Add(summaryTable);
            //create row and add cells and contents
            Row row1SummaryTable = summaryTable.Rows.Add();

            Aspose.Pdf.Generator.TextInfo tf1 = new Aspose.Pdf.Generator.TextInfo();
            tf1.FontSize = 10;
            tf1.Color = new Aspose.Pdf.Generator.Color("White");
            tf1.FontName = "Helvetica-Bold";
            tf1.Alignment = AlignmentType.Center;
            Cell cell1Row1SummaryTable = row1SummaryTable.Cells.Add("Order ID", tf1);
            cell1Row1SummaryTable.BackgroundColor = color;

            Cell cell2Row1SummaryTable = row1SummaryTable.Cells.Add("Customer ID", tf1);
            cell2Row1SummaryTable.BackgroundColor = color;

            Cell cell3Row1SummaryTable = row1SummaryTable.Cells.Add("Agent ID", tf1);
            cell3Row1SummaryTable.BackgroundColor = color;

            Cell cell4Row1SummaryTable = row1SummaryTable.Cells.Add("Sales Person", tf1);
            cell4Row1SummaryTable.BackgroundColor = color;

            Cell cell5Row1SummaryTable = row1SummaryTable.Cells.Add("Required Date", tf1);
            cell5Row1SummaryTable.BackgroundColor = color;

            Cell cell6Row1SummaryTable = row1SummaryTable.Cells.Add("Shipped Date", tf1);
            cell6Row1SummaryTable.BackgroundColor = color;


            Row row2SummaryTable = summaryTable.Rows.Add();
            tf1 = new Aspose.Pdf.Generator.TextInfo();
            tf1.FontSize = 9;
            tf1.Color = new Aspose.Pdf.Generator.Color("Black");
            tf1.FontName = "Times-Roman";
            tf1.Alignment = AlignmentType.Center;

            row2SummaryTable.Cells.Add("90234", tf1);
            row2SummaryTable.Cells.Add("3762", tf1);
            row2SummaryTable.Cells.Add("AU89", tf1);
            row2SummaryTable.Cells.Add("James Smith", tf1);
            row2SummaryTable.Cells.Add(DateTime.Now.Date.ToString(), tf1);
            row2SummaryTable.Cells.Add(DateTime.Now.Date.ToString(), tf1);

        }