/*
* $Id: ColumnText.java 3904 2009-04-24 10:09:01Z blowagie $
*
* Copyright 2001, 2002 by Paulo Soares.
*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the License.
*
* The Original Code is 'iText, a free JAVA-PDF library'.
*
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
* the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
* All Rights Reserved.
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
* are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
*
* Contributor(s): all the names of the contributors are added in the source code
* where applicable.
*
* Alternatively, the contents of this file may be used under the terms of the
* LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
* provisions of LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of the LGPL
* License and not to allow others to use your version of this file under
* the MPL, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the LGPL.
* If you do not delete the provisions above, a recipient may use your version
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MPL as stated above or under the terms of the GNU
* Library General Public License as published by the Free Software Foundation;
* either version 2 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
* details.
*
* If you didn't download this code from the following link, you should check if
* you aren't using an obsolete version:
* http://www.lowagie.com/iText/
*/
package com.lowagie.text.pdf;
import com.lowagie.text.*;
import com.lowagie.text.pdf.draw.DrawInterface;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Stack;
/**
* Formats text in a columnwise form. The text is bound
* on the left and on the right by a sequence of lines. This allows the column
* to have any shape, not only rectangular.
* <P>
* Several parameters can be set like the first paragraph line indent and
* extra space between paragraphs.
* <P>
* A call to the method <CODE>go</CODE> will return one of the following
* situations: the column ended or the text ended.
* <P>
* I the column ended, a new column definition can be loaded with the method
* <CODE>setColumns</CODE> and the method <CODE>go</CODE> can be called again.
* <P>
* If the text ended, more text can be loaded with <CODE>addText</CODE>
* and the method <CODE>go</CODE> can be called again.<BR>
* The only limitation is that one or more complete paragraphs must be loaded
* each time.
* <P>
* Full bidirectional reordering is supported. If the run direction is
* <CODE>PdfWriter.RUN_DIRECTION_RTL</CODE> the meaning of the horizontal
* alignments and margins is mirrored.
* @author Paulo Soares (psoares@consiste.pt)
*/
public class ColumnText {
/** Eliminate the arabic vowels */
public static final int AR_NOVOWEL = ArabicLigaturizer.ar_novowel;
/** Compose the tashkeel in the ligatures. */
public static final int AR_COMPOSEDTASHKEEL = ArabicLigaturizer.ar_composedtashkeel;
/** Do some extra double ligatures. */
public static final int AR_LIG = ArabicLigaturizer.ar_lig;
/**
* Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits.
*/
public static final int DIGITS_EN2AN = ArabicLigaturizer.DIGITS_EN2AN;
/**
* Digit shaping option: Replace Arabic-Indic digits by European digits (U+0030...U+0039).
*/
public static final int DIGITS_AN2EN = ArabicLigaturizer.DIGITS_AN2EN;
/**
* Digit shaping option:
* Replace European digits (U+0030...U+0039) by Arabic-Indic digits
* if the most recent strongly directional character
* is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC).
* The initial state at the start of the text is assumed to be not an Arabic,
* letter, so European digits at the start of the text will not change.
* Compare to DIGITS_ALEN2AN_INIT_AL.
*/
public static final int DIGITS_EN2AN_INIT_LR = ArabicLigaturizer.DIGITS_EN2AN_INIT_LR;
/**
* Digit shaping option:
* Replace European digits (U+0030...U+0039) by Arabic-Indic digits
* if the most recent strongly directional character
* is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC).
* The initial state at the start of the text is assumed to be an Arabic,
* letter, so European digits at the start of the text will change.
* Compare to DIGITS_ALEN2AN_INT_LR.
*/
public static final int DIGITS_EN2AN_INIT_AL = ArabicLigaturizer.DIGITS_EN2AN_INIT_AL;
/**
* Digit type option: Use Arabic-Indic digits (U+0660...U+0669).
*/
public static final int DIGIT_TYPE_AN = ArabicLigaturizer.DIGIT_TYPE_AN;
/**
* Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).
*/
public static final int DIGIT_TYPE_AN_EXTENDED = ArabicLigaturizer.DIGIT_TYPE_AN_EXTENDED;
protected int runDirection = PdfWriter.RUN_DIRECTION_DEFAULT;
/** the space char ratio */
public static final float GLOBAL_SPACE_CHAR_RATIO = 0;
/** Initial value of the status. */
public static final int START_COLUMN = 0;
/** Signals that there is no more text available. */
public static final int NO_MORE_TEXT = 1;
/** Signals that there is no more column. */
public static final int NO_MORE_COLUMN = 2;
/** The column is valid. */
protected static final int LINE_STATUS_OK = 0;
/** The line is out the column limits. */
protected static final int LINE_STATUS_OFFLIMITS = 1;
/** The line cannot fit this column position. */
protected static final int LINE_STATUS_NOLINE = 2;
/** Upper bound of the column. */
protected float maxY;
/** Lower bound of the column. */
protected float minY;
protected float leftX;
protected float rightX;
/** The column alignment. Default is left alignment. */
protected int alignment = Element.ALIGN_LEFT;
/** The left column bound. */
protected ArrayList leftWall;
/** The right column bound. */
protected ArrayList rightWall;
/** The chunks that form the text. */
// protected ArrayList chunks = new ArrayList();
protected BidiLine bidiLine;
/** The current y line location. Text will be written at this line minus the leading. */
protected float yLine;
/** The leading for the current line. */
protected float currentLeading = 16;
/** The fixed text leading. */
protected float fixedLeading = 16;
/** The text leading that is multiplied by the biggest font size in the line. */
protected float multipliedLeading = 0;
/** The <CODE>PdfContent</CODE> where the text will be written to. */
protected PdfCon
没有合适的资源?快使用搜索试试~ 我知道了~
解决jasperreport、itext生成pdf时符号换行,复刻word中文版式
共4个文件
java:4个
0 下载量 109 浏览量
2024-02-26
14:42:51
上传
评论
收藏 34KB ZIP 举报
温馨提示
在使用jasperreport生成pdf时,会发现结尾为逗号或者句号时,若一行字数已满,逗号或者句号会在第二行展示,与常规的中文版式不相符。然而在word中,若遇到此类情况,会将文字缩进使得标点符号能在一行中展示,对于双引号、书名号等,若在一行结尾,会将该符号显示在第二行。主要原因是itext分隔符使用的是英文分隔符。 为了处理此场景,需要对jasperreport源码和pdf的源码进行修改,复刻word的中文版式的样子。 解决问题如下: 1、部分不能出现在行首的中文自动归于上一行,部分不能出现在结尾的中文自动归于下一行 2、单行结尾遇到符号(逗号或者句号)时,自动收缩字间距,使得一行的文本能够正常显示 3、解决长文本分页时会掉字的问题(分页的那张一行仅有展示一个字) 覆盖DefaultSplitCharacter、BidiLine、ColumnText、SimpleTextLineWrapper这4个文件即可 jasperreports版本6.20.0 itext版本2.1.7
资源推荐
资源详情
资源评论
收起资源包目录
覆盖代码.zip (4个子文件)
覆盖代码
net
sf
jasperreports
engine
fill
SimpleTextLineWrapper.java 32KB
com
lowagie
text
pdf
DefaultSplitCharacter.java 6KB
ColumnText.java 60KB
BidiLine.java 48KB
共 4 条
- 1
资源评论
wisdomsuper2
- 粉丝: 2
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功