本文整理汇总了Java中com.itextpdf.text.Paragraph.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java Paragraph.setFont方法的具体用法?Java Paragraph.setFont怎么用?Java Paragraph.setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.itextpdf.text.Paragraph
的用法示例。
在下文中一共展示了Paragraph.setFont方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
@Override
public void process(int level, Node node, InvocationContext context) {
HeaderNode hNode = (HeaderNode) node;
int hLevel = hNode.getLevel();
Sections sections = context.iTextContext().sections();
Font font = sections.sectionTitlePrimaryFont(hLevel);
context.pushFont(font);
List<Element> subs = context.collectChildren(level, node);
context.popFont();
Paragraph p = new Paragraph();
p.setFont(font);
p.addAll(subs);
Element element = sections.newSection(p, hLevel);
context.append(element);
}
示例2: addTitle
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
public void addTitle() throws DocumentException {
Paragraph title = new Paragraph();
title.setAlignment(1);
title.setFont(new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD,
BaseColor.RED));
title.add(new Phrase("Java Assignment"));
document.add(title);
addEmptyLine(title, 2);
Paragraph name = new Paragraph();
name.setAlignment(0);
name.setFont(new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD,
BaseColor.GRAY));
name.add(new Phrase(" Name : " + FileUtil.name + "\n"));
name.add(new Phrase(" Enrollno : " + FileUtil.rollno
+ "\n\n"));
document.add(name);
addEmptyLine(title, 2);
}
示例3: CreatePDF_3DPrinter
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
public CreatePDF_3DPrinter(File file, ArrayList<String> infos, ArrayList<Image> imagelist) throws DocumentException, MalformedURLException, IOException{
result = file;
MyPDF = new Document(PageSize.A4, 50, 50, 80, 80);
MyWriter = PdfWriter.getInstance(MyPDF,new FileOutputStream(result));
MyWriter.setInitialLeading(160);
MyPDF.open();
Font font = new Font(Font.FontFamily.TIMES_ROMAN, 40, Font.NORMAL);
Paragraph pg = new Paragraph();
pg.setAlignment(Element.ALIGN_CENTER);
pg.setSpacingAfter(150);
pg.setFont(font);
pg.add(infos.get(0));
pg.setLeading(2,1);
MyPDF.add(pg);
Image image = Image.getInstance(loadImage("/logo.png"), null);
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 580f);
if(infos.get(0).length()<25){
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 620f);
}
MyPDF.add(image);
MyPDF.add(createFrontPageTable(infos));
if(imagelist!=null){
tilingImages(imagelist);
}
MyPDF.close();
}
示例4: CreatePDF_LaserCutting
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
public CreatePDF_LaserCutting(File file, ArrayList<String> infos, ArrayList<Image> imagelist) throws DocumentException, MalformedURLException, IOException{
result = file;
MyPDF = new Document(PageSize.A4, 50, 50, 80, 80);
MyWriter = PdfWriter.getInstance(MyPDF,new FileOutputStream(result));
MyWriter.setInitialLeading(160);
MyPDF.open();
Font font = new Font(Font.FontFamily.TIMES_ROMAN, 40, Font.NORMAL);
Paragraph pg = new Paragraph();
pg.setAlignment(Element.ALIGN_CENTER);
pg.setSpacingAfter(150);
pg.setFont(font);
pg.add(infos.get(0));
pg.setLeading(2,1);
MyPDF.add(pg);
Image image = Image.getInstance(loadImage("/logo.png"), null);
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 580f);
if(infos.get(0).length()<25){
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 620f);
}
MyPDF.add(image);
MyPDF.add(createFrontPageTable(infos));
if(imagelist!=null){
tilingImages(imagelist);
}
MyPDF.close();
}
示例5: adjustParagraphFont
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
private void adjustParagraphFont(Paragraph element) {
Font font = configuration.tableContentFont();
element.setFont(font);
for (Chunk c : notNull(element.getChunks())) {
adjustChunkFont(c);
}
}
示例6: formatParagraph
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
@Override
protected void formatParagraph(final Element el, final Paragraph p) throws Exception {
p.setAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
String parentName = el.getParent().getName();
if (parentName.equals("Secao") || parentName.equals("Subsecao")) {
p.setFont(ctx.getFont(Font.BOLD));
}
}
示例7: formatParagraph
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
@Override
protected void formatParagraph(final Element el, final Paragraph p) throws Exception {
p.setIndentationLeft(ITextUtil.cm2point(8.5f));
p.setFont(ctx.getFont(Font.NORMAL, ctx.getInt(PDFConfigs.FONT_SIZE_EMENTA)));
p.setSpacingBefore(ITextUtil.cm2point(1));
p.setSpacingAfter(ITextUtil.cm2point(2));
}
示例8: addFacheinschaetzungen
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
private void addFacheinschaetzungen(Chapter chapterLEB, PdfWriter writer) throws DocumentException, PdfFormatierungsException {
for (LebFacheinschaetzungData facheinschaetzungsdaten : lebData.getFacheinschaetzungsdaten()) {
sectionCount += 1;
breakHurenkind(writer);
breakSchusterjunge(writer);
Paragraph paragraphFacheinschaetzung = new Paragraph();
Section facheinschaetzungsTextSection = chapterLEB.addSection(paragraphFacheinschaetzung);
facheinschaetzungsTextSection.setNumberDepth(0);
Collection<String> fachbezeichnungen = facheinschaetzungsdaten.getFachbezeichnungen();
fachbezeichnungen.add(facheinschaetzungsdaten.getFachname());
String facheinschaetzung = facheinschaetzungsdaten.getFacheinschaetzung();
Integer firstIndex = null;
String boldedWord = "";
for (String fachbezeichnung : fachbezeichnungen) {
int index = facheinschaetzung.toLowerCase().indexOf(fachbezeichnung.toLowerCase());
if (index != -1 && (firstIndex == null || firstIndex > index)) {
firstIndex = index;
boldedWord = fachbezeichnung;
}
}
Paragraph facheinschaetzungParapgraph = new Paragraph();
facheinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED);
facheinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor);
if (firstIndex == null) {
facheinschaetzungParapgraph.add(new Phrase(facheinschaetzungsdaten.getFacheinschaetzung().replace('\t', '\0'), standardTextFont));
} else {
String beforeBoldWord = facheinschaetzung.substring(0, firstIndex);
facheinschaetzungParapgraph.add(new Phrase(beforeBoldWord.replace('\t', '\0'), standardTextFont));
String boldWord = facheinschaetzung.substring(firstIndex, firstIndex + boldedWord.length());
facheinschaetzungParapgraph.add(new Phrase(boldWord, standardTextBoldFont));
String afterBoldWord = facheinschaetzung.substring(firstIndex + boldedWord.length());
facheinschaetzungParapgraph.add(new Phrase(afterBoldWord.replace('\t', '\0'), standardTextFont));
}
facheinschaetzungParapgraph.setFont(standardTextFont);
facheinschaetzungsTextSection.add(facheinschaetzungParapgraph);
Paragraph unterschriftParagraph = new Paragraph();
document.add(facheinschaetzungsTextSection);
Section facheinschaetzungsUnterschriftSection = chapterLEB.addSection(unterschriftParagraph);
facheinschaetzungsUnterschriftSection.setNumberDepth(0);
unterschriftParagraph.add(new Phrase(facheinschaetzungsdaten.getUnterschrift().replace('\t', '\0'), standardTextFont));
unterschriftParagraph.setAlignment(Element.ALIGN_RIGHT);
unterschriftParagraph.add(Chunk.NEWLINE);
unterschriftParagraph.add(Chunk.NEWLINE);
document.add(facheinschaetzungsUnterschriftSection);
alertHurenkind(writer);
insertDummyLineIfNecessary(writer);
}
}
示例9: addVerticalSpaceCM
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
protected void addVerticalSpaceCM(final float cm) throws Exception {
Paragraph p = new Paragraph();
p.setFont(ctx.getFont(Font.NORMAL));
p.setSpacingAfter(ITextUtil.cm2point(cm));
addToPDF(p);
}
示例10: formatParagraph
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
@Override
protected void formatParagraph(final Element el, final Paragraph p) throws Exception {
p.setAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
p.setFont(ctx.getFont(Font.BOLD, ctx.getInt(PDFConfigs.FONT_SIZE_EPIGRAFE)));
ctx.pushStringTransformer(this);
}
示例11: formatParagraph
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
@Override
protected void formatParagraph(final Element el, final Paragraph p) throws Exception {
p.setFont(ctx.getFont(Font.BOLD));
}
示例12: render
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
@Override
public boolean render(final Element el) throws Exception {
String parentName = el.getParent().getName();
if (parentName.equals("Capitulo") || parentName.equals("Titulo") || parentName.equals("Livro")
|| parentName.equals("Parte") || parentName.equals("Secao") || parentName.equals("Subsecao")) {
Paragraph p = ctx.createParagraph();
p.setAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
float paragraphSpacing = ITextUtil.cm2point(ctx.getFloat(PDFConfigs.PARAGRAPH_SPACING));
p.setSpacingBefore(paragraphSpacing / 2);
p.setSpacingAfter(paragraphSpacing / 2);
ctx.pushContainer(p); // Necessário para abertura de aspas
// Negrito
if (parentName.equals("Secao") || parentName.equals("Subsecao")) {
p.setFont(ctx.getFont(Font.BOLD));
}
addToContainer(el.getTextTrim());
ctx.popContainer();
addToPDF(p);
}
else {
String texto = el.getTextTrim();
if (parentName.equals("Artigo") || parentName.equals("Paragrafo")) {
texto += " "; // Dois espaços
}
else {
texto += " ";
}
Chunk c = new Chunk(texto);
if (texto.toLowerCase().contains("parágrafo único")) {
c.setFont(ctx.getFont(Font.ITALIC));
}
else {
c.setFont(ctx.getFont(Font.BOLD));
}
addToNextContainer(c);
if (renderizarOmissis(el)) {
Renderer_Omissis.renderOmissis(ctx);
}
}
return Renderer.ACABOU;
}
示例13: build
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
public void build() throws Exception {
// Para resolução de namespace padrão via XPATH
Map<String , String> map = new HashMap<String , String>();
map.put("lexml", root.getNamespaceURI());
ctx.setXpathNamespaceContext(new SimpleNamespaceContext(map));
// seta LexmlFontFactory
ctx.setFontFactory(new GentiumFontFactory(ctx.getBoolean(PDFConfigs.ALLOW_UNDERLINES)));
// Setup da página
Rectangle pageSize = new Rectangle(ctx.getPoints(PDFConfigs.DOCUMENT_WIDTH),
ctx.getPoints(PDFConfigs.DOCUMENT_HEIGHT));
Document doc = new Document(pageSize, ctx.getPoints(PDFConfigs.DOCUMENT_MARGIN_LEFT),
ctx.getPoints(PDFConfigs.DOCUMENT_MARGIN_RIGHT),
ctx.getPoints(PDFConfigs.DOCUMENT_MARGIN_TOP),
ctx.getPoints(PDFConfigs.DOCUMENT_MARGIN_BOTTOM));
ctx.setPdf(doc);
OutputStream out = ctx.getOutputStream();
PdfWriter pdfWriter = PdfWriter.getInstance(doc, ctx.getOutputStream());
pdfWriter.setPageEvent(new PdfPageListener());
if(ctx.getBoolean(PDFConfigs.ADD_OUTLINE)) {
//System.out.println("build: outline enabled");
//pdfWriter.setViewerPreferences(PdfWriter.PageModeUseOutlines);
}
ctx.setPdfWriter(pdfWriter);
// Inicializa decoradores
decorators = new PDFDecoratorList(ctx.getString(PDFConfigs.DECORATOR_CLASSES));
decorators.init(ctx, root);
// Necessário para PDF/A
pdfWriter.setPDFXConformance(PdfWriter.PDFA1B);
createMetadata(doc, root, pdfWriter);
doc.open();
// Fonte / Parágrafo padrão
Paragraph p = ctx.createParagraph();
Font f = ctx.getFont(Font.NORMAL);
p.setFont(f);
p.setAlignment(com.itextpdf.text.Element.ALIGN_JUSTIFIED);
p.setSpacingAfter(ctx.getPoints(PDFConfigs.PARAGRAPH_SPACING));
ctx.pushProtoParagraph(p);
decorators.beforeContent(ctx, root);
render(root);
ctx.popProtoParagraph();
decorators.afterContent(ctx, root);
ctx.flushPdf();
ctx.finalizeDocument();
doc.close();
out.close();
}
示例14: addtoPDf
import com.itextpdf.text.Paragraph; //导入方法依赖的package包/类
public void addtoPDf() throws FileNotFoundException,
DocumentException {
String str;
while (!FileUtil.javaFiles.isEmpty()) {
String curFile = FileUtil.javaFiles.remove(0);
Paragraph title = new Paragraph();
title.setAlignment(1);
title.setFont(new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD,
BaseColor.BLUE));
title.add(new Phrase(curFile));
document.add(title);
addEmptyLine(title, 1);
Paragraph paragraph = new Paragraph();
paragraph.setFont(new Font(Font.FontFamily.TIMES_ROMAN, 8,
Font.NORMAL, BaseColor.BLACK));
// Scanner sc = new Scanner(new File(curFile));
try (BufferedReader br = new BufferedReader(new FileReader(curFile))) {
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
if (sCurrentLine.lastIndexOf('\t') > 0) {
for (int i = 0; i != sCurrentLine.lastIndexOf('\t'); i++) {
paragraph.add(new Phrase(" "));
}
}
paragraph.add(new Phrase(sCurrentLine + "\n\t"));
// System.out.println(sCurrentLine);
}
// }
} catch (IOException e) {
e.printStackTrace();
}
document.add(paragraph);
}
}