PdfBox-Android icon indicating copy to clipboard operation
PdfBox-Android copied to clipboard

Writing vertical text with IDENTITY-V

Open Phyambre opened this issue 9 years ago • 2 comments

Hi,

I need to write text vertically (Japanese traditional writing). I found that there is a CMAP called IDENTITY-V to write vertically. However, when I load an external font, I can find no way to load such CMAP. What I do is PDType0Font font = PDType0Font.load(doc, fontInputStream); How can I write vertically?

Phyambre avatar Feb 16 '16 18:02 Phyambre

I've tried a couple different things to get this to work, but they haven't worked. If you figure out how to get this to work in the desktop version, let me know and I can implement the necessary changes. Sorry up that.

TomRoush avatar Apr 03 '16 21:04 TomRoush

Hi again,

Well, at this very moment I can write vertically by repositioning the cursor after every character:

content.setFont(font, fontSize);
for (int i = 0; i < text.length(); i++) {
    content.beginText();
    content.newLineAtOffset(x, y);
    content.showText(String.valueOf(text.charAt(i)));
    content.endText();
    y -= fontSize;
}

I guess this is not very efficient (maybe because I have to call beginText() and endText() on every character, otherwise it makes a mess), but it is enough to publish the first version of my app. After I publish, I will check the IDENTITY-V problem. I have never used the desktop version of PDFBox, but for Android the guys of Itext did it, so maybe we can get any idea from there: http://what-when-how.com/itext-5/using-fonts-in-itext-part-1/ However, after seeing that post I am not sure if IDENTITY-V does vertical writing or if it just rotates the text. My understanding was that IDENTITY-V did the former, but if it is the latter, it wasn't the thing I was looking for.

Phyambre avatar Apr 04 '16 17:04 Phyambre