如何将DOCX转换为PDF使用Java(韩国)
我尝试将DOCX转换为PDF。
DOCX文件有韩语 也许您认为BTS歌曲的歌词,
例如。 朋友们 BTS 유난히도유난히도! 처음보는보는다른 땀에땀에밴채만난 뭔가이상했었던 난,넌넌 우리대화는숙제 하루는,하루는하루는 我只是想明白 你好我的外星人 우린우린神秘 그래서더특별한 언젠가언젠가이때때때때 내옆에함께 영원히계속이곳에逗留,嘿 네작은 일곱번의번의추운 오래 这是
我的转换代码。
String k=null;
OutputStream fileForPdf =null;
try {
String fileName=w;
//Below Code is for .doc file
if(fileName.endsWith(".doc"))
{
HWPFDocument doc = new HWPFDocument(new FileInputStream(
fileName));
WordExtractor we=new WordExtractor(doc);
k = we.getText();
fileForPdf = new FileOutputStream(new File(
p));
we.close();
}
//Below Code for
else if(fileName.endsWith(".docx"))
{
XWPFDocument docx = new XWPFDocument(new FileInputStream(
fileName));
// using XWPFWordExtractor Class
XWPFWordExtractor we = new XWPFWordExtractor(docx);
k = we.getText();
fileForPdf = new FileOutputStream(new File(p));
we.close();
}
Document document = new Document();
PdfWriter.getInstance(document, fileForPdf);
document.open();
document.add(new Paragraph(k));
document.close();
fileForPdf.close();
此代码制作PDF文件,但此文件没有韩国歌词
I try convert docx to pdf.
Docx file has korean
maybe you think BTS song's lyrics
Eg.
Friends
BTS
유난히도 반짝였던 서울!
처음 보는 또 다른 세상
땀에 잔뜩 밴 채 만난 넌
뭔가 이상했었던 아이
난 달에서, 넌 별에서
우리 대화는 숙제 같았지
하루는 베프, 하루는 웬수
I just wanna understand
Hello my alien
우린 서로의 mystery
그래서 더 특별한 걸까
언젠가 이 함성 멎을 때 stay, hey
내 옆에 함께 있어줘
영원히 계속 이곳에 stay, hey
네 작은 새끼손가락처럼
일곱 번의 여름과 추운 겨울보다
오래
수많은 약속과 추억들보다
this is my convering code.
String k=null;
OutputStream fileForPdf =null;
try {
String fileName=w;
//Below Code is for .doc file
if(fileName.endsWith(".doc"))
{
HWPFDocument doc = new HWPFDocument(new FileInputStream(
fileName));
WordExtractor we=new WordExtractor(doc);
k = we.getText();
fileForPdf = new FileOutputStream(new File(
p));
we.close();
}
//Below Code for
else if(fileName.endsWith(".docx"))
{
XWPFDocument docx = new XWPFDocument(new FileInputStream(
fileName));
// using XWPFWordExtractor Class
XWPFWordExtractor we = new XWPFWordExtractor(docx);
k = we.getText();
fileForPdf = new FileOutputStream(new File(p));
we.close();
}
Document document = new Document();
PdfWriter.getInstance(document, fileForPdf);
document.open();
document.add(new Paragraph(k));
document.close();
fileForPdf.close();
this code make pdf file But this file didn't have korea lyrics
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试以下方法将.docx文件转换为.pdf文件。
https://simples.dev/simples.dev/java-convert -docx-file-to-pdf-file-using-xdocReport/
You can try the following approach to convert a .docx file to .pdf file.
https://simplesolution.dev/java-convert-docx-file-to-pdf-file-using-xdocreport/