I am analysing Aspose.Pdf (v19.10) to convert my html to Pdf in java.
But i am facing style issues.
SourceCode.zip (527.7 KB)
-
Table alignment is breaking
-
Charts and graphs are not inside the page view.
I am attaching my source code, html source and pdf generated .
Please check and help on this.
Below is my java code.
public class SamplePDF {
public static void main(String[] args) {
generatePDFmain();
}
private static void generatePDFmain() {
License license = new License();
InputStream licenceStream = null;
String basePath = "/Users/shubham/Downloads/";
try {
licenceStream = streamFromClasspathResourceStatic("Aspose.Pdf.lic1");
license.setLicense(licenceStream);
HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);
PageInfo page = new PageInfo();
page.setMargin(new MarginInfo(10, 10, 10, 10));
htmloptions.setPageInfo(page);
htmloptions.setInputEncoding("utf-8");
final Document pdfDocument = new Document(basePath + "htmlToPdfWithCharts.htm", htmloptions);
pdfDocument.save(basePath + "samplePdf", com.aspose.pdf.SaveFormat.Pdf);
} catch (Exception e) {
throw new RuntimeException("Error while generating word doc using Aspose.pdf." + e.getLocalizedMessage(),
e);
} finally {
if (licenceStream != null) {
try {
licenceStream.close();
} catch (IOException e) {
throw new RuntimeException(
"Error while generating word doc using Aspose.pdf." + e.getLocalizedMessage(), e);
}
}
}
}
private static InputStream streamFromClasspathResourceStatic(final String resourceClassPath) {
final Class<SamplePDF> clazz = SamplePDF.class;
final ClassLoader clLoader = clazz.getClassLoader();
final InputStream inStream = clLoader.getResourceAsStream(resourceClassPath);
return inStream;
}
}