用于突出显示pdf中文本颜色的java代码
我正在pdf中使用用于突出显示pdf中文本颜色的java代码,java,itext,Java,Itext,我正在pdf中使用com.lowagie.text。生成时,我需要突出显示一些文本。这是我的代码。我需要突出显示块中文本的代码 PdfContentByte cb = writer.getDirectContent(); Chunk chunck = new Chunk(arraySpec[k],font); Phrase phrase = new Phrase(8.0f+ 1); phrase.add(chunck); ColumnText columnText = new ColumnT
com.lowagie.text
。生成时,我需要突出显示一些文本。这是我的代码。我需要突出显示块中文本的代码
PdfContentByte cb = writer.getDirectContent();
Chunk chunck = new Chunk(arraySpec[k],font);
Phrase phrase = new Phrase(8.0f+ 1);
phrase.add(chunck);
ColumnText columnText = new ColumnText(cb);
columnText.addText(phrase);
//verify the bounding box size
if (attributeBoundingBoxTextWidth == 0){
attributeBoundingBoxTextWidth = (int) boardWidth;
}
float llx = xpos;
float lly = 0;
float urx = llx + width;
float ury = refYPos - sizeOftext;
refYPos = ury;
float leading = 8.0f+ 1;
columnText.setSimpleColumn(llx, lly, urx, ury, leading, Element.ALIGN_LEFT);
columnText.go();
我为上面的帖子找到了一个解决方案
columnText.getCanvas().setColorFill(Color.decode("#FFA500"));
columnText.getCanvas().rectangle(llx, ury-(leading) ,columnText.getWidth(phrase) , sizeOftext);
columnText.getCanvas().fill();
columnText.go();
你的帖子没有说你的问题到底是什么。你需要什么帮助?上面的代码没有突出显示代码,我不知道放在哪里