private Envelope GetInputEnvelope(string envelopeName = "") { EnvelopeSize envelopeSize = _envelopeView.RequestEnvelopeSize(envelopeName); Log.Information("Envelope sizes entered: {height} {width}", envelopeSize.Height, envelopeSize.Width); if (envelopeSize.Height < 0) { throw new ArgumentOutOfRangeException("Height"); } if (envelopeSize.Width < 0) { throw new ArgumentOutOfRangeException("Width"); } return(new Envelope(envelopeSize));; }
public static iTextSharp.text.Rectangle GetEnvelopeSize(EnvelopeSize Size) { iTextSharp.text.Rectangle _Rec = new iTextSharp.text.Rectangle(100,100); switch (Size) { case EnvelopeSize.Env10: _Rec = new iTextSharp.text.Rectangle(684, 297); break; case EnvelopeSize.EnvLS: _Rec = new iTextSharp.text.Rectangle(792, 612); break; case EnvelopeSize.EnvTY: _Rec = new iTextSharp.text.Rectangle(414, 288); break; case EnvelopeSize.EnvBD1: _Rec = new iTextSharp.text.Rectangle(522, 369); break; case EnvelopeSize.EnvBD2: _Rec = new iTextSharp.text.Rectangle(486, 333); break; } return _Rec; }
public static void PrintEnvelope(int ProfileId, EnvelopeSize Size, string Sender, string Reciver) { try { if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Report_" + ProfileId.ToString() + ".pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Report_" + ProfileId.ToString() + ".pdf"); } } catch (IOException) { string Proc = GetFileProcessName("Report_" + ProfileId.ToString() + ".pdf"); if (File.Exists(System.Windows.Forms.Application.UserAppDataPath + @"\Report_" + ProfileId.ToString() + ".pdf")) { File.Delete(System.Windows.Forms.Application.UserAppDataPath + @"\Report_" + ProfileId.ToString() + ".pdf"); } } FileStream FS = new FileStream(System.Windows.Forms.Application.UserAppDataPath + @"\Report_" + ProfileId.ToString() + ".pdf", FileMode.CreateNew); var Doc = new iTextSharp.text.Document(GetEnvelopeSize(Size),20,20,20,20); PdfWriter.GetInstance(Doc, FS); Doc.Open(); PdfPTable table = new PdfPTable(5); table.WidthPercentage = 100; PdfPCell pricell = new PdfPCell(new Phrase(Sender, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, int.Parse(Math.Round(Doc.PageSize.Width/41,0).ToString()), iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray)))); pricell.HorizontalAlignment = Element.ALIGN_LEFT; pricell.VerticalAlignment = Element.ALIGN_MIDDLE; pricell.SpaceCharRatio = 4; pricell.PaddingBottom = 3; pricell.Colspan = 2; pricell.FixedHeight = ((Doc.PageSize.Height-40) / 10)*3; table.AddCell(pricell); pricell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray)))); pricell.Border = iTextSharp.text.Rectangle.NO_BORDER; pricell.HorizontalAlignment = Element.ALIGN_RIGHT; pricell.VerticalAlignment = Element.ALIGN_MIDDLE; pricell.PaddingBottom = 3; pricell.Colspan = 3; table.AddCell(pricell); //*******************************Пустой блок pricell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, int.Parse(Math.Round(Doc.PageSize.Width / 41, 0).ToString()), iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray)))); pricell.HorizontalAlignment = Element.ALIGN_LEFT; pricell.VerticalAlignment = Element.ALIGN_TOP; pricell.Border = iTextSharp.text.Rectangle.NO_BORDER; pricell.PaddingBottom = 3; pricell.Colspan = 5; pricell.FixedHeight = ((Doc.PageSize.Height-40) / 10)*4-5; table.AddCell(pricell); //******************************* pricell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray)))); pricell.Border = iTextSharp.text.Rectangle.NO_BORDER; pricell.HorizontalAlignment = Element.ALIGN_RIGHT; pricell.VerticalAlignment = Element.ALIGN_MIDDLE; pricell.PaddingBottom = 3; pricell.Colspan = 3; table.AddCell(pricell); pricell = new PdfPCell(new Phrase(Reciver, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, int.Parse(Math.Round(Doc.PageSize.Width / 41, 0).ToString()), iTextSharp.text.Font.NORMAL, new BaseColor(Color.DimGray)))); pricell.HorizontalAlignment = Element.ALIGN_LEFT; pricell.VerticalAlignment = Element.ALIGN_MIDDLE; pricell.PaddingBottom = 3; pricell.SpaceCharRatio = 4; pricell.Colspan = 2; pricell.FixedHeight = ((Doc.PageSize.Height-40) / 10)*3; table.AddCell(pricell); Doc.Add(table); Doc.Close(); Process.Start(System.Windows.Forms.Application.UserAppDataPath + @"\Report_" + ProfileId.ToString() + ".pdf"); }