iT邦幫忙

0

PDF撰寫(JSP)

以下是我參考網路上的程式寫的,然後在中文字型的部份,若是中文字的話,PDF上就不會顯示出「邦幫忙」三個字,若我在這架構下的話,我應該要怎麼寫會比較好呢?麻煩各位指導我一下,謝謝!!!

public void doGet(HttpServletRequest request,HttpServletResponse response){
Document document = new Document();

	try {
		PdfWriter.getInstance(document, response.getOutputStream());
		document.open();
		
		document.add(new Paragraph("VVVVVV邦幫忙"));
		document.add(new Paragraph("1122"));
	} catch (DocumentException e) {
		System.err.println(e.getMessage());
	} catch (IOException e) {
		System.err.println(e.getMessage());
	}
	
	document.close();

}

fillano iT邦超人 1 級 ‧ 2017-11-03 17:47:02 檢舉
https://developers.itextpdf.com/examples/font-examples/clone-language-specific-examples
klm2242 iT邦研究生 1 級 ‧ 2017-12-20 11:49:49 檢舉
謝謝你!
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
小碼農米爾
iT邦高手 1 級 ‧ 2017-11-03 18:35:30

原來是 JSP 我好像跑錯地方了,不過還是給你參考看看。

Paragraph 需要指定字型檔 (.ttf),來源如下。

中文: cwTeXHei-zhonly.ttf 是 Google 的中文字型,下載網址
英文: arial.ttf 是英文字型,要到「控制台」→「字型」裡面複製出來。

klm2242 iT邦研究生 1 級 ‧ 2017-12-20 11:50:00 檢舉

謝謝你

我要發表回答

立即登入回答