Android™
Android™
Add an External Style Sheet for MHT Conversion
See more MHT / HTML Email Examples
Demonstrates Mht.AddExternalStyleSheet, which adds a style-sheet URL to the list of external CSS resources downloaded and embedded during conversion.
Background. This is normally unnecessary because Chilkat automatically discovers
references present in the static HTML. It is useful when a stylesheet is applied by means Chilkat cannot detect from the static markup.Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CkMht mht = new CkMht();
// Add an external style-sheet URL to the list of CSS resources downloaded and embedded during
// conversion. This is normally unnecessary because Chilkat automatically discovers
// <link rel="stylesheet"> references in the static HTML.
mht.AddExternalStyleSheet("https://example-code.com/crumb/style.css");
// Create the MHT web archive. The external style sheet is downloaded and embedded.
String mhtText = mht.getMHT("https://example-code.com/crumb/index.html");
if (mht.get_LastMethodSuccess() == false) {
Log.i(TAG, mht.lastErrorText());
return;
}
Log.i(TAG, mhtText);
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}