Html to pdf in Aspose.Pdf (v19.10) conversion style issue

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;
}

}

@shubham23

Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue on page 6 and 8. A ticket with ID PDFJAVA-38984 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

Hello @Farhan.Raza ,

Can you please tell me by when i can expect the resolution for the issue.
Also you mentioned issue in page 6 and 8 only, will request you to please consider the issue with table alignments also.
Also please consider extra non-needed space inside pdf .
For example: In page 2 , so much extra space is there, which is not required.

Also one more query, when i try to convert same html to word(.doc) , the same styling issue persist.
Also attaching the source.Archive 2.zip (277.3 KB)

Thanks

@shubham23

Please note that the issue has been logged under free support model and will be investigated on first come first serve basis. Therefore, it may take some months to resolve. As soon as we have some definite updates regarding ticket resolution, we will let you know.

Furthermore, we also offer paid support model where issues are resolved on urgent basis and have priority over the issues logged under free support model. You may check our Paid Support options for your reference.

Moreover, would you please share some screenshots while mentioning page numbers for other problems you are referring to.

About conversion of HTML to DOC, we are checking from Aspose.Words perspective and will update you soon.

@shubham23

We have tested the scenario using the latest version of Aspose.Words for .NET 19.11 with following code example. We have not found the style issue in output document. Please check the attached output document.
19.11.zip (22.6 KB)

Document doc = new Document(MyDir + @"htmlToPdfWithCharts.htm");
doc.Save(MyDir + @"19.11.doc");  

If you still face problem, please share the screenshots of problematic sections of output document and expected output Word document. We will investigate this issue further and provide you more informaton on it.

Hello @tahir.manzoor

I already have ASPOSE.pdf , and as per my knowledge i can use it for conversion of html to pdf as well as pdf to doc. So i used it to convert my html to pdf format in java and then i used the same generated pdf for doc conversion.
As per my previous issue (mentioned above in the queue) html to pdf conversion was creating some formatting and alignment issue. As i am using the same malformed pdf for doc conversion , hence doc file is also generating with same issues.
So can you assure me that if the above issue is resolved for pdf then its converted doc will also be fine.

Attaching pdf and doc

Archive 3.zip (675.5 KB)

Source code :

private static void generateWordmain() {

License license = new License();

InputStream licenceStream = null ;

String basePath = “/Users/shubham/Downloads/”;

File initialFile = new File(basePath + “htmlToPdfWithCharts19.pdf”);

InputStream targetStream= null ;

try {

targetStream = new FileInputStream(initialFile);

} catch (FileNotFoundException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

try {

licenceStream = streamFromClasspathResourceStatic (“Aspose.Pdf.lic1”);

license.setLicense(licenceStream);

final Document pdfDocument = new Document(targetStream);

pdfDocument.save(basePath + “htmlToPdfWithCharts19.doc”, com.aspose.pdf.SaveFormat. Doc );

} 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);

}

}

}

}

Also @Farhan.Raza
Please check page no 2 -->extra space
page no 5 --> table column heading alignment issue
page n0 6,7 --> graph and charts are going outside the page area.

Screenshots attached : Archive.zip (4.7 MB)

@shubham23

Thank you for elaborating further.

We have further logged below tickets in our issue management system for further investigations and resolutions.

  • PDFJAVA-38999: Problems while converting PDF to DOC
  • PDFJAVA-39000: Problem related to extra space
  • PDFJAVA-39001: Problem with table column heading alignment

Other problem with overflowing of graph and charts is logged already. We will let you know as soon as any update will be available in this regard.