static void Main(string[] args) { DashedLine line = new DashedLine(); line.Points.Add(new Point { X = 1, Y = 1 }); line.Points.Add(new Point { X = 2, Y = 2 }); line.Points.Add(new Point { X = 3, Y = 3 }); line.Points.Add(new Point { X = 4, Y = 4 }); foreach (Point p in line.Points) { Debug.WriteLine("Point {0}, {1}", p.X, p.Y); } }
private void BtnPrint_Click(object sender, RoutedEventArgs e) { var order = (this.DataContext as OrderViewModel).Order; var salesLines = (this.DataContext as OrderViewModel).SalesLines; byte[] result; using (var memoryStream = new MemoryStream()) { var pdfWriter = new PdfWriter(memoryStream); var pdfDocument = new PdfDocument(pdfWriter); var document = new Document(pdfDocument, new PageSize(270, 500)); // , PageSize.A4, true); document.SetMargins(2, 2, 2, 2); PdfFont sylfaenfont = PdfFontFactory.CreateFont(@"c:\\windows\fonts\Sylfaen.ttf", PdfEncodings.IDENTITY_H); document.SetFont(sylfaenfont); document.Add(new Paragraph("შპს გასგო მოტორსი")); document.Add(new Paragraph(order.Ship_toAddress != null ? order.Ship_toAddress : "")); document.Add(new Paragraph(order.PostingDate.HasValue ? order.PostingDate.Value.ToString("dd/MM/yyyy HH:mm") : "")); document.Add(new Paragraph(order.No_)); document.Add(new LineSeparator(new DashedLine())); Table table = new Table(UnitValue.CreatePercentArray(new float[] { 1, 12, 6 })) .UseAllAvailableWidth(); var count = 0; table.SetBorder(iText.Layout.Borders.Border.NO_BORDER); table.SetFontSize(10); foreach (var l in salesLines) { count++; table.AddCell(new Cell().Add(new Paragraph(count.ToString())).SetBorder(iText.Layout.Borders.Border.NO_BORDER)); var desc = $"{(string.IsNullOrEmpty(l.LargeDescription) ? "" : l.LargeDescription)}"; if (!string.IsNullOrEmpty(l.Service_Provider_Name)) { desc = $"{desc}\n{l.Service_Provider_Name}"; } if (!string.IsNullOrEmpty(l.Customer_Vehicle)) { desc = $"{desc}\n{l.Customer_Vehicle}"; } if (App.Current.User.UserType == PosUserTypes.Shop) { var shelfno = DaoController.Current.GetStockShelfNoByItemId(l.No_); desc = $"{desc}\n{shelfno}"; } table.AddCell(new Cell().Add(new Paragraph(desc)).SetBorder(iText.Layout.Borders.Border.NO_BORDER)); table.AddCell(new Cell().Add(new Paragraph($"{l.Quantity:N0}*{l.UnitPrice:F2}={l.AmountIncludingVAT:F2} ₾").SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT)).SetBorder(iText.Layout.Borders.Border.NO_BORDER).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.RIGHT)); } document.Add(table); DashedLine line = new DashedLine(); document.Add(new LineSeparator(line)); document.Add(new Paragraph($"ჯამი {order.AmountIncludingVat:F2} ₾").SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT).SetFontSize(15).SetBold().SetMarginBottom(20)); document.Close(); result = memoryStream.ToArray(); pdfWebViewer.NavigateToStream(memoryStream); } var fileName = $@"C:\wr\check_{order.No_}_{Guid.NewGuid()}.pdf"; File.WriteAllBytes(fileName, result); if (!string.IsNullOrEmpty(App.Current.PosSetting.Settings_Printers)) { //var pr = ""; //foreach (String printer in PrinterSettings.InstalledPrinters) //{ // pr = printer.ToString(); //} foreach (var printerName in App.Current.PosSetting.Settings_Printers.Split(',').ToList()) { printToPrinter(printerName, fileName); //print1(printerName, fileName); Thread.Sleep(4000); } return; } else { pdfWebViewer.Navigate(fileName); } }