- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
客户要求我们在生成的 PDF 标题中创建一个包含一些字段和值的表格。需要重复此 header 。
早期的实现将 PDFPTable 和 PDFPCell 中的数据放在正文内容中,即使经过多次尝试也未能重复。我们已经从 PDFPTable --> Table 和 PDFPCell --> Cell 转移,并且它在标题中工作。现在表的一列包含阿拉伯文本,并且在简单的表和单元格中没有 RUNDIRECTION 设置 RTL 的选项。以 Unicode 编写的文本打印错误。任何帮助表示赞赏。指定供引用的源代码是示例,不包含完整的处理。
public class DataReportFiller {
public static void main(String[] args) {
ff.setFileType(FileFormat.FILE_TYPE_PDF);
PDFWriter pw = new PDFWriter(ff, basePath);
pw.open(fileName, recordSize);
Document document = pw.getDocument();
document.setPageSize(PageSize.A4);
pw.openFileForHeader();
String accStr10[] = null;
accStr10 = new String[] { "TESTING DATA", "", "", "", "", "",
"Total Pages ", Integer.toString(totalPages), "", "",
"\u0629\u062d\u0641\u0635\u0644\u0627 \u0645\u0642\u0631", "" };
pw.setBorder = false;
pw.setBold = true;
pw.fontColour = PDFWriter.COLOUR_BLACK;
pw.bgColour = PDFWriter.COLOUR_WHITE;
pw.horAlignment = pw.ALIGN_LEFT;
// ----------------------------------
int totalPages = 1;
totalPages = totalPages + ((recordSize + 5) / 12);
Table headerTable = pw.getHeaderTable();
headerTable.setBorder(Rectangle.BOTTOM);
headerTable.setBorderColor(Color.WHITE);
pw.writeStatementHeaderLine(accStr10, DataWriter.LINE_TYPE_GENERAL);
headerPhrase.add(2, headerTable);
HeaderFooter header = new HeaderFooter(headerPhrase, false);
header.setAlignment(0);
header.setBorder(Rectangle.NO_BORDER);
document.setHeader(header);
pw.openFile();
pw.createEmptyLine();
pw.commitEmptyLine();
pw.close();
}
// Another method to write data in header, unable to put arabic text here
public boolean writeStatementHeaderLine(String line[], int type)
throws Exception {
try {
// Increment the current line number
currentLineNo++;
// Check if the text is not null or empty
if (line == null || line.length == 0) {
for (int i = 0; i < fileFormat.getFileColCount(); i++) {
chunk = new Chunk(" ", font);
Cell simpleCell = new Cell(new Phrase(chunk));
headerTable.addCell(simpleCell);
}
return false;
}
for (int i = 0; i < line.length; i++) {
setFont();
Cell simpleCell = null;
if (line[i] == null) {
chunk = new Chunk("", font);
simpleCell = new Cell(new Phrase(chunk));
} else if ((type == LINE_TYPE_GENERAL && i >= line.length - 2)) {
final String FONT = applicationContext
.getProperty("arabic.font.path");
font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H,
BaseFont.EMBEDDED, 8);
if (line[i].equalsIgnoreCase("iban"))
setFont();
chunk = new Chunk(line[i], font);
simpleCell = new Cell(new Phrase(chunk));
} else {
chunk = new Chunk(line[i], font);
if (type == LINE_TYPE_GENERAL) {
simpleCell = new Cell(new Phrase(chunk));
}
}
simpleCell.setBorder(Rectangle.NO_BORDER);
if ((type == LINE_TYPE_GENERAL && i >= line.length - 2)) {
simpleCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
// simpleCell.rotate();
}
headerTable.addCell(simpleCell);
}
} catch (Exception e) {
e.printStackTrace();
deleteFile();
e.printStackTrace();
throw e;
}
return true;
}
}
需要在 PDF 标题表中将分支打印为“فف ف٬ْ”,其中显示“فففف”。
最佳答案
最终通过PageEvent的onEndPage方法实现,代码引用如下
pw.open File();
pw.writer.setPageEvent(new PdfPageEventHelper(){
protected ApplicationContext applicationContext = ApplicationContext.getInstance();
@Override
public void onEndPage(PdfWriter writer, Document document)
{
PdfPTable table1=new PdfPTable(12);
try{
String accStr[] = null;
String accStr10[] = null;
accStr = new String[] { accountTitle ,"","","","","","Period Covered " ,startDate +" to " +endDate,"","","\u0645\u062f\u0629 \u0627\u0644\u062a\u063a\u0637\u064a\u0629",""};
accStr10 = new String[] {address1 ,"","","","","","Page No ",Integer.toString(writer.getPageNumber()-1),"","","\u0631\u0642\u0645 \u0627\u0644\u0635\u0641\u062d\u0629",""};
table1.setTotalWidth(522);
float f[] = {45,10,0,0,0,0,25,35,0,0,20,0};
table1.setWidths(f);
pw.setBorder = true;
pw.setBold = true;
pw.fontColour = AccStmtPDFWriter.COLOUR_BLACK;
pw.bgColour = AccStmtPDFWriter.COLOUR_WHITE;
pw.horAlignment = pw.ALIGN_LEFT;
PdfPCell pdfCell=null;
//table1=pw.getTable1();
if(!FieldNameUtil.isApplicableForBahrain){
pdfCell = new PdfPCell(new Phrase(new Chunk("")));
pdfCell.setBorder(0);
pdfCell.setColspan(12);
table1.addCell(pdfCell);
table1=writeHeaderLine(accStr, DataWriter.LINE_TYPE_GENERAL,table1);
}
pdfCell = new PdfPCell(new Phrase(new Chunk("")));
pdfCell.setBorder(0);
pdfCell.setColspan(12);
table1.addCell(pdfCell);
table1=writeHeaderLine(accStr10, DataWriter.LINE_TYPE_GENERAL,table1);
table1.writeSelectedRows(0, -1, 57, 730, writer.getDirectContent());
//document.add(table1);
table1.deleteBodyRows();
}catch(Exception e){
e.printStackTrace();
}
}
public PdfPTable writeHeaderLine(String line[], int type,PdfPTable table2)
throws Exception {
Chunk chunk = null;
PdfPCell cell =null;
PdfPTable tableNew =table2;
Font font=FontFactory.getFont("Arial",8,Font.BOLD,Color.BLACK);
try {
for (int i = 0; i < line.length; i++) {
//changed by shruti
if (line[i] == null)
chunk = new Chunk("", font);
else if(type==115 || (type==pw.LINE_TYPE_GENERAL && i>=line.length-2) || (type==112 && i==line.length-1)){
final String FONT = applicationContext.getProperty("arabic.font.path");
font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED,8);
if(line[i].equalsIgnoreCase("iban"))
font=FontFactory.getFont("Arial",8,Font.BOLD,Color.BLACK);
chunk = new Chunk(line[i], font);
}else
chunk = new Chunk(line[i], font);
cell = new PdfPCell(new Phrase(chunk));
cell.setBorder(Rectangle.NO_BORDER);
cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
if((type==pw.LINE_TYPE_GENERAL && i>=line.length-2)){
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
tableNew.addCell(cell);
}else{
tableNew.addCell(cell);
}
}
return tableNew;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
});
关于java - 需要使用 iText 的 Lowagie 实现在 PDF 标题的表格单元格内写入阿拉伯文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55842192/
我已经尝试在我的 CSS 中添加一个元素来删除每三个 div 的 margin-right。不过,似乎只是出于某种原因影响了第 3 次和第 7 次。需要它在第 3、6、9 等日工作... CSS .s
如何使 div/input 闪烁或“脉冲”?例如,假设表单字段输入了无效值? 最佳答案 使用 CSS3 类似 on this page ,您可以将脉冲效果添加到名为 error 的类中: @-webk
我目前正在尝试构建一个简单的 wireframe来自 lattice 的情节包,但由沿 y 轴的数百个点组成。这导致绘图被线框网格淹没,您看到的只是一个黑色块。我知道我可以用 col=FALSE 完全
在知道 parent>div CSS 选择器在 IE 中无法识别后,我重新编码我的 CSS 样式,例如: div#bodyMain div#paneLeft>div{/*styles here*/}
我有两个 div,一个在另一个里面。当我将鼠标悬停 到最外面的那个时,我想改变它的颜色,没问题。但是,当我将鼠标悬停 到内部时,我只想更改它的颜色。这可能吗?换句话说,当 将鼠标悬停到内部 div 上
我需要展示这样的东西 有人可以帮忙吗?我可以实现以下输出 我正在使用以下代码:: GridView.builder( scrollDirection: Axis.vertical,
当 Bottom Sheet 像 Android 键盘一样打开时,是否有任何方法可以手动上推布局( ScrollView 或回收器 View 或整个 Activity )?或者你可以说我想以 Bott
我有以下代码,用于使用纯 HTML 和 CSS 显示翻转。当您将鼠标悬停在文本上时,它会更改左右图像。 在我测试的所有浏览器中都运行良好,Safari 4 除外。据我收集的信息,Safari 4 支持
我构建了某种 CMS,但在使用 TinyMCE 和 Bootstrap 时遇到了一些问题。 我有一个页面,其中概述了一个 div,如果用户单击该 div,他们可以从模态中选择图像。该图像被插入到一个
出于某种原因,当我设置一个过渡时,当我的鼠标悬停在一个元素上时,背景会改变颜色,它只适用于一个元素,但它们都共享同一个类?任何帮助我的 CSS .outer_ad { position:rel
好吧,这真的很愚蠢。我不知道 Android Studio 中的调试监视框架发生了什么。我有 1.5.1 的工作室。 是否有一些来自 intellij 的 secret 知识来展示它。 最佳答案 与以
我有这个标记: some code > 我正在尝试获取此布局: 注意:上一个和下一个按钮靠近#player 我正在尝试这样: .nextBtn{
网站:http://avuedesigns.com/index 首页有 6 个菜单项。我希望每件元素在您经过时都有自己的颜色。 这是当您将鼠标悬停在 div 上时将所有内容更改为白色的行 li#hom
我需要在 index.php 文件中显示它,但没有任何效果。我所有的文章都没有正确定位。我将其用作代码: 最佳答案 您可以首先检查您
我是一名优秀的程序员,十分优秀!