///// <summary> ///// Gets the FontDescriptor identified by the specified FontSelector. If no such objects ///// exists, a new FontDescriptor is created and added to the stock. ///// </summary> //public FontDescriptor CreateDescriptor(FontSelector selector) //{ // if (selector == null) // throw new ArgumentNullException("selector"); // FontDescriptor descriptor = this.table[selector] as FontDescriptor; // if (descriptor == null) // { // descriptor = new TrueTypeDescriptor(selector); // this.table.Add(selector, descriptor); // } // return descriptor; //} /// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFont font) { if (font == null) { throw new ArgumentNullException("font"); } FontSelector selector = new FontSelector(font); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { descriptor = new TrueTypeDescriptor(font, font.privateFontCollection); this.table.Add(selector, descriptor); } } } return(descriptor); }
/// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFontFamily family, XFontStyle style) { if (family == null) { throw new ArgumentNullException("family"); } FontSelector selector = new FontSelector(family, style); FontDescriptor descriptor; if (!table.TryGetValue(selector, out descriptor)) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile if (!table.TryGetValue(selector, out descriptor)) { XFont font = new XFont(family.Name, 10, style); descriptor = new OpenTypeDescriptor(font); if (table.ContainsKey(selector)) { GetType(); } else { table.Add(selector, descriptor); } } } } return(descriptor); }
/// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFontFamily family, XFontStyle style) { if (family == null) { throw new ArgumentNullException("family"); } FontSelector selector = new FontSelector(family, style); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { XFont font = new XFont(family.Name, 10, style); descriptor = new TrueTypeDescriptor(font, font.privateFontCollection); if (this.table.ContainsKey(selector)) { GetType(); } else { this.table.Add(selector, descriptor); } } } } return(descriptor); }
private static PdfGrid createHeader(PagesHeaderBuilder header) { var table = new PdfGrid(numColumns: 1) { WidthPercentage = 100, RunDirection = PdfWriter.RUN_DIRECTION_RTL, SpacingAfter = 7 }; var basefont = BaseFont.CreateFont(TestUtils.GetTahomaFontPath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); var gillsans = new iTextSharp.text.Font(basefont, 30, iTextSharp.text.Font.BOLD, new BaseColor(ColorTranslator.FromHtml("#009cde").ToArgb())); FontSelector selector = new FontSelector(); selector.AddFont(gillsans); var title = selector.Process("PayPing"); var pdfCell = new PdfPCell(title) { RunDirection = PdfWriter.RUN_DIRECTION_RTL, BorderWidthLeft = 0, BorderWidthRight = 0, BorderWidthTop = 0, BorderWidthBottom = 1, PaddingBottom = 10, BorderColorBottom = new BaseColor(System.Drawing.Color.LightGray.ToArgb()), HorizontalAlignment = Element.ALIGN_CENTER }; table.AddCell(pdfCell); return(table); }
/// <summary> /// Tries to gets a PdfFont from the font dictionary. /// Returns null if no such PdfFont exists. /// </summary> public PdfFont TryGetFont(string idName) { FontSelector selector = new FontSelector(idName); PdfFont pdfFont; fonts.TryGetValue(selector, out pdfFont); return(pdfFont); }
/// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. Returns null if no /// such objects exists. /// </summary> public FontDescriptor FindDescriptor(FontSelector selector) { if (selector == null) return null; FontDescriptor descriptor = this.table[selector] as FontDescriptor; return descriptor; }
public override bool Equals(object obj) { FontSelector selector = obj as FontSelector; if (obj != null && name == selector.name && style == selector.style) { return(fontType == selector.fontType); } return(false); }
private FontSelector getFontSelector() { var fontSelector = new FontSelector(); foreach (var font in Fonts) { fontSelector.AddFont(font); } return(fontSelector); }
public override bool Equals(object obj) { FontSelector selector = obj as FontSelector; if (obj != null && this.name == selector.name) { return(this.style == selector.style); } return(false); }
/// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. Returns null if no /// such objects exists. /// </summary> public FontDescriptor FindDescriptor(FontSelector selector) { if (selector == null) { return(null); } FontDescriptor descriptor = table[selector] as FontDescriptor; return(descriptor); }
private Anchor getAnchor(FontSelector fontSelector, CellAttributes attributes) { var text = getText(attributes); var url = getUrl(attributes); var anchor = new Anchor(fontSelector.Process(text.ToSafeString())) { Reference = url }; return(anchor); }
public TestCentricMainView() : base("TestCentric") { InitializeComponent(); // View Parameters FontSelector = new FontSelector(this); SplitterPosition = new SplitterPosition(treeSplitter); // UI Elements on main form RunButton = new ButtonElement(runButton); StopButton = new ButtonElement(stopButton); RunSummary = new ControlElement <ExpandingLabel>(runCount); ResultTabs = new TabSelector(resultTabs); // Initialize File Menu Commands FileMenu = new PopupMenu(fileMenu); OpenCommand = new MenuCommand(openMenuItem); CloseCommand = new MenuCommand(closeMenuItem); AddTestFileCommand = new MenuCommand(addTestFileMenuItem); ReloadTestsCommand = new MenuCommand(reloadTestsMenuItem); RuntimeMenu = new PopupMenu(runtimeMenuItem); SelectedRuntime = new CheckedMenuGroup(runtimeMenuItem); RecentFilesMenu = new PopupMenu(recentFilesMenu); ExitCommand = new MenuCommand(exitMenuItem); // Initialize View Menu Commands DisplayFormat = new CheckedMenuGroup(fullGuiMenuItem, miniGuiMenuItem); IncreaseFontCommand = new MenuCommand(increaseFontMenuItem); DecreaseFontCommand = new MenuCommand(decreaseFontMenuItem); ChangeFontCommand = new MenuCommand(fontChangeMenuItem); RestoreFontCommand = new MenuCommand(defaultFontMenuItem); IncreaseFixedFontCommand = new MenuCommand(increaseFixedFontMenuItem); DecreaseFixedFontCommand = new MenuCommand(decreaseFixedFontMenuItem); RestoreFixedFontCommand = new MenuCommand(restoreFixedFontMenuItem); StatusBarCommand = new CheckedMenuItem(statusBarMenuItem); // Initialize Test Menu Commands RunAllCommand = new MenuCommand(runAllMenuItem); RunSelectedCommand = new MenuCommand(runSelectedMenuItem); RunFailedCommand = new MenuCommand(runFailedMenuItem); StopRunCommand = new MenuCommand(stopRunMenuItem); // Initialize Tools Menu Comands ToolsMenu = new PopupMenu(toolsMenu); ProjectEditorCommand = new MenuCommand(projectEditorMenuItem); SaveResultsCommand = new MenuCommand(saveResultsMenuItem); ExtensionsCommand = new MenuCommand(extensionsMenuItem); SettingsCommand = new MenuCommand(settingsMenuItem); TestCentricHelpCommand = new MenuCommand(testCentricHelpMenuItem); NUnitHelpCommand = new MenuCommand(nunitHelpMenuItem); AboutCommand = new MenuCommand(aboutMenuItem); }
private void UI_SubFontSelect_Click(object sender, EventArgs e) { FontSelector.Font = UI_SubFont.Font; if (FontSelector.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { SerializableFont font = new SerializableFont(FontSelector.Font); UI_SubFont.Text = font.SerializeFontAttribute; UI_SubFont.Font = font.FontData; } }
// --------------------------------------------------------------------------- public void Write(Stream stream) { using (ZipFile zip = new ZipFile()) { zip.AddFile(RESOURCE, ""); using (MemoryStream ms = new MemoryStream()) { using (Document document = new Document(PageSize.A4.Rotate())) { // step 2 PdfWriter.GetInstance(document, ms); // step 3 document.Open(); // step 4 fs = new FontSelector(); for (int i = 0; i < FONTS.Length; i++) { fs.AddFont(FontFactory.GetFont( FONTS[i][0], FONTS[i][1], BaseFont.EMBEDDED )); } table = new PdfPTable(3); table.DefaultCell.Padding = 3; table.DefaultCell.UseAscender = true; table.DefaultCell.UseDescender = true; using (XmlReader xr = XmlReader.Create(RESOURCE)) { xr.MoveToContent(); while (xr.Read()) { switch (xr.NodeType) { case XmlNodeType.Element: StartElement(xr); break; case XmlNodeType.Text: buf.Append(xr.Value.Trim()); break; case XmlNodeType.EndElement: EndElement(xr.Name); break; } } } document.Add(table); } zip.AddEntry(RESULT, ms.ToArray()); } zip.Save(stream); } }
public override bool Equals(object obj) { if (obj == null) // removing this can lead to stack overflow { return(false); } FontSelector selector = obj as FontSelector; if (!Equals(selector, null)) { return(name == selector.name && style == selector.style); } return(false); }
public FontSelectorSample() { FontSelector sel = new FontSelector(); sel.PreviewText = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy"; Label preview = new Label("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy"); preview.Ellipsize = EllipsizeMode.End; sel.FontChanged += (sender, e) => preview.Font = sel.SelectedFont; PackStart(sel); PackStart(new HSeparator()); PackStart(preview); }
private void BuildFonts() { const int PAGE = 6; ScrollArea rightArea = new ScrollArea(190, 20, WIDTH - 210, 420, true); Label text = new Label("Chat font:", true, HUE_FONT, 0, FONT); rightArea.Add(text); _fontSelectorChat = new FontSelector() { X = 20 }; rightArea.Add(_fontSelectorChat); Add(rightArea, PAGE); }
//string[][] pdfStandardFonts = //{ // new string[]{"Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic"}, // new string[]{"Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique"}, // new string[]{"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"}, // new string[]{"Symbol", "Symbol", "Symbol", "Symbol"}, // new string[]{"ZapfDingbats", "ZapfDingbats", "ZapfDingbats", "ZapfDingbats"}, //}; #if true /// <summary> /// Gets a PdfFont from a font program. If no PdfFont already exists, a new one is created. /// </summary> public PdfFont GetFont(string idName, byte[] fontData) { FontSelector selector = new FontSelector(idName); PdfFont pdfFont; if (!fonts.TryGetValue(selector, out pdfFont)) { //if (font.Unicode) pdfFont = new PdfType0Font(owner, idName, fontData, false); //else // pdfFont = new PdfTrueTypeFont(this.owner, font); //pdfFont.Document = this.document; Debug.Assert(pdfFont.Owner == owner); fonts[selector] = pdfFont; } return(pdfFont); }
public object GetFontSelectorFromFontName(string s) { FontSelector fs2 = new FontSelector(); int splt = s.IndexOf('/'); if (splt != -1) { fs2.AndroidFontName = s.Substring(0, splt); fs2.AppleFontName = s.Substring(splt + 1); } else { fs2.AndroidFontName = s; fs2.AppleFontName = s; } return(fs2); }
private void BuildFonts() { const int PAGE = 6; ScrollArea rightArea = new ScrollArea(190, 60, 390, 380, true); Label text = new Label("Chat font:", true, 0, 0, 1); rightArea.Add(text); _fontSelectorChat = new FontSelector() { X = 20 }; rightArea.Add(_fontSelectorChat); Add(rightArea, PAGE); }
public Vector3 GetAdvance(object parameters, object font, char c) { //return Vector3.zero; FontSelector fs = font as FontSelector; Parameters cp = parameters as Parameters; if (cp.fixedWidth) { return(new Vector3(1, 0, 0)); } else { Texture2D _texture = new Texture2D(1, 1, TextureFormat.Alpha8, false); _texture.hideFlags = HideFlags.HideInInspector | HideFlags.DontSave; _texture.filterMode = FilterMode.Point; _texture.wrapMode = TextureWrapMode.Clamp; int textureID = _texture.GetNativeTextureID(); SysFont.QueueTexture("" + c, #if UNITY_ANDROID fs.AndroidFontName #else #if UNITY_IPHONE fs.AppleFontName #else ((string)font) #endif #endif , 12, false, //_isBold, false, //_isItalic, SysFont.Alignment.Left, //_alignment, false, 2048, 2048, textureID ); int _textWidthPixels = SysFont.GetTextWidth(textureID); // int _textHeightPixels = SysFont.GetTextHeight(textureID); GameObject.Destroy(_texture); return(new Vector3(_textWidthPixels * cp.scale, 0, 0)); } }
// --------------------------------------------------------------------------- public void Write(Stream stream) { // step 1 using (Document document = new Document(PageSize.A4)) { // step 2 PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 FontSelector selector = new FontSelector(); selector.AddFont(FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12)); selector.AddFont(FontFactory.GetFont( "MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED )); Phrase ph = selector.Process(TEXT); document.Add(new Paragraph(ph)); } }
public FontDescriptor CreateDescriptor(string idName, byte[] fontData) { FontSelector selector = new FontSelector(idName); FontDescriptor descriptor; if (!table.TryGetValue(selector, out descriptor)) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile if (!table.TryGetValue(selector, out descriptor)) { descriptor = new OpenTypeDescriptor(idName, fontData); table.Add(selector, descriptor); } } } return(descriptor); }
public FontDescriptor CreateDescriptor(string idName, byte[] fontData) { FontSelector selector = new FontSelector(idName); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { descriptor = new TrueTypeDescriptor(idName, fontData); this.table.Add(selector, descriptor); } } } return(descriptor); }
///// <summary> ///// Gets the FontDescriptor identified by the specified FontSelector. If no such objects ///// exists, a new FontDescriptor is created and added to the stock. ///// </summary> //public FontDescriptor CreateDescriptor(FontSelector selector) //{ // if (selector == null) // throw new ArgumentNullException("selector"); // FontDescriptor descriptor = this.table[selector] as FontDescriptor; // if (descriptor == null) // { // descriptor = new TrueTypeDescriptor(selector); // this.table.Add(selector, descriptor); // } // return descriptor; //} /// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFont font) { if (font == null) { throw new ArgumentNullException("font"); } FontSelector selector = new FontSelector(font); FontDescriptor descriptor; if (!table.TryGetValue(selector, out descriptor)) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile if (!table.TryGetValue(selector, out descriptor)) { descriptor = new OpenTypeDescriptor(font); table.Add(selector, descriptor); } } } return(descriptor); }
private void DrawPageNumber(Font font) { #if DEBUG //Console.WriteLine("pageNumberBox: " + pageNumberBox.X + ", " + pageNumberBox.Y); #endif PdfReader reader = new PdfReader(stream.ToArray()); MemoryStream _stream = new MemoryStream(); PdfStamper stamper = new PdfStamper(reader, _stream); int currentPage = 1; int totalPage = 0; int drawPage = 1; PDFDrawItextSharp.PDFDrawItextSharp pDraw = (PDFDrawItextSharp.PDFDrawItextSharp)PdfDrawer; FontSelector selector = pDraw.FontSelector(font); foreach (int eachCount in EachPageCount) { if (drawPage == 1) { currentPage = 1; totalPage = eachCount; } else { currentPage = 1; totalPage = eachCount - totalPage; } while (drawPage <= eachCount) { #if DEBUG //Console.WriteLine("PDFTemplateItextSharp.DrawPageNumber: " + currentPage + "/" + totalPage); #endif if (PageNumberBoxes.Count < currentPage) { break; } var pageNumberBox = PageNumberBoxes[currentPage - 1]; Hashtable data = new Hashtable { { "{__PAGE__}", currentPage }, { "{__TOTALPAGE__}", totalPage } }; PdfContentByte cb = stamper.GetOverContent(drawPage); //iTextSharp.text.Phrase phrase = new iTextSharp.text.Chunk(pageNumberBox.GetText(data), font); Phrase phrase = selector.Process(pageNumberBox.GetText(data)); //Console.WriteLine("chunk.Content: " + chunk.Content); //iTextSharp.text.pdf.ColumnText column = new iTextSharp.text.pdf.ColumnText(cb); int align = PDFDrawItextSharpHelper.Align( Helper.GetAttributeValue( "align", pageNumberBox.Attributes, "Left")); //20130610 :: mellorasinxelas :: change to static class //20130721 :: cmwong :: change to PDFDrawItextSharp.DrawString() pDraw.DrawString(cb, phrase, pageNumberBox.X, pageNumberBox.Y, pageNumberBox.Width, align, null); currentPage++; drawPage++; } } stamper.Close(); stream = _stream; }
/// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFontFamily family, XFontStyle style) { if (family == null) throw new ArgumentNullException("family"); FontSelector selector = new FontSelector(family, style); FontDescriptor descriptor; if (!this.table.TryGetValue(selector, out descriptor)) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile if (!this.table.TryGetValue(selector, out descriptor)) { XFont font = new XFont(family.Name, 10, style); descriptor = new OpenTypeDescriptor(font); if (this.table.ContainsKey(selector)) GetType(); else this.table.Add(selector, descriptor); } } } return descriptor; }
public object GetFontSelectorFromFontName(string s) { FontSelector fs2=new FontSelector(); int splt=s.IndexOf('/'); if (splt!=-1) { fs2.AndroidFontName=s.Substring(0,splt); fs2.AppleFontName=s.Substring(splt+1); } else { fs2.AndroidFontName=s; fs2.AppleFontName=s; } return fs2; }
public static string GenerateQuotationPDF(String customerquoteid) { VPCRMSBAL VPCRMSBAL = new VPCRMSBAL(); string path = HttpContext.Current.Server.MapPath("PDF-Files"); // due to static web method Httpcontext is used. string client_alias = HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4); string filename = path + "/Quotation_" + client_alias + "_" + customerquoteid + ".pdf"; // Check file exists on path or not, if exists delete existing instance and create new one always. if (File.Exists(filename)) { File.Delete(filename); } Document document = new Document(PageSize.A4, 12.5f, 12.5f, 12.5f, 12.5f); try { PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create)); document.Open(); FontSelector selector = new FontSelector(); Font f1 = FontFactory.GetFont(FontFactory.TIMES_BOLD, 12); f1.Color = BaseColor.DARK_GRAY; // Header Content font. Font f2 = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16); f1.Color = BaseColor.BLACK; // General Text font. Font f3 = FontFactory.GetFont(FontFactory.TIMES, 12); f3.Color = BaseColor.DARK_GRAY; Paragraph quotelabel = new Paragraph("Sales Quotation", f2); quotelabel.Alignment = Element.ALIGN_RIGHT; document.Add(quotelabel); Paragraph linebreak = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1))); document.Add(linebreak); Paragraph quotedate = new Paragraph("Date: " + DateTime.Today.ToString("dd-MM-yyyy"), f3); quotedate.Alignment = Element.ALIGN_RIGHT; document.Add(quotedate); Paragraph quotenum = new Paragraph("Quotation Number: " + customerquoteid, f3); quotenum.Alignment = Element.ALIGN_RIGHT; document.Add(quotenum); DataTable dt = new DataTable(); dt = VPCRMSBAL.GetCompanyName(Convert.ToDecimal(HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4))); if (dt.Rows.Count > 0) { Paragraph para1 = new Paragraph(dt.Rows[0]["clientname"].ToString().Trim(), f1); para1.Alignment = Element.ALIGN_LEFT; document.Add(para1); Paragraph para1a = new Paragraph(dt.Rows[0]["clientaddress1"].ToString().Trim(), f3); para1.Alignment = Element.ALIGN_LEFT; document.Add(para1a); Paragraph para1b = new Paragraph(dt.Rows[0]["clientcontactno1"].ToString().Trim(), f3); para1b.Alignment = Element.ALIGN_LEFT; document.Add(para1b); para1b.SpacingAfter = 30f; } Paragraph para5 = new Paragraph(); Phrase phrase51 = new Phrase("To, ", f3); para5.SpacingBefore = 50f; para5.Add(phrase51); document.Add(para5); DataTable dataTable = new DataTable(); dataTable = VPCRMSBAL.GetQuotationDetailsbyID(Convert.ToDecimal(customerquoteid)); if (dataTable.Rows.Count > 0) { Paragraph phrase52 = new Paragraph(dataTable.Rows[0]["Customer Name"].ToString().Trim() + ",", f1); document.Add(phrase52); Paragraph phrase53 = new Paragraph(dataTable.Rows[0]["Customer Address Line 1"].ToString().Trim() + ",", f3); document.Add(phrase53); Paragraph phrase54 = new Paragraph(dataTable.Rows[0]["Customer Address Line 2"].ToString().Trim() + ",", f3); document.Add(phrase54); Paragraph phrase55 = new Paragraph(dataTable.Rows[0]["Customer City"].ToString().Trim() + " " + dataTable.Rows[0]["Customer District"].ToString().Trim() + ",", f3); document.Add(phrase55); Paragraph phrase56 = new Paragraph(dataTable.Rows[0]["Customer State"].ToString().Trim() + " " + dataTable.Rows[0]["Customer Country"].ToString().Trim() + ",", f3); document.Add(phrase56); Paragraph phrase57 = new Paragraph(dataTable.Rows[0]["Customer Pincode"].ToString().Trim(), f3); document.Add(phrase57); Paragraph phrase41 = new Paragraph("Dear Sir/Madam,", f3); phrase41.SpacingBefore = 30f; document.Add(phrase41); Paragraph phrase42 = new Paragraph("Please see requested quotation details as per below.", f3); phrase42.SpacingAfter = 30f; document.Add(phrase42); //PdfPTable table = new PdfPTable(dataTable.Columns.Count); PdfPTable table = new PdfPTable(4); table.WidthPercentage = 100; table.SetTotalWidth(new float[] { 100f, 20f, 20f, 20f }); //Set columns names in the pdf file //for (int k = 0; k < dataTable.Columns.Count; k++) //PdfPCell srnocell = new PdfPCell(new Phrase("Sr No")); //srnocell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; //srnocell.VerticalAlignment = PdfPCell.ALIGN_CENTER; //srnocell.BackgroundColor = BaseColor.LIGHT_GRAY; //table.AddCell(srnocell); for (int k = 12; k < dataTable.Columns.Count; k++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Columns[k].ColumnName)); if (k == 12) { cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; } cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; cell.BackgroundColor = BaseColor.LIGHT_GRAY; table.AddCell(cell); } //Add values of DataTable in pdf file for (int i = 0; i < dataTable.Rows.Count; i++) { //for (int j = 0; j < dataTable.Columns.Count; j++) //srnocell = new PdfPCell(new Phrase((i + 1).ToString(), f3)); //srnocell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; //srnocell.VerticalAlignment = PdfPCell.ALIGN_CENTER; //table.AddCell(srnocell); for (int j = 12; j < dataTable.Columns.Count; j++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Rows[i][j].ToString(), f3)); //Align the cell in the center if (j == 12) { cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; } cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; table.AddCell(cell); } } document.Add(table); } Paragraph thanksline = new Paragraph(new Phrase("Thank you for showing interest in us, we look forward for your positive response.", f3)); thanksline.Alignment = Element.ALIGN_LEFT; thanksline.SpacingBefore = 30f; thanksline.SpacingAfter = 50f; document.Add(thanksline); Paragraph signpara = new Paragraph(new Phrase("Authorized Signatory", f3)); signpara.Alignment = Element.ALIGN_RIGHT; signpara.SpacingAfter = 20f; document.Add(signpara); document.Add(linebreak); Paragraph terms1 = new Paragraph(new Phrase("Terms & Conditions", f1)); terms1.Alignment = Element.ALIGN_LEFT; document.Add(terms1); Paragraph terms2 = new Paragraph(new Phrase("1. Prices are exclusive of taxes.", f3)); terms2.Alignment = Element.ALIGN_LEFT; document.Add(terms2); Paragraph terms3 = new Paragraph(new Phrase("2. All shipments of goods/products will be delivered within ___ months.", f3)); terms3.Alignment = Element.ALIGN_LEFT; document.Add(terms3); Paragraph terms4 = new Paragraph(new Phrase("3. If there are any inconsitancies or conflicts between the standard terms & conditions of sales & terms on any applicable agreement, precedence shall be given to standard terms & conditions of Sale unless the parties agree in writing to contrary.", f3)); terms4.Alignment = Element.ALIGN_JUSTIFIED; document.Add(terms4); document.AddAuthor("VPCRMS"); document.AddCreator("VP Consultancy Services"); document.AddTitle("Quotation"); document.Close(); } catch (Exception ex) { ILog logger = log4net.LogManager.GetLogger("ErrorLog"); logger.Error(ex.ToString()); } return(client_alias); }
/// <summary> /// Gets a PdfFont from an XFont. If no PdfFont already exists, a new one is created. /// </summary> public PdfFont GetFont(XFont font) { string fontName = font.Name; FontSelector selector = font.selector; if (selector == null) { selector = new FontSelector(font); font.selector = selector; } PdfFont pdfFont; if (!fonts.TryGetValue(selector, out pdfFont)) { if (font.Unicode) { pdfFont = new PdfType0Font(owner, font, font.IsVertical); } else { pdfFont = new PdfTrueTypeFont(owner, font); } //pdfFont.Document = this.document; Debug.Assert(pdfFont.Owner == owner); fonts[selector] = pdfFont; //if (this.owner.EarlyWrite) //{ // //pdfFont.Close(); delete // //pdfFont.AssignObjID(ref this.document.ObjectID); // BUG: just test code!!!! // //pdfFont.WriteObject(null); //} } return(pdfFont); #if false goto TrueTypeFont; switch (font.Name) { case "Times": case "Times New Roman": std = 0; break; case "Helvetica": std = 1; break; case "Courier": std = 2; break; case "Symbol": std = 3; break; case "ZapfDingbats": std = 4; break; } if (std != -1) { int idx = (int)font.Style & 0x3; string name = pdfStandardFonts[std][idx]; PdfFont pdfFont = GetFont(name); if (pdfFont == null) { pdfFont = new PdfFont(); pdfFont.SubType = "/Type1"; pdfFont.BaseFont = name; pdfFont.DefaultName = string.Format("F{0}", PdfFontTable.fontNumber++); } return(pdfFont); } else { TrueTypeFont: // TrueType font PdfFont pdfFont = new PdfFont(); pdfFont.SubType = "/TrueType"; pdfFont.FirstChar = 0; pdfFont.LastChar = 255; pdfFont.BaseFont = font.Name; pdfFont.DefaultName = string.Format("F{0}", PdfFontTable.fontNumber++); } #endif // TrueType font // PdfFont pdfFont = new PdfFont(); // pdfFont.descriptor = new PdfFontDescriptor((TrueTypeDescriptor)FontDescriptorStock.Global.CreateDescriptor(font)); // pdfFont.SubType = "/TrueType"; // pdfFont.FirstChar = 0; // pdfFont.LastChar = 255; // pdfFont.BaseFont = font.Name; // pdfFont.BaseFont = pdfFont.BaseFont.Replace(" ", ""); // switch (font.Style & (XFontStyle.Bold | XFontStyle.Italic)) // { // case XFontStyle.Bold: // pdfFont.BaseFont += ",Bold"; // break; // // case XFontStyle.Italic: // pdfFont.BaseFont += ",Italic"; // break; // // case XFontStyle.Bold | XFontStyle.Italic: // pdfFont.BaseFont += ",BoldItalic"; // break; // } // pdfFont.descriptor.FontName = pdfFont.BaseFont; // pdfFont.DefaultName = string.Format("F{0}", PdfFontTable.fontNumber++); }
public TTFTextTexturePortion ComputeGlyphBitmap(object parameters, object font, char c) { SysFontTexture tex = new SysFontTexture(); FontSelector fs = (FontSelector)GetFontSelectorFromFontName((string)font); tex.AndroidFontName = fs.AndroidFontName; tex.AppleFontName = fs.AppleFontName; tex.Update(); Texture2D _texture = new Texture2D(1, 1, TextureFormat.Alpha8, false); //Texture2D _texture = new Texture2D(64, 64, TextureFormat.RGBA32, false); _texture.hideFlags = HideFlags.HideInInspector | HideFlags.DontSave; _texture.filterMode = FilterMode.Point; _texture.wrapMode = TextureWrapMode.Clamp; int textureID = _texture.GetNativeTextureID(); SysFont.QueueTexture("" + c, #if UNITY_ANDROID fs.AndroidFontName #else #if UNITY_IPHONE fs.AppleFontName #else ((string)font) #endif #endif , 12, false, //_isBold, false, //_isItalic, SysFont.Alignment.Left, //_alignment, false, 2048, 2048, textureID ); int _textWidthPixels = SysFont.GetTextWidth(textureID); int _textHeightPixels = SysFont.GetTextHeight(textureID); SysFont.UpdateQueuedTexture(textureID); Debug.Log("."); Parameters cp = parameters as Parameters; Material m = null; if (cp != null) { Shader shader = Shader.Find(cp.shaderName); if (shader == null) { shader = Shader.Find("Mobile/Diffuse"); } if (shader == null) { shader = Shader.Find("Diffuse"); } m = new Material(shader); m.color = new Color(cp.red, cp.green, cp.blue, cp.alpha); m.mainTexture = _texture; } else { Shader shader = Shader.Find("SysFont/Unlit Transparent"); if (shader == null) { shader = Shader.Find("Mobile/Diffuse"); } if (shader == null) { shader = Shader.Find("Diffuse"); } m = new Material(shader); m.color = Color.black; m.mainTexture = _texture; } TTFTextTexturePortion p = new TTFTextTexturePortion( m, 0, 0, 1, 1, _textWidthPixels * cp.scale, _textHeightPixels * cp.scale, 0, 0, true ); return(p); }
///// <summary> ///// Gets the FontDescriptor identified by the specified FontSelector. If no such objects ///// exists, a new FontDescriptor is created and added to the stock. ///// </summary> //public FontDescriptor CreateDescriptor(FontSelector selector) //{ // if (selector == null) // throw new ArgumentNullException("selector"); // FontDescriptor descriptor = this.table[selector] as FontDescriptor; // if (descriptor == null) // { // descriptor = new TrueTypeDescriptor(selector); // this.table.Add(selector, descriptor); // } // return descriptor; //} /// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFont font) { if (font == null) throw new ArgumentNullException("font"); FontSelector selector = new FontSelector(font); FontDescriptor descriptor; if (!this.table.TryGetValue(selector, out descriptor)) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile if (!this.table.TryGetValue(selector, out descriptor)) { descriptor = new OpenTypeDescriptor(font); this.table.Add(selector, descriptor); } } } return descriptor; }
public FontDescriptor CreateDescriptor(string idName, byte[] fontData) { FontSelector selector = new FontSelector(idName); FontDescriptor descriptor; if (!this.table.TryGetValue(selector, out descriptor)) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile if (!this.table.TryGetValue(selector, out descriptor)) { descriptor = new OpenTypeDescriptor(idName, fontData); this.table.Add(selector, descriptor); } } } return descriptor; }
//string[][] pdfStandardFonts = //{ // new string[]{"Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic"}, // new string[]{"Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique"}, // new string[]{"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"}, // new string[]{"Symbol", "Symbol", "Symbol", "Symbol"}, // new string[]{"ZapfDingbats", "ZapfDingbats", "ZapfDingbats", "ZapfDingbats"}, //}; #if true /// <summary> /// Gets a PdfFont from a font program. If no PdfFont already exists, a new one is created. /// </summary> public PdfFont GetFont(string idName, byte[] fontData) { PdfFontTable.FontSelector selector = new FontSelector(idName); PdfFont pdfFont; if (!this.fonts.TryGetValue(selector, out pdfFont)) { //if (font.Unicode) pdfFont = new PdfType0Font(this.owner, idName, fontData, false); //else // pdfFont = new PdfTrueTypeFont(this.owner, font); //pdfFont.Document = this.document; Debug.Assert(pdfFont.Owner == this.owner); this.fonts[selector] = pdfFont; } return pdfFont; }
/// <summary> /// Tries to gets a PdfFont from the font dictionary. /// Returns null if no such PdfFont exists. /// </summary> public PdfFont TryGetFont(string idName) { FontSelector selector = new FontSelector(idName); PdfFont pdfFont; this.fonts.TryGetValue(selector, out pdfFont); return pdfFont; }
public void Report1ExportToPdf(DataTable dataTable) { string path = HttpContext.Current.Server.MapPath("PDF-Files"); string filename = path + "/Report1_" + HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4) + ".pdf"; Document document = new Document(new Rectangle(288f, 144f), 30, 20, 20, 20); document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create)); document.Open(); BaseFont header = iTextSharp.text.pdf.BaseFont.CreateFont("C:\\windows\\fonts\\timesbd.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); FontSelector selector = new FontSelector(); Font f1 = FontFactory.GetFont(FontFactory.TIMES_BOLD, 12); f1.Color = BaseColor.MAGENTA; Font f2 = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16); f1.Color = BaseColor.RED; iTextSharp.text.Font fontHeader = new iTextSharp.text.Font(header, 18, iTextSharp.text.Font.BOLD); DataTable dt = new DataTable(); dt = VPCRMSBAL.GetCompanyName(Convert.ToDecimal(HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4))); if (dt.Rows.Count > 0) { Paragraph para1 = new Paragraph(dt.Rows[0]["clientname"].ToString().Trim(), f2); para1.Alignment = Element.ALIGN_CENTER; document.Add(para1); para1.SpacingAfter = 50f; } Paragraph para2 = new Paragraph(); Phrase phrase1 = new Phrase("DAILY SALES STATISTICS", f1); para2.Alignment = Element.ALIGN_LEFT; para2.Add(phrase1); document.Add(para2); Paragraph para3 = new Paragraph(); Phrase phrase2 = new Phrase("Sales Person: "); Phrase phrase3 = new Phrase(HttpContext.Current.Session["UserFirstName"].ToString().Trim() + HttpContext.Current.Session["UserLastName"].ToString().Trim()); para3.Add(phrase2); para3.Add(phrase3); para3.Alignment = Element.ALIGN_RIGHT; para3.SpacingAfter = 50f; document.Add(para3); PdfPTable table = new PdfPTable(dataTable.Columns.Count); table.WidthPercentage = 100; //Set columns names in the pdf file for (int k = 0; k < dataTable.Columns.Count; k++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Columns[k].ColumnName)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; cell.BackgroundColor = new iTextSharp.text.BaseColor(51, 102, 102); table.AddCell(cell); } //Add values of DataTable in pdf file for (int i = 0; i < dataTable.Rows.Count; i++) { for (int j = 0; j < dataTable.Columns.Count; j++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Rows[i][j].ToString())); //Align the cell in the center cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; table.AddCell(cell); } } document.Add(table); document.Close(); } catch (Exception ex) { ILog logger = log4net.LogManager.GetLogger("ErrorLog"); logger.Error(ex.ToString()); HttpContext.Current.Response.Redirect("ErrorPage.aspx"); } }
public FontSelectorSample() { FontSelector sel = new FontSelector(); sel.PreviewText = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy"; Label preview = new Label("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy"); preview.Ellipsize = EllipsizeMode.End; sel.FontChanged += (sender, e) => preview.Font = sel.SelectedFont; PackStart(sel); PackStart(new HSeparator()); PackStart(preview); var lblSystemFont = new Label(); lblSystemFont.Font = Xwt.Drawing.Font.SystemFont; lblSystemFont.Text = lblSystemFont.Font.ToString(); var selectSystemFont = new Button("Select"); selectSystemFont.Clicked += (sender, e) => sel.SelectedFont = Xwt.Drawing.Font.SystemFont; var lblSystemMonospaceFont = new Label(); lblSystemMonospaceFont.Font = Xwt.Drawing.Font.SystemMonospaceFont; lblSystemMonospaceFont.Text = lblSystemMonospaceFont.Font.ToString(); var selectSystemMonospaceFont = new Button("Select"); selectSystemMonospaceFont.Clicked += (sender, e) => sel.SelectedFont = Xwt.Drawing.Font.SystemMonospaceFont; var lblSystemSerifFont = new Label(); lblSystemSerifFont.Font = Xwt.Drawing.Font.SystemSerifFont; lblSystemSerifFont.Text = lblSystemSerifFont.Font.ToString(); var selectSystemSerifFont = new Button("Select"); selectSystemSerifFont.Clicked += (sender, e) => sel.SelectedFont = Xwt.Drawing.Font.SystemSerifFont; var lblSystemSansSerifFont = new Label(); lblSystemSansSerifFont.Font = Xwt.Drawing.Font.SystemSansSerifFont; lblSystemSansSerifFont.Text = lblSystemSansSerifFont.Font.ToString(); var selectSystemSansSerifFont = new Button("Select"); selectSystemSansSerifFont.Clicked += (sender, e) => sel.SelectedFont = Xwt.Drawing.Font.SystemSansSerifFont; var tblSystemFonts = new Table(); tblSystemFonts.Add(new Label("System Font:"), 0, 0); tblSystemFonts.Add(lblSystemFont, 1, 0); tblSystemFonts.Add(selectSystemFont, 2, 0); tblSystemFonts.Add(new Label("System Monospace Font:"), 0, 1); tblSystemFonts.Add(lblSystemMonospaceFont, 1, 1); tblSystemFonts.Add(selectSystemMonospaceFont, 2, 1); tblSystemFonts.Add(new Label("System Serif Font:"), 0, 2); tblSystemFonts.Add(lblSystemSerifFont, 1, 2); tblSystemFonts.Add(selectSystemSerifFont, 2, 2); tblSystemFonts.Add(new Label("System SansSerif Font:"), 0, 3); tblSystemFonts.Add(lblSystemSansSerifFont, 1, 3); tblSystemFonts.Add(selectSystemSansSerifFont, 2, 3); PackStart(new HSeparator()); PackStart(tblSystemFonts); }
/// <summary> /// Gets a PdfFont from an XFont. If no PdfFont already exists, a new one is created. /// </summary> public PdfFont GetFont(XFont font) { string fontName = font.Name; PdfFontTable.FontSelector selector = font.selector; if (selector == null) { selector = new FontSelector(font); font.selector = selector; } PdfFont pdfFont; if (!this.fonts.TryGetValue(selector, out pdfFont)) { if (font.Unicode) pdfFont = new PdfType0Font(this.owner, font, font.IsVertical); else pdfFont = new PdfTrueTypeFont(this.owner, font); //pdfFont.Document = this.document; Debug.Assert(pdfFont.Owner == this.owner); this.fonts[selector] = pdfFont; //if (this.owner.EarlyWrite) //{ // //pdfFont.Close(); delete // //pdfFont.AssignObjID(ref this.document.ObjectID); // BUG: just test code!!!! // //pdfFont.WriteObject(null); //} } return pdfFont; #if false goto TrueTypeFont; switch (font.Name) { case "Times": case "Times New Roman": std = 0; break; case "Helvetica": std = 1; break; case "Courier": std = 2; break; case "Symbol": std = 3; break; case "ZapfDingbats": std = 4; break; } if (std != -1) { int idx = (int)font.Style & 0x3; string name = pdfStandardFonts[std][idx]; PdfFont pdfFont = GetFont(name); if (pdfFont == null) { pdfFont = new PdfFont(); pdfFont.SubType = "/Type1"; pdfFont.BaseFont = name; pdfFont.DefaultName = string.Format("F{0}", PdfFontTable.fontNumber++); } return pdfFont; } else { TrueTypeFont: // TrueType font PdfFont pdfFont = new PdfFont(); pdfFont.SubType = "/TrueType"; pdfFont.FirstChar = 0; pdfFont.LastChar = 255; pdfFont.BaseFont = font.Name; pdfFont.DefaultName = string.Format("F{0}", PdfFontTable.fontNumber++); } #endif // TrueType font // PdfFont pdfFont = new PdfFont(); // pdfFont.descriptor = new PdfFontDescriptor((TrueTypeDescriptor)FontDescriptorStock.Global.CreateDescriptor(font)); // pdfFont.SubType = "/TrueType"; // pdfFont.FirstChar = 0; // pdfFont.LastChar = 255; // pdfFont.BaseFont = font.Name; // pdfFont.BaseFont = pdfFont.BaseFont.Replace(" ", ""); // switch (font.Style & (XFontStyle.Bold | XFontStyle.Italic)) // { // case XFontStyle.Bold: // pdfFont.BaseFont += ",Bold"; // break; // // case XFontStyle.Italic: // pdfFont.BaseFont += ",Italic"; // break; // // case XFontStyle.Bold | XFontStyle.Italic: // pdfFont.BaseFont += ",BoldItalic"; // break; // } // pdfFont.descriptor.FontName = pdfFont.BaseFont; // pdfFont.DefaultName = string.Format("F{0}", PdfFontTable.fontNumber++); }