新手请教高手一个问题,关于pdf转换html的问题!
我目前也确实实现了转换,但是只局限于英文的pdf,中文的就不行了,转换后的html一片空白,。很困惑,,,
我的代码如下:
import java.io.File;
import java.io.IOException;
public class ConvertPdf
{
private static String INPUT_PATH;
private static String PROJECT_PATH;
public static void convertToHtml(String file, String project)
{
INPUT_PATH = file;
PROJECT_PATH = project;
if(checkContentType()==0)
{
toHtml();
}
}
private static int checkContentType()
{
String type = INPUT_PATH.substring(INPUT_PATH.lastIndexOf(".") + 1, INPUT_PATH.length())
.toLowerCase();
if (type.equals("pdf"))
return 0;
else
return 9;
}
private static void toHtml()
{
if(new File(INPUT_PATH).isFile())
{
try
{
String cmd = "cmd /c start c:\\xpdf\\pdftohtml.exe -enc UTF-8 \"" + INPUT_PATH + "\" \"" +PROJECT_PATH+ "\"";
Runtime.getRuntime().exec(cmd);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
public static void main(String[] args)
{
ConvertPdf cpdf=new ConvertPdf();
ConvertPdf.convertToHtml("C:\\o.pdf", "c:\\b.html");
}
}
我感觉不是代码的问题,有可能是配置的问题,有个中文的配置文件,我我不知道该如何配置!!! 文件如下:
#----- begin Chinese Simplified support package
cidToUnicode Adobe-GB1 xpdf-chinese-simplified\Adobe-GB1.cidToUnicode
unicodeMap ISO-2022-CN xpdf-chinese-simplified\ISO-2022-CN.unicodeMap
unicodeMap EUC-CN xpdf-chinese-simplified\EUC-CN.unicodeMap
unicodeMap GBK xpdf-chinese-simplified\GBK.unicodeMap
cMapDir Adobe-GB1 xpdf-chinese-simplified\CMap
toUnicodeDir xpdf-chinese-simplified\CMap
fontDir C:\WINDOWS\Fonts
displayCIDFontTT Adobe-GB1 C:\WINDOWS\Fonts\simhei.ttf
#----- end Chinese Simplified support package
谢谢各位老大,小弟感激不尽 呵呵
相关推荐
itext7 html转换为pdf
使用itext7将html转换为pdf,支持中文,可以生产页眉,页脚,这个是windows系统的,里面还需要自己在pom.xml中导入相关的包,不会的可以找我
html2pdf(html转换pdf)
html2pdf(html转换pdf), html2canvas+jspdf+pdfmake+jquery 页面直接html生成pdf文件,避免了,过多人下载pdf,消耗服务器资源的一个解决方案。如果并发量大的情况下,很好的解决了服务器的压力。 自己研究了好长时间终于搞定了
poi创建word、生成html、itext将html转换成pdf。pd4ml将jsp转成pdf
1.用户导入word生成pdf -首先导入word的时候读取word里面的全部内容。调用(ReadAndWriteDoc)然后将内容 传送到createPdf里面生成pdf。导入的时候读取采用poi /生成的时候采用的是itext 2.通过读取数据库更改原始的.doc文件、读取数据库生成pdf。 -然后更改webRoot下面的.doc文件。然后调用ReadWriteAndDownloadDocAction生成一 个新的word。 -读取数据库文件生成pdf调用createDBPdf类。 3.WordToHtmlPO类可以将word转换成html(itext) 4.将html转换成pdf(itext)
Android平台下,将Html文本转换为PDF格式并输出
安卓下可用的HTML转PDF代码,支持中文和单独的图片
html转pdf,ITEXT转HTML为PDF解决中文不换行问题
1、core-renderer.jar该jar包修改过中文不换行问题 public static String getConversionHtmlCode(String linkcss,String htmlCode,String title){ String css = ""; css +="<style>"; css +="table{"; css +=" border-collapse: collapse;"; css +=" font-size: 15px;"; css +=" width: 98%;"; css +="}"; css +=""; css +="td{"; css +=" border: 1px solid #ddd;"; css +=" text-align: left;"; css +=" white-space: nowrap"; css +="}"; css +="th{"; css +=" border: 1px solid #ddd;"; css +=" text-align: left;"; css +="}"; css +="</style>"; String html = "<html><head>"+css+"</head><body margin:0;margin-top: 15px;margin-bottom: 15px; text-align: center; font-family:SimSun;\" >"+ title+""+ htmlCode + "</body></html>"; System.out.println("html:"+html); return html; }


Web 开发
