public void drawCheckBoxAppearences(PdfFormField field, string value, float llx, float lly, float urx, float ury) { BaseFont font = null; try { font = BaseFont.createFont(BaseFont.ZAPFDINGBATS, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); } catch (Exception e) { throw e; } float size = (ury - lly); PdfContentByte da = new PdfContentByte(writer); da.setFontAndSize(font, size); da.resetRGBColorFill(); field.DefaultAppearancestring = da; PdfContentByte cb = writer.DirectContent; cb.moveTo(0, 0); PdfAppearance tpOn = cb.createAppearance(urx - llx, ury - lly); tpOn.drawTextField(0f, 0f, urx - llx, ury - lly); tpOn.saveState(); tpOn.resetRGBColorFill(); tpOn.beginText(); tpOn.setFontAndSize(font, size); tpOn.showTextAligned(PdfContentByte.ALIGN_CENTER, "4", (urx - llx) / 2, (ury - lly) / 2 - (size * 0.3f), 0); tpOn.endText(); tpOn.restoreState(); field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, value, tpOn); PdfAppearance tpOff = cb.createAppearance(urx - llx, ury - lly); tpOff.drawTextField(0f, 0f, urx - llx, ury - lly); field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", tpOff); }
/** Creates new Barcode128 */ public Barcode128() { try { x = 0.8f; font = BaseFont.createFont("Helvetica", "winansi", false); size = 8; baseline = size; barHeight = size * 3; textAlignment = Element.ALIGN_CENTER; codeType = CODE128; } catch (Exception e) { throw e; } }
/** Creates new BarcodeEAN */ public BarcodeEAN() { try { x = 0.8f; font = BaseFont.createFont("Helvetica", "winansi", false); size = 8; baseline = size; barHeight = size * 3; guardBars = true; codeType = EAN13; code = ""; } catch (Exception e) { throw e; } }
/** Creates new BarcodeInter25 */ public BarcodeInter25() { try { x = 0.8f; n = 2; font = BaseFont.createFont("Helvetica", "winansi", false); size = 8; baseline = size; barHeight = size * 3; textAlignment = Element.ALIGN_CENTER; generateChecksum = false; checksumText = false; } catch (Exception e) { throw e; } }
/** * Returns a BaseFont which can be used to represent the given NET Font * * @param font the font to be converted * @return a BaseFont which has similar properties to the provided Font */ public BaseFont netToPdf(System.Drawing.Font font) { try { BaseFontParameters p = getBaseFontParameters(font.Name); if (p != null) { return(BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb)); } string fontKey = null; string logicalName = font.Name; if (logicalName.Equals("DialogInput") || (logicalName.Equals("Monospaced"))) { if (font.Italic) { if (font.Bold) { fontKey = BaseFont.COURIER_BOLDOBLIQUE; } else { fontKey = BaseFont.COURIER_OBLIQUE; } } else { if (font.Bold) { fontKey = BaseFont.COURIER_BOLD; } else { fontKey = BaseFont.COURIER; } } } else if (logicalName.Equals("Serif")) { if (font.Italic) { if (font.Bold) { fontKey = BaseFont.TIMES_BOLDITALIC; } else { fontKey = BaseFont.TIMES_ITALIC; } } else { if (font.Bold) { fontKey = BaseFont.TIMES_BOLD; } else { fontKey = BaseFont.TIMES_ROMAN; } } } else // default, this catches Dialog and SansSerif { if (font.Italic) { if (font.Bold) { fontKey = BaseFont.HELVETICA_BOLDOBLIQUE; } else { fontKey = BaseFont.HELVETICA_OBLIQUE; } } else { if (font.Bold) { fontKey = BaseFont.HELVETICA_BOLD; } else { fontKey = BaseFont.HELVETICA; } } } return(BaseFont.createFont(fontKey, BaseFont.CP1252, false)); } catch (Exception e) { throw e; } }
// constructors /** * Constructs a new <CODE>PdfFont</CODE>-object. * * @param name name of the font * @param f the base 14 type * @param s value of the size * @param e value of the encodingtype */ internal PdfFont(string name, int f, float s, int e) { string fontName = BaseFont.HELVETICA; size = s; switch (f) { case COURIER: fontName = BaseFont.COURIER; break; case COURIER_BOLD: fontName = BaseFont.COURIER_BOLD; break; case COURIER_OBLIQUE: fontName = BaseFont.COURIER_OBLIQUE; break; case COURIER_BOLDOBLIQUE: fontName = BaseFont.COURIER_BOLDOBLIQUE; break; case HELVETICA: fontName = BaseFont.HELVETICA; break; case HELVETICA_BOLD: fontName = BaseFont.HELVETICA_BOLD; break; case HELVETICA_OBLIQUE: fontName = BaseFont.HELVETICA_OBLIQUE; break; case HELVETICA_BOLDOBLIQUE: fontName = BaseFont.HELVETICA_BOLDOBLIQUE; break; case SYMBOL: fontName = BaseFont.SYMBOL; break; case TIMES_ROMAN: fontName = BaseFont.TIMES_ROMAN; break; case TIMES_BOLD: fontName = BaseFont.TIMES_BOLD; break; case TIMES_ITALIC: fontName = BaseFont.TIMES_ITALIC; break; case TIMES_BOLDITALIC: fontName = BaseFont.TIMES_BOLDITALIC; break; case ZAPFDINGBATS: fontName = BaseFont.ZAPFDINGBATS; break; } try { font = BaseFont.createFont(fontName, BaseFont.WINANSI, false); } catch (Exception ee) { throw ee; } }
/** * Creates a new Barcode. * * @param ttf the ttf file representing the barcode font * @param size the size of the barcode * @param number the number you want to convert to a barcode in string format */ public PdfBarcode(string ttf, int type, int size, string number) : base(convertToCode(type, number), new iTextSharp.text.Font(BaseFont.createFont(ttf, "winansi", true), size)) { }