1

I trying to convert Html to pdf using pd4ml. Loaded pd4ml.jar in lib folder. I am getting the error

Error. ss_css2.jar is not in the classpath.

Is there any other jar I have to download?

My code is :

private void runConverter(String url, String outputPath)
        throws InvalidParameterException, MalformedURLException, IOException {  
    File output = new File(outputPath);  
    java.io.FileOutputStream fos = new java.io.FileOutputStream(output);  

    PD4ML pd4ml = new PD4ML();  

    pd4ml.setHtmlWidth(userSpaceWidth); // set frame width of "virtual web browser"   

    // choose target paper format and "rotate" it to landscape orientation  
    pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));   

    // define PDF page margins  
    pd4ml.setPageInsetsMM(new Insets(topValue, leftValue, bottomValue, rightValue));   

    // source HTML document also may have margins, could be suppressed this way   
    // (PD4ML *Pro* feature):  
    pd4ml.addStyle("BODY {margin: 0}", true);  

    // If built-in basic PDF fonts are not sufficient or   
    // if you need to output non-Latin texts,  
    // TTF embedding feature should help (PD4ML *Pro*)  
    pd4ml.useTTF("c:/windows/fonts", true);  

    pd4ml.render(new URL(url), fos); // actual document conversion from URL to file  
    fos.close();  

    System.out.println( outputPath + "\ndone." );
}
Zereges
  • 5,139
  • 1
  • 25
  • 49
Pratty
  • 85
  • 2
  • 13

1 Answers1

1

You should add to classpath all jars on which depends pd4ml

More simple solution - start using or to dependency management and add pd4ml as dependencies.

Or googled all required jars for pd4ml, or try to run and add jars one by one

Pd4Cmd execution requires pd4ml.jar and ss_css2.jar are in the classpath.

(c) http://pd4ml.com/html-to-pdf-command-line-tool.htm

Batiaev
  • 1,173
  • 1
  • 14
  • 30