when convert image to html face some issue
private void saveImageAsHtml(Uri imageUri) {
try {
// Convert URI to a file path
ContentResolver contentResolver = getContentResolver();
// Open an InputStream using the URI
InputStream inputStream = contentResolver.openInputStream(imageUri);
Bitmap urlToBitmap= BitmapFactory.decodeStream(inputStream);
// String imagePath = getRealPathFromURI(imageUri);
Bitmap addeffectBitmap=preprocessImage(urlToBitmap);
// Initialize the Aspose.Words Document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert the image into the document
builder.insertImage(urlToBitmap);
// Define the HTML file path
File htmlFile = new File(getFilesDir(), "Output3.html");
doc.save(htmlFile.getAbsolutePath());
// Read the saved HTML file as a string
String htmlContent = readHtmlFileAsString(htmlFile);
//
// // Show the HTML content in an EditText
Log.d("%%%", "saveImageAsHtml: "+htmlContent);
binding.etText.setText(htmlContent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "Error saving HTML: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
when i convert then show this types reult:-
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="Aspose.Words for Android via Java 24.6.0" />
<title></title>
</head><body style="font-family:'Times New Roman'; font-size:12pt">
<div><p style="margin-top:0pt; margin-bottom:0pt"><img src="Output3.001.png" width="624" height="133" alt="" style="-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-wrap-type:inline; -aw-top-pos:0pt" /></p></div>
</body>
and when i try same image in “Convert Image To HTML Online” accurate result
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="Aspose.Words for .NET 24.11.1" />
<title></title>
<style type="text/css">
body {
font-family: 'Times New Roman';
font-size: 12pt
}
p {
margin: 0pt
}
</style>
</head><body>
<div><p style="margin-top:1.65pt; margin-right:6pt; text-indent:89.25pt; line-height:46.35pt"><span style="font-family:Calibri; font-size:33pt">Company</span><span style="font-family:Calibri; font-size:33pt; letter-spacing:139.15pt"> </span><span style="font-family:Calibri; font-size:33pt">Contact</span><span style="font-family:Calibri; font-size:33pt; letter-spacing:29.65pt"> </span><span style="font-family:Calibri; font-size:33pt">|</span><span style="font-family:Calibri; font-size:33pt; letter-spacing:9.45pt"> </span><span style="font-family:Calibri; font-size:33pt">Country Alfreds</span><span style="font-family:Calibri; font-size:33pt; letter-spacing:18.25pt"> </span><span style="font-family:Calibri; font-size:33pt">Futterkiste</span><span style="font-family:Calibri; font-size:33pt; letter-spacing:66.2pt"> </span><span style="font-family:Calibri; font-size:33pt">{Maria</span><span style="font-family:Calibri; font-size:33pt; letter-spacing:83.85pt"> </span><span style="font-family:Calibri; font-size:33pt">Germany</span></p><p style="margin-top:8.3pt; margin-left:1.45pt; text-align:justify; line-height:43.9pt"><span style="font-family:Calibri; font-size:36pt">Centro</span><span style="font-family:Calibri; font-size:36pt; letter-spacing:230.6pt"> </span><span style="font-family:Calibri; font-size:36pt">Francisco</span><span style="font-family:Calibri; font-size:36pt; letter-spacing:34.7pt"> </span><span style="font-family:Calibri; font-size:36pt">||Mexico</span></p></div>
</body>
so fix this issue in android java when convert image to html face some issue
private void saveImageAsHtml(Uri imageUri) {
try {
// Convert URI to a file path
ContentResolver contentResolver = getContentResolver();
// Open an InputStream using the URI
InputStream inputStream = contentResolver.openInputStream(imageUri);
Bitmap urlToBitmap= BitmapFactory.decodeStream(inputStream);
// String imagePath = getRealPathFromURI(imageUri);
Bitmap addeffectBitmap=preprocessImage(urlToBitmap);
// Initialize the Aspose.Words Document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert the image into the document
builder.insertImage(urlToBitmap);
// Define the HTML file path
File htmlFile = new File(getFilesDir(), "Output3.html");
doc.save(htmlFile.getAbsolutePath());
// Read the saved HTML file as a string
String htmlContent = readHtmlFileAsString(htmlFile);
//
// // Show the HTML content in an EditText
Log.d("%%%", "saveImageAsHtml: "+htmlContent);
binding.etText.setText(htmlContent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "Error saving HTML: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
when i convert then show this types reult:-
and when i try same image in “Convert Image To HTML Online” accurate result
so fix this issue in android java