private void pdf_to_epub(save_progress progress, System.Windows.Forms.Form dlg, int c) { try { Pdf pdf; ListViewItem item; string text; Aspose.Pdf.Generator.Section section; Aspose.Pdf.Generator.Image image; string str4; string extension; if (progress != null) { dlg.Invoke(progress, new object[] { 0 }); } string str = new ini_config("config.ini").read_ini("isMerger", "App"); ListView.ListViewItemCollection items = null; int num = 0; if (dlg.Name == "mainDlg") { items = ((mainDlg)dlg).lstFile.Items; num = 0; } else { items = ((mainDlg_A)dlg).lstFile.Items; num = 1; } if (str == "1") { if (c == (items.Count - 1)) { pdf = new Pdf(); for (int i = 0; i < items.Count; i++) { item = items[i]; text = item.SubItems[num].Text; section = pdf.Sections.Add(); image = new Aspose.Pdf.Generator.Image(section); section.Paragraphs.Add(image); image.ImageInfo.File = text; extension = Path.GetExtension(text); if (extension == null) { goto Label_01C8; } if (!(extension == ".jpg")) { if (extension == ".gif") { goto Label_0188; } if (extension == ".bmp") { goto Label_0198; } if (extension == ".png") { goto Label_01A8; } if (extension == ".tiff") { goto Label_01B8; } goto Label_01C8; } image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg; continue; Label_0188: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Gif; continue; Label_0198: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp; continue; Label_01A8: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png; continue; Label_01B8: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff; continue; Label_01C8: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg; } str4 = this.global_config.target_dic + Path.GetFileNameWithoutExtension(this.file_path) + this.get_suffix(); pdf.Save(str4); } goto Label_0366; } pdf = new Pdf(); item = items[c]; text = item.SubItems[num].Text; section = pdf.Sections.Add(); image = new Aspose.Pdf.Generator.Image(section); section.Paragraphs.Add(image); image.ImageInfo.File = text; extension = Path.GetExtension(text); if (extension == null) { goto Label_0329; } if (!(extension == ".jpg")) { if (extension == ".gif") { goto Label_02E9; } if (extension == ".bmp") { goto Label_02F9; } if (extension == ".png") { goto Label_0309; } if (extension == ".tiff") { goto Label_0319; } goto Label_0329; } image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg; goto Label_0339; Label_02E9: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Gif; goto Label_0339; Label_02F9: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp; goto Label_0339; Label_0309: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png; goto Label_0339; Label_0319: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff; goto Label_0339; Label_0329: image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg; Label_0339: str4 = this.global_config.target_dic + Path.GetFileNameWithoutExtension(this.file_path) + this.get_suffix(); pdf.Save(str4); Label_0366: if (progress != null) { dlg.Invoke(progress, new object[] { 100 }); } } catch (Exception) { } }
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); }
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); }