public PDFHeaderFooter(Configuration Options, string profile)//PDF_Option opt) { // _opt = opt; _options = Options; _profile = profile; Head = LoadFootHead(true); Foot = LoadFootHead(false); bfSun = BaseFont.CreateFont(@"C:\Windows\Fonts\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); }
private PdfPTable onDraw(PdfWriter writer, Document document, Foot_Head options) { fontText = new Font(bfSun, options.FontSize, 0, new BaseColor(options.FtxtColor.Red, options.FtxtColor.Green, options.FtxtColor.Blue)); PdfPTable tab; PdfPCell cell, cell1; options.Txt = options.Txt.Replace(@"\n", "\n"); cell = new PdfPCell(new Phrase(options.Txt, fontText)); cell.Border = Rectangle.NO_BORDER; if (options.PicName.Length > 1) { Image img = iTextSharp.text.Image.GetInstance(options.PicName); img.ScaleAbsoluteHeight(Convert.ToSingle(options.PicHeight)); img.ScaleAbsoluteWidth(Convert.ToSingle(options.PicWidth)); cell1 = new PdfPCell(img); cell1.Border = Rectangle.NO_BORDER; if (options.IsPicFirst) { float[] widths = new float[] { Convert.ToSingle(options.SecondLeftPos + options.PicWidth), Convert.ToSingle(options.FontSize * options.Txt.Length + 30) }; tab = new PdfPTable(2); tab.TotalWidth = options.FontSize * options.Txt.Length + 30 + options.SecondLeftPos + options.PicWidth; tab.SetWidths(widths); tab.AddCell(cell1); tab.AddCell(cell); } else { float[] widths = new float[] { Convert.ToSingle(options.FontSize * options.Txt.Length + 30), Convert.ToSingle(options.SecondLeftPos + options.PicWidth) }; tab = new PdfPTable(2); tab.TotalWidth = options.FontSize * options.Txt.Length + 30 + options.SecondLeftPos + options.PicWidth; tab.SetWidths(widths); tab.AddCell(cell1); tab.AddCell(cell); //tab.AddCell(cell); tab.AddCell(cell1); } } else { tab = new PdfPTable(1); // float[] width = new float[] { document.PageSize.Width - 20 }; tab.TotalWidth = document.PageSize.Width - 40; tab.SetWidths(new float[] { tab.TotalWidth }); tab.AddCell(cell); } return(tab); }
public Foot_Head LoadFootHead(bool isHead) { Foot_Head opt = new Foot_Head(isHead, _options, _profile); return(opt); }