0

から始まるテキストを垂直に設定するにはどうすればよいbottom to topですか?

これらは動的に生成されたテキストです。そこで、各テキストを表のタグに入れることを検討しました。

これは機能していません:

for (int j = 0; j < cur.getCount(); j++)
{
VerticalText vt = new VerticalText(writer.getDirectContent());
//vt.setVerticalLayout(390, 570, 540, 12, 30);

vt.addText(new Phrase(location));
vt.go();
vt.setAlignment(Element.ALIGN_RIGHT);

verticalLoc = vt.toString();

verticalLoc += "<td align='left' width='28%'><div style='font-size:8px;-ms-transform:rotate(270deg);-moz-transform:rotate(270deg);" +
        "-webkit-transform:rotate(270deg);-o-transform:rotate(270deg);'>"+ verticalLoc+ "</div></td>";
}

ここに画像の説明を入力

ここで垂直方向の配置に使用されているスタイルは、itextpdfでは機能しません。

アップデート:

わかりました、記事を 1 つ見つけて、その助けを借りて縦書きテキストを実装しようとしました。

しかし、それを上記のコードとリンクする方法は?

アップデート:

Further as a point of note-

私のhtmlには、後でプログラムを使用して置き換えるいくつかの要素が含まれています。このような要素は、 のような html タグ内の中括弧の下で示されます<td>{VERTICALTEXT}</td>。次に、プログラムでこれを map like- に置き換えますmap.put("VERTICALTEXT", verticalLoc);。次に、html = html.replace("{" + e.getKey() + "}", value);必要なhtmlを置き換えて取得します。

アップデート:

私がそれをどのように行っているか-

private static String FILE = Environment.getExternalStorageDirectory() + File.separator;
static PdfWriter writer;
HTMLWorker htmlWorker = new HTMLWorker(document);
Document document = new Document();
document.setMargins(2f, 2f, 2f, 2f);
writer = PdfWriter.getInstance(document, new FileOutputStream(FILE));
document.open();

PdfDestination pdfDest = new PdfDestination(PdfDestination.FIT, 0,
                    document.getPageSize().getHeight(), 0.5f);

PdfAction action = PdfAction.gotoLocalPage(1, pdfDest, writer);

writer.setOpenAction(action);

verticalLoc += "<td align='left' width='28%'><div style='font-size:8px;-ms-transform:rotate(270deg);-moz-transform:rotate(270deg);" +"-webkit-transform:rotate(270deg);-o-transform:rotate(270deg);'>"+ location+ "</div></td>";

InputStream is = getAssets().open("My_Report.html");

int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);

map.put("VERTICALTEXT", verticalLoc);
map.put("STATE", getvalue("State", "Information", ""));
map.put("TIMEZONE", getvalue("Time_Zone", "Information", ""));

String htmlStr = getHTMLReport(new String(buffer), map);

htmlWorker.parse(new StringReader(htmlStr));

PdfContentByte cb = writer.getDirectContent();
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.saveState();
cb.beginText();
cb.moveText(x, y);
cb.setFontAndSize(bf, 12);
cb.showText(text);
cb.endText();
cb.restoreState();
document.newPage();

document.close();

openPdfIntent(FILE);

Canvas を使用してテキストを回転させ、マップをさらに表示用に渡すことはできますか?

私はAndroid Canvasとitextpdfが初めてなので助けてください。

ありがとう!

4

0 に答える 0