81,092
社区成员
发帖
与我相关
我的任务
分享
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");
}
}