We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Html page style ,css,color are missing and getting text alone in pdf - Android

How to convert HTML/HTM to PDF using Aspose android ?

Thanks
bright

@brightraj,

You can either use Aspose.Words for .NET (if you are using Xamarin.Android platform) or Aspose.Words for Android via Java API to convert HTML document to PDF on your Android devices. The code will look like this:

Document doc = new Document("E:\\temp\\input.html");
doc.save("E:\\temp\\19.2.pdf");

You can also perform HTML to PDF conversion by using Aspose.PDF for Android via Java API. Please refer to Aspose.PDF for Android via Java documentation for details:

Please let us know if you need more information; we are always glad to help you.

Thanks !!!

I tried the above code it working. But the html page style ,css,color are missing and getting text alone.

Thanks
bright

@brightraj,

What Aspose API (Aspose.Words or Aspose.PDF) are you getting this problem with?

Please ZIP and upload your input HTML file (along with any external CSS files) and Aspose generated PDF file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

Have used Aspose.Words for Android via java for conversion . Please find the attachment in the zip.

Thanks
brightzip.zip (1.4 KB)

@brightraj

You have only attached the input HTML file. Please also attach the Aspose.Words generated PDF file showing the undesired behavior here for testing. Thanks for your cooperation.

Have attached the exact output screenshot of the generated PDF looks like .Hope this will help you.

Thanks,
Brightoutput.zip (313.4 KB)

@brightraj,

There is following line in your “another_page.html” file:

<link rel="stylesheet" type="text/css" href="style/style.css" title="style" />

Please make sure that both style.css and another_page.html files are in the same folder.

In case the problem still remains, please also attach this style.css and the actual Aspose.Words generated PDF (not the screenshot) file here for further testing. Thanks for your cooperation.

Let me explain my scenario , i will get random/dynamic html files for the PDF conversion . So i will have html file alone not the style.css. Hope you understood now and attaching Aspose.Words generated PDF with input html file .

Thanks
brightconverted output.zip (18.0 KB)

@brightraj,

You have attached the “another_page.html” and “output.pdf” documents. Please also provide a comparison screenshot highlighting the problematic areas in Aspose.Words generated PDF file with respect to your input HTML and attach it here for our reference. Thanks for your cooperation.

Have attached the comparison document .Please have a look.
comparison_doc.zip (464.1 KB)

@brightraj,

But, this is how your HTML appears in browsers on our end:

Please make sure that both style.css and another_page.html files are in the same folder.

In case the problem still remains, please also ZIP and attach this style.css file here for further testing. Thanks for your cooperation.

Ok . But the original html file looks like what i sent in the attachment . I do not have the style.css because i downloaded the html from site. Can you test and share any sample html file contains text,image etc . So we both are in same observation.

@brightraj,

It looks like your web browser has cached the CSS file.

Generally, Aspose.Words mimics the behavior of MS Word i.e. if you convert the HTML file to PDF by using Aspose.Words, the output will look similar to what MS Word produces.

However, it is not always guaranteed that the Aspose.Words and MS Word generated output documents will look exactly the same as the input HTML file shown in web browsers. This is because Aspose.Words was originally designed to work with Microsoft Word documents and HTML documents are quite different. Hope, this helps.

So how to over come this issue? Anything there

@brightraj,

Please make sure that both style.css and another_page.html files are in the same folder. Also, please refer to the following article.
Load in the HTML (.HTML, .XHTML, .MHTML) Format