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


Java XWPFRun.setFontSize方法代码示例

本文整理汇总了Java中org.apache.poi.xwpf.usermodel.XWPFRun.setFontSize方法的典型用法代码示例。如果您正苦于以下问题:Java XWPFRun.setFontSize方法的具体用法?Java XWPFRun.setFontSize怎么用?Java XWPFRun.setFontSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.xwpf.usermodel.XWPFRun的用法示例。


在下文中一共展示了XWPFRun.setFontSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyMStyle

import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
/**
 * Apply the given style to the given run. Background color is not taken into account here since it does not apply to runs.
 * 
 * @param run
 *            The run to style
 * @param style
 *            The style to apply, can be <code>null</code>
 */
private void applyMStyle(XWPFRun run, MStyle style) {
    if (style.getFontSize() != -1) {
        run.setFontSize(style.getFontSize());
    }
    if (style.getFontModifiers() != -1) {
        run.setBold((style.getFontModifiers() & MStyle.FONT_BOLD) != 0);
        run.setItalic((style.getFontModifiers() & MStyle.FONT_ITALIC) != 0);
        if ((style.getFontModifiers() & MStyle.FONT_UNDERLINE) != 0) {
            run.setUnderline(UnderlinePatterns.SINGLE);
        }
        run.setStrikeThrough((style.getFontModifiers() & MStyle.FONT_STRIKE_THROUGH) != 0);
    }
    if (style.getForegroundColor() != null) {
        run.setColor(hexColor(style.getForegroundColor()));
    }
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:25,代码来源:M2DocEvaluator.java

示例2: addRunError

import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
/**
 * Inserts the given {@link TemplateValidationMessage} in a run next to the one of the given construct subject to the message.
 * 
 * @param message
 *            the {@link TemplateValidationMessage} to insert
 *            the error message to insert in a run
 * @param offset
 *            the offset in number of {@link XWPFRun} to insert after {@link TemplateValidationMessage#getLocation() message location}
 * @return the number of inserted {@link XWPFRun}
 */
private int addRunError(TemplateValidationMessage message, int offset) {
    int res = 0;

    if (message.getLocation().getParent() instanceof XWPFParagraph) {
        XWPFParagraph paragraph = (XWPFParagraph) message.getLocation().getParent();
        final int basePosition = paragraph.getRuns().indexOf(message.getLocation()) + offset;

        // separation run.
        res++;
        final String color = M2DocUtils.getColor(message.getLevel());
        XWPFRun newBlankRun = paragraph.insertNewRun(basePosition + res);
        newBlankRun.setText(BLANK_SEPARATOR);

        res++;
        final XWPFRun separationRun = paragraph.insertNewRun(basePosition + res);
        separationRun.setText(LOCATION_SEPARATOR);
        separationRun.setColor(color);
        separationRun.setFontSize(ERROR_MESSAGE_FONT_SIZE);
        final CTHighlight separationHighlight = separationRun.getCTR().getRPr().addNewHighlight();
        separationHighlight.setVal(STHighlightColor.LIGHT_GRAY);

        res++;
        final XWPFRun messageRun = paragraph.insertNewRun(basePosition + res);
        messageRun.setText(message.getMessage());
        messageRun.setColor(color);
        messageRun.setFontSize(ERROR_MESSAGE_FONT_SIZE);
        final CTHighlight messageHighlight = messageRun.getCTR().getRPr().addNewHighlight();
        messageHighlight.setVal(STHighlightColor.LIGHT_GRAY);
    }

    return res;
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:43,代码来源:TemplateValidationGenerator.java

示例3: SetFontStyle

import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
private void SetFontStyle(XWPFRun run) {
	run.setFontFamily("Calibri");
	run.setFontSize(20);
}
 
开发者ID:Arquisoft,项目名称:Voting_2b,代码行数:5,代码来源:WordLetterWriter.java

示例4: saveStylesToDocxFile

import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
/**
 * ����text��������ʽ��docx��ʽ�ļ�
 */
@SuppressWarnings("deprecation")
public void saveStylesToDocxFile(StyledText text, XWPFDocument document) {

	for (int i = 0; i < text.getLineCount(); ++i) {
		int lineOffset = text.getOffsetAtLine(i);
		String lineText = text.getLine(i);
		XWPFParagraph paragraph = document.createParagraph();
		paragraph.setFirstLineIndent(text.getIndent());
		int lineAlignment = text.getLineAlignment(i);
		switch (lineAlignment) {
		case SWT.RIGHT:
			paragraph.setAlignment(ParagraphAlignment.RIGHT);
			break;
		case SWT.CENTER:
			paragraph.setAlignment(ParagraphAlignment.CENTER);
			break;
		}
		// ����ÿһ�����ÿ���ַ�
		for (int a = lineOffset; a < lineOffset + lineText.length(); ++a) {
			StyleRange charStyle = text.getStyleRangeAtOffset(a);
			String charText = text.getText(a, a);
			XWPFRun run = paragraph.createRun();
			run.setText(charText);
			String fontname = null;
			int fontsize = 0;
			if (charStyle != null) {
				// Color background = charStyle.background;
				// Color foreground = charStyle.foreground;
				if (charStyle.font != null) {
					fontname = charStyle.font.getFontData()[0].getName();
					if (b.text != null && text.equals(b.text))
						fontsize = b.getFontRealSize(charStyle.font.getFontData()[0].getHeight());
					else
						fontsize = text.getFont().getFontData()[0].getHeight();
				}
				int fontstyle = charStyle.fontStyle;
				switch (fontstyle) {
				case SWT.BOLD:
					run.setBold(true);
					break;
				case SWT.ITALIC:
					run.setItalic(true);
					break;
				case SWT.BOLD | SWT.ITALIC:
					run.setBold(true);
					run.setItalic(true);
					break;
				}
				run.setStrike(charStyle.strikeout);
				if (charStyle.underline)
					run.setUnderline(UnderlinePatterns.SINGLE);

				run.setFontFamily(fontname, FontCharRange.eastAsia);
				run.setFontSize(fontsize);
			}

		}

	}

}
 
开发者ID:piiiiq,项目名称:Black,代码行数:65,代码来源:blackAction.java

示例5: createDocument

import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
@Override
public void createDocument(String documentName, String content) throws CitizenException {

       XWPFDocument doc = new XWPFDocument();
       XWPFParagraph pg = doc.createParagraph();



           XWPFRun run = pg.createRun();
           run.setFontFamily("Calibri");
           run.setFontSize(20);
           run.setText(content);
       try {
           FileOutputStream out = new FileOutputStream(FILE_PATH+documentName+".docx");
           doc.write(out);
           out.close();
           doc.close();
       } catch (IOException e) {
           throw new CitizenException("Error al generar documento word" +
                   " ["+ FILE_PATH+documentName+".docx] | ["+this.getClass().getName()+"]");
       }






	
}
 
开发者ID:Arquisoft,项目名称:citizensLoader4a,代码行数:30,代码来源:WordTextWritter.java


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