public void HandleEvent(Event @event) { var docEvent = (PdfDocumentEvent)@event; var canvas = new PdfCanvas(docEvent.GetPage()); var pageSize = docEvent.GetPage().GetPageSize(); canvas.BeginText(); try { canvas.SetFontAndSize(PdfFontFactory.CreateFont(iText.IO.Font.Constants.StandardFonts.HELVETICA), 7); } catch (IOException e) { //e.printStackTrace(); } var adresse = PDFCreator.SellerAdress(invoice); if (invoice.PAYEE != null) { adresse = PDFCreator.PayeeAdress(invoice); } var paymentInfo = PDFCreator.PaymentInfo(invoice); var contactInfo = PDFCreator.ContactInfo(invoice); PrintListToCanvas(canvas, adresse, doc.GetLeftMargin(), pageSize.GetBottom() + doc.GetBottomMargin() - 30); PrintListToCanvas(canvas, paymentInfo, 200, 0); PrintListToCanvas(canvas, contactInfo, 200, 0); canvas.EndText().Release(); // var c = new Canvas(canvas, docEvent.GetDocument(), pageSize); }
private void Button_Click(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); if (fileDialog.ShowDialog() == true) { PDFCreator.CreatePDF(XML_Invoice_Mapper.MapToInvoice(fileDialog.FileName)); } }