日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

itextpdf paragraph使用

發布時間:2023/12/14 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 itextpdf paragraph使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

itextpdf paragraph使用

? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ??

*****************

相關類與接口

? ? ? ? ? ? ??

Paragraph:文本段落

public class Paragraph extends BlockElement<Paragraph> {protected DefaultAccessibilityProperties tagProperties;public Paragraph() {public Paragraph(String text) {public Paragraph(Text text) {public Paragraph add(String text) {public Paragraph add(ILeafElement element) {public Paragraph add(IBlockElement element) {public <T2 extends ILeafElement> Paragraph addAll(List<T2> elements) {public Paragraph addTabStops(TabStop... tabStops) {public Paragraph addTabStops(List<TabStop> tabStops) {public Paragraph removeTabStop(float tabStopPosition) {public Paragraph setFirstLineIndent(float indent) {public Paragraph setOrphansControl(ParagraphOrphansControl orphansControl) {public Paragraph setWidowsControl(ParagraphWidowsControl widowsControl) {public Paragraph setFixedLeading(float leading) {public Paragraph setMultipliedLeading(float leading) {public <T1> T1 getDefaultProperty(int property) {public AccessibilityProperties getAccessibilityProperties() {protected IRenderer makeNewRenderer() {private void addTabStopsAsProperty(List<TabStop> newTabStops) {

? ? ? ? ? ? ? ? ? ? ? ??

Text:文本內容

public class Text extends AbstractElement<Text> implements ILeafElement, IAccessibleElement {protected String text;protected DefaultAccessibilityProperties tagProperties;public Text(String text) {public void setText(String text) {public Text setTextRise(float textRise) {public Text setSkew(float alpha, float beta) {public Text setHorizontalScaling(float horizontalScaling) {public String getText() {public float getTextRise() {public Float getHorizontalScaling() {public AccessibilityProperties getAccessibilityProperties() {protected IRenderer makeNewRenderer() {

Div:將paragraph放進div中,進行文本布局

public class Div extends BlockElement<Div> {protected DefaultAccessibilityProperties tagProperties;public Div() {}public Div add(IBlockElement element) {public Div add(Image element) {public Div add(AreaBreak areaBreak) {public AccessibilityProperties getAccessibilityProperties() {public Div setFillAvailableArea(boolean fillArea) {public Div setFillAvailableAreaOnSplit(boolean fillAreaOnSplit) {protected IRenderer makeNewRenderer() {

? ? ? ? ? ? ? ? ? ? ??

BlockElement:內外邊距、行寬高等設置

public abstract class BlockElement<T extends IElement> extends AbstractElement<T> implements IAccessibleElement, IBlockElement {protected BlockElement() {}public <T1> T1 getDefaultProperty(int property) {switch(property) {case 103:case 104:return OverflowPropertyValue.FIT;default:return super.getDefaultProperty(property);}}*********** 內邊距public T setPaddingLeft(float value) {public T setPaddingRight(float value) {public T setPaddingTop(float value) {public T setPaddingBottom(float value) {public UnitValue getPaddingLeft() {public UnitValue getPaddingRight() {public UnitValue getPaddingTop() {public UnitValue getPaddingBottom() {public T setPadding(float commonPadding) {public T setPaddings(float paddingTop, float paddingRight, float paddingBottom, float paddingLeft) {*********** 頁邊距public T setMarginLeft(float value) {public T setMarginRight(float value) {public T setMarginTop(float value) {public T setMarginBottom(float value) {public UnitValue getMarginLeft() {public UnitValue getMarginRight() {public UnitValue getMarginTop() {public UnitValue getMarginBottom() {public T setMargin(float commonMargin) {public T setMargins(float marginTop, float marginRight, float marginBottom, float marginLeft) {*********** 寬度、高度public T setWidth(float width) {public T setWidth(UnitValue width) {public UnitValue getWidth() {public T setHeight(UnitValue height) {public T setHeight(float height) {public UnitValue getHeight() {public T setMaxHeight(float maxHeight) {public T setMaxHeight(UnitValue maxHeight) {public T setMinHeight(UnitValue minHeight) {public T setMinHeight(float minHeight) {public T setMaxWidth(UnitValue maxWidth) {public T setMaxWidth(float maxWidth) {public T setMinWidth(UnitValue minWidth) {public T setMinWidth(float minWidth) {*********** 其余操作public T setVerticalAlignment(VerticalAlignment verticalAlignment) {public T setSpacingRatio(float ratio) {public Boolean isKeepTogether() {public T setKeepTogether(boolean keepTogether) {public Boolean isKeepWithNext() {public T setKeepWithNext(boolean keepWithNext) {public T setRotationAngle(float angleInRadians) {public T setRotationAngle(double angleInRadians) {

? ? ? ? ? ? ? ? ? ??

AbstractElement:樣式、頁面動作等設置

public abstract class AbstractElement<T extends IElement> extends ElementPropertyContainer<T> implements IAbstractElement {protected IRenderer nextRenderer;protected List<IElement> childElements = new ArrayList();protected Set<Style> styles;public AbstractElement() {}public IRenderer createRendererSubTree() {public void setNextRenderer(IRenderer renderer) {public IRenderer getRenderer() {public T addStyle(Style style) { //添加樣式public T setAction(PdfAction action) { //頁面動作:頁面跳轉、超鏈接等public T setPageNumber(int pageNumber) { //設置頁碼public boolean isEmpty() {public List<IElement> getChildren() {public boolean hasProperty(int property) {public <T1> T1 getProperty(int property) {protected abstract IRenderer makeNewRenderer(); }

? ? ? ? ? ? ? ? ? ? ? ??

Style:樣式

public class Style extends ElementPropertyContainer<Style> {public Style() {public Style(Style style) {********** 頁邊距public Style setMarginTop(float value) {public Style setMarginLeft(float value) {public Style setMarginRight(float value) {public Style setMarginBottom(float value) {public UnitValue getMarginTop() {public UnitValue getMarginLeft() {public UnitValue getMarginRight() {public UnitValue getMarginBottom() {public Style setMargin(float commonMargin) {public Style setMargins(float marginTop, float marginRight, float marginBottom, float marginLeft) {********** 內邊距public Style setPaddingTop(float value) {public Style setPaddingLeft(float value) {public Style setPaddingRight(float value) {public Style setPaddingBottom(float value) {public UnitValue getPaddingTop() {public UnitValue getPaddingLeft() {public UnitValue getPaddingRight() {public UnitValue getPaddingBottom() {public Style setPadding(float commonPadding) {public Style setPaddings(float paddingTop, float paddingRight, float paddingBottom, float paddingLeft) {********** 高度、寬度public Style setWidth(float width) {public Style setWidth(UnitValue width) {public UnitValue getWidth() {public Style setHeight(UnitValue height) {public Style setHeight(float height) {public UnitValue getHeight() {public Style setMaxHeight(float maxHeight) {public Style setMaxHeight(UnitValue maxHeight) {public Style setMinHeight(UnitValue minHeight) {public Style setMinHeight(float minHeight) {public Style setMaxWidth(UnitValue maxWidth) {public Style setMaxWidth(float maxWidth) {public Style setMinWidth(UnitValue minWidth) {public Style setMinWidth(float minWidth) {********** 其余操作public Boolean isKeepTogether() {public Style setKeepTogether(boolean keepTogether) {public Style setRotationAngle(float radAngle) {public Style setRotationAngle(double angle) {public Style setSpacingRatio(float ratio) {public Style setVerticalAlignment(VerticalAlignment verticalAlignment) {

?????????????

ElementPropertyContainer:位置、字體、邊框、背景等設置

public abstract class ElementPropertyContainer<T extends IPropertyContainer> extends AbstractIdentifiableElement implements IPropertyContainer {protected Map<Integer, Object> properties = new HashMap();public ElementPropertyContainer() {}********* propertypublic boolean hasProperty(int property) {public <T1> T1 getProperty(int property) {public void setProperty(int property, Object value) {public boolean hasOwnProperty(int property) {public <T1> T1 getOwnProperty(int property) {public void deleteOwnProperty(int property) {public <T1> T1 getDefaultProperty(int property) {********* positionpublic T setRelativePosition(float left, float top, float right, float bottom) {public T setFixedPosition(float left, float bottom, float width) {public T setFixedPosition(float left, float bottom, UnitValue width) {public T setFixedPosition(int pageNumber, float left, float bottom, float width) {public T setFixedPosition(int pageNumber, float left, float bottom, UnitValue width) {********* fontpublic T setFont(PdfFont font) {public T setFontFamily(String... fontFamilyNames) {public T setFontFamily(List<String> fontFamilyNames) {public T setFontColor(Color fontColor) {public T setFontColor(Color fontColor, float opacity) {public T setFontSize(float fontSize) {public T setFontKerning(FontKerning fontKerning) {public T setFontScript(UnicodeScript script) {public T setBold() { //字體加粗public T setItalic() { //字體傾斜********* backgroundpublic T setBackgroundColor(Color backgroundColor) {public T setBackgroundColor(Color backgroundColor, float opacity) {public T setBackgroundColor(Color backgroundColor, float extraLeft, float extraTop, float extraRight, float extraBottom) {public T setBackgroundColor(Color backgroundColor, float opacity, float extraLeft, float extraTop, float extraRight, float extraBottom) {public T setBackgroundImage(BackgroundImage image) {public T setBackgroundImage(List<BackgroundImage> imagesList) {********* borderpublic T setBorder(Border border) {public T setBorderTop(Border border) {public T setBorderLeft(Border border) {public T setBorderRight(Border border) {public T setBorderBottom(Border border) {public T setBorderRadius(BorderRadius borderRadius) {public T setBorderTopLeftRadius(BorderRadius borderRadius) {public T setBorderTopRightRadius(BorderRadius borderRadius) {public T setBorderBottomRightRadius(BorderRadius borderRadius) {public T setBorderBottomLeftRadius(BorderRadius borderRadius) {public T setStrokeColor(Color strokeColor) {public Color getStrokeColor() { //邊框顏色public T setStrokeWidth(float strokeWidth) {public Float getStrokeWidth() { //邊框寬度 ********* underlinepublic T setUnderline() { //文本加下劃線public T setLineThrough() { //文本加刪除線public T setUnderline(float thickness, float yPosition) {public T setUnderline(Color color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle) {public T setUnderline(Color color, float opacity, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle) {********* 其余操作public T setHorizontalAlignment(HorizontalAlignment horizontalAlignment) {public T setTextAlignment(TextAlignment alignment) { //文本對齊方式public T setCharacterSpacing(float charSpacing) {public T setWordSpacing(float wordSpacing) { //單詞間距public T setTextRenderingMode(int textRenderingMode) {public Integer getTextRenderingMode() { //文本渲染方式public T setSplitCharacters(ISplitCharacters splitCharacters) {public ISplitCharacters getSplitCharacters() { //文本分隔符public T setBaseDirection(BaseDirection baseDirection) {public T setDestination(String destination) {public T setOpacity(Float opacity) { //文本透明度public T setHyphenation(HyphenationConfig hyphenationConfig) { //設置連字符

? ? ? ? ? ? ? ? ? ? ? ??

DeviceRgb:自定義顏色

public class DeviceRgb extends Color {public static final Color BLACK = new DeviceRgb(0, 0, 0);public static final Color WHITE = new DeviceRgb(255, 255, 255);public static final Color RED = new DeviceRgb(255, 0, 0);public static final Color GREEN = new DeviceRgb(0, 255, 0);public static final Color BLUE = new DeviceRgb(0, 0, 255);public DeviceRgb(int r, int g, int b) {public DeviceRgb(float r, float g, float b) {public DeviceRgb(java.awt.Color color) {public DeviceRgb() {this(0.0F, 0.0F, 0.0F);}public static DeviceRgb makeLighter(DeviceRgb rgbColor) {public static DeviceRgb makeDarker(DeviceRgb rgbColor) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

ColorConstants

public class ColorConstants {public static final Color BLACK;public static final Color BLUE;public static final Color CYAN;public static final Color DARK_GRAY;public static final Color GRAY;public static final Color GREEN;public static final Color LIGHT_GRAY;public static final Color MAGENTA;public static final Color ORANGE;public static final Color PINK;public static final Color RED;public static final Color WHITE;public static final Color YELLOW;public ColorConstants() {}static {BLACK = DeviceRgb.BLACK;BLUE = DeviceRgb.BLUE;CYAN = new DeviceRgb(0, 255, 255);DARK_GRAY = new DeviceRgb(64, 64, 64);GRAY = new DeviceRgb(128, 128, 128);GREEN = DeviceRgb.GREEN;LIGHT_GRAY = new DeviceRgb(192, 192, 192);MAGENTA = new DeviceRgb(255, 0, 255);ORANGE = new DeviceRgb(255, 200, 0);PINK = new DeviceRgb(255, 175, 175);RED = DeviceRgb.RED;WHITE = DeviceRgb.WHITE;YELLOW = new DeviceRgb(255, 255, 0);} }

? ? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ? ??

*****************

示例

? ? ? ? ? ? ??

public class Test4 {private static final String dest = "./test/4.pdf";private static final String dest2 = "./test/5.pdf";private static final String fontPath = "./fonts/simkai.ttf";public static void fun() throws Exception{PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));pdfDocument.setDefaultPageSize(PageSize.A4);Document document = new Document(pdfDocument);PdfFont font = PdfFontFactory.createFont(fontPath);document.setFont(font);Div div = new Div();div.setTextAlignment(TextAlignment.CENTER);Paragraph paragraph = new Paragraph();paragraph.setFirstLineIndent(2).add(new Text("靜夜思\n").setTextAlignment(TextAlignment.CENTER).setFontColor(ColorConstants.ORANGE)).add(new Text("床前明月光,疑是地上霜。\n舉頭望明月,低頭思故鄉。").setTextAlignment(TextAlignment.CENTER).setFontColor(new DeviceRgb(204, 102, 160)));div.add(paragraph);document.add(div);document.add(new AreaBreak(AreaBreakType.NEXT_AREA));//區域間隔要在document上添加,在div上添加無效Div div2 = new Div();div2.setTextAlignment(TextAlignment.CENTER);Paragraph paragraph2 = new Paragraph();paragraph2.addTabStops(new TabStop(20)).add(new Text("春曉\n")).add(new Text("春眠不覺曉,處處聞啼鳥。\n夜來風雨聲,花落知多少。"));div2.add(paragraph2);document.add(div2);document.close();}public static void fun2() throws Exception{PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest2));pdfDocument.setDefaultPageSize(PageSize.A4);Document document = new Document(pdfDocument);PdfFont font = PdfFontFactory.createFont(fontPath);document.setFont(font);Div div = new Div();Paragraph paragraph = new Paragraph();paragraph.setFirstLineIndent(25) //首行縮進.add(new Text("這長達數千公里的槽脊,就是一段大氣長波,它的周期大約是3到5天左右," +"所以冬季冷空氣活動也因此具有一定規律性。冷空氣的周期和強度都會受槽脊強弱影響," +"所以如果某次冷空氣剛好趕上了周末,在下個周末又撞上新一股冷空氣,也是可能的。"));div.add(paragraph);document.add(div);document.close();}public static void main(String[] args) throws Exception{fun();fun2();} }

? ? ? ? ? ? ? ? ? ??

fun

? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? ? ? ?

fun2

? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

總結

以上是生活随笔為你收集整理的itextpdf paragraph使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。