本文整理匯總了Java中com.lowagie.text.Font.NORMAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Font.NORMAL屬性的具體用法?Java Font.NORMAL怎麽用?Java Font.NORMAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.lowagie.text.Font
的用法示例。
在下文中一共展示了Font.NORMAL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createContent
public void createContent(WebInput wi, DocInfo di)throws ControllerException {
Document pdfDoc = di.getPdfDocument();
try {
pdfDoc.add(new Paragraph("Hello World!"));
try {
BaseFont bf = BaseFont.createFont("STSong-Light",
"UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font FontChinese = new Font(bf, 12, Font.NORMAL);
String info=wi.getParameter("info");
Paragraph p0 = new Paragraph(info, FontChinese);
pdfDoc.add(p0);
Paragraph p1 = new Paragraph("Beetle Web Framework 頁麵生成PDF文件演示!", FontChinese);
pdfDoc.add(p1);
} catch (Exception ex1) {
throw new ControllerException(ex1);
}
} catch (DocumentException ex) {
throw new ControllerException(ex);
}
}
示例2: main
/**
* Specifying an encoding.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2: creation of the writer
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("fontencoding.pdf"));
// step 3: we open the document
document.open();
// step 4: we add content to the document
BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
Font font = new Font(helvetica, 12, Font.NORMAL);
Chunk chunk = new Chunk("Sponsor this example and send me 1\u20ac. These are some special characters: \u0152\u0153\u0160\u0161\u0178\u017D\u0192\u02DC\u2020\u2021\u2030", font);
document.add(chunk);
// step 5: we close the document
document.close();
}
示例3: OscarChartPrinter
public OscarChartPrinter(HttpServletRequest request, OutputStream os) throws DocumentException,IOException {
this.request = request;
this.os = os;
document = new Document();
// writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
writer = PdfWriter.getInstance(document,os);
writer.setPageEvent(new EndPage());
document.setPageSize(PageSize.LETTER);
document.open();
//Create the font we are going to print to
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, FONTSIZE, Font.NORMAL);
boldFont = new Font(bf,FONTSIZE,Font.BOLD);
}
示例4: PdfRecordPrinter
public PdfRecordPrinter(HttpServletRequest request, OutputStream os) throws DocumentException,IOException {
this.request = request;
this.os = os;
formatter = new SimpleDateFormat("dd-MMM-yyyy");
//Create the font we are going to print to
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, FONTSIZE, Font.NORMAL);
boldFont = new Font(bf,FONTSIZE,Font.BOLD);
//Create the document we are going to write to
document = new Document();
writer = PdfWriter.getInstance(document,os);
writer.setPageEvent(new EndPage());
writer.setStrictImageSequence(true);
document.setPageSize(PageSize.LETTER);
document.open();
}
示例5: start
public void start() throws DocumentException,IOException {
//Create the font we are going to print to
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, FONTSIZE, Font.NORMAL);
boldFont = new Font(bf,FONTSIZE,Font.BOLD);
//Create the document we are going to write to
document = new Document();
writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
// writer = PdfWriter.getInstance(document,os);
// writer.setPageEvent(new EndPage());
writer.setStrictImageSequence(true);
document.setPageSize(PageSize.LETTER);
document.open();
}
示例6: printPdf
/**
* Prints the consultation request.
* @throws IOException when an error with the output stream occurs
* @throws DocumentException when an error in document construction occurs
*/
public void printPdf(LoggedInInfo loggedInInfo) throws IOException, DocumentException {
// Create the document we are going to write to
document = new Document();
// PdfWriter.getInstance(document, os);
PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
document.setPageSize(PageSize.LETTER);
document.addTitle(getResource("msgConsReq"));
document.addCreator("OSCAR");
document.open();
// Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
headerFont = new Font(bf, 14, Font.BOLD);
infoFont = new Font(bf, 12, Font.NORMAL);
font = new Font(bf, 9, Font.NORMAL);
boldFont = new Font(bf, 10, Font.BOLD);
bigBoldFont = new Font(bf, 12, Font.BOLD);
createConsultationRequest(loggedInInfo);
document.close();
}
示例7: addDynamicPositionedText
private float addDynamicPositionedText(String name, String text, float dynamicHeight, EctConsultationFormRequestUtil reqForm) throws DocumentException {
if (text != null && text.length() > 0){
Font boldFont = new Font(bf, FONTSIZE, Font.BOLD);
Font font = new Font(bf, FONTSIZE, Font.NORMAL);
float lineCount = (name.length() + text.length()) / 100;
// if there is not enough room on the page for the text start on the next page
if ( (height - 264 - dynamicHeight - lineCount*LINEHEIGHT) < LINEHEIGHT*3 ){
nextPage(reqForm);
dynamicHeight = LINEHEIGHT - 152;
}
ct.setSimpleColumn(new Float(85), height - 264 - dynamicHeight - lineCount*LINEHEIGHT, new Float(526), height - 250 - dynamicHeight, LINEHEIGHT, Element.ALIGN_LEFT);
ct.addText(new Phrase(name, boldFont));
ct.addText(new Phrase(text, font));
ct.go();
dynamicHeight += lineCount*LINEHEIGHT + LINEHEIGHT*2;
}
return dynamicHeight;
}
示例8: main
/**
* Demonstrates the use of layers.
*
* @param args
* no arguments needed
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document,
PdfTestBase.getOutputStream("optionalcontent.pdf"));
writer.setPdfVersion(PdfWriter.VERSION_1_5);
writer.setViewerPreferences(PdfWriter.PageModeUseOC);
// step 3: opening the document
document.open();
// step 4: content
PdfContentByte cb = writer.getDirectContent();
Phrase explanation = new Phrase(
"Automatic layers, form fields, images, templates and actions",
new Font(Font.HELVETICA, 18, Font.BOLD, Color.red));
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, explanation, 50,
650, 0);
PdfLayer l1 = new PdfLayer("Layer 1", writer);
PdfLayer l2 = new PdfLayer("Layer 2", writer);
PdfLayer l3 = new PdfLayer("Layer 3", writer);
PdfLayer l4 = new PdfLayer("Form and XObject Layer", writer);
PdfLayerMembership m1 = new PdfLayerMembership(writer);
m1.addMember(l2);
m1.addMember(l3);
Phrase p1 = new Phrase("Text in layer 1");
Phrase p2 = new Phrase("Text in layer 2 or layer 3");
Phrase p3 = new Phrase("Text in layer 3");
cb.beginLayer(l1);
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p1, 50, 600, 0f);
cb.endLayer();
cb.beginLayer(m1);
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p2, 50, 550, 0);
cb.endLayer();
cb.beginLayer(l3);
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, p3, 50, 500, 0);
cb.endLayer();
TextField ff = new TextField(writer, new Rectangle(200, 600, 300, 620),
"field1");
ff.setBorderColor(Color.blue);
ff.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
ff.setBorderWidth(TextField.BORDER_WIDTH_THIN);
ff.setText("I'm a form field");
PdfFormField form = ff.getTextField();
form.setLayer(l4);
writer.addAnnotation(form);
Image img = Image.getInstance(PdfTestBase.RESOURCES_DIR
+ "pngnow.png");
img.setLayer(l4);
img.setAbsolutePosition(200, 550);
cb.addImage(img);
PdfTemplate tp = cb.createTemplate(100, 20);
Phrase pt = new Phrase("I'm a template", new Font(Font.HELVETICA, 12,
Font.NORMAL, Color.magenta));
ColumnText.showTextAligned(tp, Element.ALIGN_LEFT, pt, 0, 0, 0);
tp.setLayer(l4);
tp.setBoundingBox(new Rectangle(0, -10, 100, 20));
cb.addTemplate(tp, 200, 500);
ArrayList<Object> state = new ArrayList<Object>();
state.add("toggle");
state.add(l1);
state.add(l2);
state.add(l3);
state.add(l4);
PdfAction action = PdfAction.setOCGstate(state, true);
Chunk ck = new Chunk("Click here to toggle the layers", new Font(
Font.HELVETICA, 18, Font.NORMAL, Color.yellow)).setBackground(
Color.blue).setAction(action);
ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(ck),
250, 400, 0);
cb.sanityCheck();
// step 5: closing the document
document.close();
}
示例9: start
public void start() throws DocumentException, IOException {
//Create the font we are going to print to
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, FONTSIZE, Font.NORMAL);
boldFont = new Font(bf, FONTSIZE, Font.BOLD);
document = new Document();
writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
writer.setStrictImageSequence(true);
document.setPageSize(PageSize.LETTER);
document.open();
}
示例10: printRtf
public void printRtf()throws IOException, DocumentException{
//create an input stream from the rtf string bytes
byte[] rtfBytes = handler.getOBXResult(0, 0).getBytes();
ByteArrayInputStream rtfStream = new ByteArrayInputStream(rtfBytes);
//create & open the document we are going to write to and its writer
document = new Document();
RtfWriter2 writer = RtfWriter2.getInstance(document,os);
document.setPageSize(PageSize.LETTER);
document.addTitle("Title of the Document");
document.addCreator("OSCAR");
document.open();
//Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, 11, Font.NORMAL);
boldFont = new Font(bf, 12, Font.BOLD);
// redFont = new Font(bf, 11, Font.NORMAL, Color.RED);
//add the patient information
addRtfPatientInfo();
//add the results
writer.importRtfDocument(rtfStream, null);
document.close();
os.flush();
}
示例11: printPdf
public void printPdf() throws IOException, DocumentException{
// check that we have data to print
if (handler == null)
throw new DocumentException();
//response.setContentType("application/pdf"); //octet-stream
//response.setHeader("Content-Disposition", "attachment; filename=\""+handler.getPatientName().replaceAll("\\s", "_")+"_LabReport.pdf\"");
//Create the document we are going to write to
document = new Document();
//PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
// PdfWriter writer = PdfWriter.getInstance(document, os);
PdfWriter writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
//Set page event, function onEndPage will execute each time a page is finished being created
writer.setPageEvent(this);
document.setPageSize(PageSize.LETTER);
document.addTitle("Title of the Document");
document.addCreator("OSCAR");
document.open();
//Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, 9, Font.NORMAL);
boldFont = new Font(bf, 10, Font.BOLD);
// redFont = new Font(bf, 9, Font.NORMAL, Color.RED);
// add the header table containing the patient and lab info to the document
createInfoTable();
// add the tests and test info for each header
ArrayList<String> headers = handler.getHeaders();
for (int i=0; i < headers.size(); i++)
addLabCategory( headers.get(i) ,null);
for(MessageHandler extraHandler:handlers) {
ArrayList<String> extraHeaders = extraHandler.getHeaders();
for (int i=0; i < extraHeaders.size(); i++)
addLabCategory( extraHeaders.get(i) , extraHandler);
}
// add end of report table
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
PdfPCell cell = new PdfPCell();
cell.setBorder(0);
cell.setPhrase(new Phrase(" "));
table.addCell(cell);
cell.setBorder(15);
cell.setBackgroundColor(new Color(210, 212, 255));
cell.setPhrase(new Phrase("END OF REPORT", boldFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
document.add(table);
document.close();
os.flush();
}
示例12: setAppointmentInfo
private void setAppointmentInfo(EctConsultationFormRequestUtil reqForm) throws DocumentException{
printClinicData(reqForm);
Font font = new Font(bf, FONTSIZE, Font.NORMAL);
// Set consultant info
cb.beginText();
cb.setFontAndSize(bf, FONTSIZE);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.referalDate, 190, height - 112, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.urgency.equals("1") ? "Urgent" : (reqForm.urgency.equals("2") ? "Non-Urgent" : "Return"), 190, height - 125, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.getServiceName(reqForm.service), 190, height - 139, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.getSpecailistsName(reqForm.specialist), 190, height - 153, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.specPhone, 190, height - 166, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.specFax, 190, height - 181, 0);
cb.endText();
ct.setSimpleColumn(new Float(190), height - 223, new Float(290), height - 181, LINEHEIGHT, Element.ALIGN_LEFT);
ct.addText(new Phrase(reqForm.specAddr.replaceAll("<br>", "\n"), font));
ct.go();
// Set patient info
cb.beginText();
cb.setFontAndSize(bf, FONTSIZE);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.patientName, 385, height - 112, 0);
cb.endText();
ct.setSimpleColumn(new Float(385), height - 153, new Float(585), height - 112, LINEHEIGHT, Element.ALIGN_LEFT);
ct.addText(new Phrase(reqForm.patientAddress.replaceAll("<br>", " "), font));
ct.go();
cb.beginText();
cb.setFontAndSize(bf, FONTSIZE);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.patientPhone, 385, height - 166, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.patientDOB, 385, height - 181, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, (reqForm.patientHealthCardType+" "+reqForm.patientHealthNum+" "+reqForm.patientHealthCardVersionCode).trim(), 440, height - 195, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.appointmentHour+":"+reqForm.appointmentMinute+" "+reqForm.appointmentPm+" " + reqForm.appointmentDate, 440, height - 208, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, reqForm.patientChartNo, 385, height - 222, 0);
cb.endText();
}
示例13: beforePropertyChange
public void beforePropertyChange(String propertyName) {
// do we have any text to do anything with?
// if not, then just return without action.
if(this.buffer.length() == 0) return;
if(propertyName.startsWith(RtfProperty.CHARACTER)) {
// this is a character change,
// add a new chunk to the current paragraph using current character settings.
Chunk chunk = new Chunk();
chunk.append(this.buffer.toString());
this.buffer = new StringBuffer(255);
HashMap charProperties = this.rtfParser.getState().properties.getProperties(RtfProperty.CHARACTER);
String defFont = (String)charProperties.get(RtfProperty.CHARACTER_FONT);
if(defFont == null) defFont = "0";
RtfDestinationFontTable fontTable = (RtfDestinationFontTable)this.rtfParser.getDestination("fonttbl");
Font currFont = fontTable.getFont(defFont);
int fs = Font.NORMAL;
if(charProperties.containsKey(RtfProperty.CHARACTER_BOLD)) fs |= Font.BOLD;
if(charProperties.containsKey(RtfProperty.CHARACTER_ITALIC)) fs |= Font.ITALIC;
if(charProperties.containsKey(RtfProperty.CHARACTER_UNDERLINE)) fs |= Font.UNDERLINE;
Font useFont = FontFactory.getFont(currFont.getFamilyname(), 12, fs, new Color(0,0,0));
chunk.setFont(useFont);
if(iTextParagraph == null) this.iTextParagraph = new Paragraph();
this.iTextParagraph.add(chunk);
} else {
if(propertyName.startsWith(RtfProperty.PARAGRAPH)) {
// this is a paragraph change. what do we do?
} else {
if(propertyName.startsWith(RtfProperty.SECTION)) {
} else {
if(propertyName.startsWith(RtfProperty.DOCUMENT)) {
}
}
}
}
}
示例14: write
/**
* Writes the representation of a <CODE>Font</CODE>.
*
* @param font a <CODE>Font</CODE>
* @param styleAttributes the style of the font
* @throws IOException
*/
protected void write(Font font, Properties styleAttributes) throws IOException {
if (font == null || !isOtherFont(font) /* || styleAttributes == null*/) return;
write(" ");
write(HtmlTags.STYLE);
write("=\"");
if (styleAttributes != null) {
String key;
for (Enumeration e = styleAttributes.propertyNames(); e.hasMoreElements(); ) {
key = (String)e.nextElement();
writeCssProperty(key, styleAttributes.getProperty(key));
}
}
if (isOtherFont(font)) {
writeCssProperty(Markup.CSS_KEY_FONTFAMILY, font.getFamilyname());
if (font.getSize() != Font.UNDEFINED) {
writeCssProperty(Markup.CSS_KEY_FONTSIZE, font.getSize() + "pt");
}
if (font.getColor() != null) {
writeCssProperty(Markup.CSS_KEY_COLOR, HtmlEncoder.encode(font.getColor()));
}
int fontstyle = font.getStyle();
BaseFont bf = font.getBaseFont();
if (bf != null) {
String ps = bf.getPostscriptFontName().toLowerCase();
if (ps.indexOf("bold") >= 0) {
if (fontstyle == Font.UNDEFINED)
fontstyle = 0;
fontstyle |= Font.BOLD;
}
if (ps.indexOf("italic") >= 0 || ps.indexOf("oblique") >= 0) {
if (fontstyle == Font.UNDEFINED)
fontstyle = 0;
fontstyle |= Font.ITALIC;
}
}
if (fontstyle != Font.UNDEFINED && fontstyle != Font.NORMAL) {
switch (fontstyle & Font.BOLDITALIC) {
case Font.BOLD:
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
break;
case Font.ITALIC:
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC);
break;
case Font.BOLDITALIC:
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC);
break;
}
// CSS only supports one decoration tag so if both are specified
// only one of the two will display
if ((fontstyle & Font.UNDERLINE) > 0) {
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_UNDERLINE);
}
if ((fontstyle & Font.STRIKETHRU) > 0) {
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_LINETHROUGH);
}
}
}
write("\"");
}
示例15: main
/**
* Generates a PDF file with the 14 standard Type 1 Fonts
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("StandardType1Fonts.pdf"));
// step 3: we open the document
document.open();
// step 4:
// the 14 standard fonts in PDF: do not use this Font constructor!
// this is for demonstration purposes only, use FontFactory!
Font[] fonts = new Font[14];
fonts[0] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.NORMAL);
fonts[1] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.ITALIC);
fonts[2] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD);
fonts[3] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC);
fonts[4] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL);
fonts[5] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC);
fonts[6] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);
fonts[7] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC);
fonts[8] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL);
fonts[9] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC);
fonts[10] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD);
fonts[11] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC);
fonts[12] = new Font(Font.SYMBOL);
fonts[13] = new Font(Font.ZAPFDINGBATS);
// add the content
for (int i = 0; i < 14; i++) {
document.add(new Paragraph("quick brown fox jumps over the lazy dog", fonts[i]));
}
// step 5: we close the document
document.close();
}