換行的時(shí)候確認(rèn)不了長(zhǎng)度:
import java.awt.*;
public class Test {
public static void main(String[] args) {
String str1 = "淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘淘";
String str2 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
String str4 = "cccccccccccccccccccccccccccccccccccccccccccccccccccc";
String str3 = "111111111111111111111111111111111111111111111111111111111111111";
FontMetrics fontMetrics = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(1, 1, Transparency.TRANSLUCENT).getGraphics().getFontMetrics();
int width1 = fontMetrics.stringWidth(str1);
int width2 = fontMetrics.stringWidth(str2);
int width3 = fontMetrics.stringWidth(str3);
int width4 = fontMetrics.stringWidth(str4);
System.out.println("寬度 str1: " + width1);
System.out.println("寬度 str2: " + width2);
System.out.println("寬度 str3: " + width3);
System.out.println("寬度 str4: " + width4);
}
}
運(yùn)行結(jié)果:
寬度 str1: 444
寬度 str2: 364
寬度 str3: 441
寬度 str4: 312文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-637831.html
這些長(zhǎng)度在pdf里面都是一樣的,但是這里運(yùn)行的寬度確實(shí)不同的,目前這個(gè)問(wèn)題還解決不了。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-637831.html
到了這里,關(guān)于PDF換行的難度,誰(shuí)能解決?的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!