当前位置: 首页>>代码示例>>Java>>正文


Java Paragraph.setFont方法代码示例

本文整理汇总了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);
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:20,代码来源:HeaderNodeProcessor.java

示例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);
	}
 
开发者ID:codebuff,项目名称:txt2pdf,代码行数:23,代码来源:PdfUtils.java

示例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();
}
 
开发者ID:AlexandrePechereau,项目名称:FabDocMaker,代码行数:28,代码来源:CreatePDF_3DPrinter.java

示例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();
}
 
开发者ID:AlexandrePechereau,项目名称:FabDocMaker,代码行数:28,代码来源:CreatePDF_LaserCutting.java

示例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);
    }
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:9,代码来源:TableDataContentProcessor.java

示例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));
    }
}
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:9,代码来源:Renderer_NomeAgrupador.java

示例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));
}
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:8,代码来源:Renderer_Ementa.java

示例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);
	}
}
 
开发者ID:fossaag,项目名称:rolp,代码行数:53,代码来源:PdfStreamSource.java

示例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);
}
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:7,代码来源:AbstractRenderer.java

示例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);
}
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:7,代码来源:Renderer_Epigrafe.java

示例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));
}
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:5,代码来源:Renderer_TituloDispositivo.java

示例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;
}
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:54,代码来源:Renderer_Rotulo.java

示例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();

    }
 
开发者ID:lexml,项目名称:lexml-renderer-pdf,代码行数:68,代码来源:PDFBuilder.java

示例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);
	}

}
 
开发者ID:codebuff,项目名称:txt2pdf,代码行数:42,代码来源:PdfUtils.java


注:本文中的com.itextpdf.text.Paragraph.setFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。