public class HtmlElementSizeOutputMode
extends java.lang.Object
Examples:
Shows how to preserve negative indents in the output .html.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a table with a negative indent, which will push it to the left past the left page boundary.
Table table = builder.startTable();
builder.insertCell();
builder.write("Row 1, Cell 1");
builder.insertCell();
builder.write("Row 1, Cell 2");
builder.endTable();
table.setLeftIndent(-36);
table.setPreferredWidth(PreferredWidth.fromPoints(144.0));
builder.insertBreak(BreakType.PARAGRAPH_BREAK);
// Insert a table with a positive indent, which will push the table to the right.
table = builder.startTable();
builder.insertCell();
builder.write("Row 1, Cell 1");
builder.insertCell();
builder.write("Row 1, Cell 2");
builder.endTable();
table.setLeftIndent(36.0);
table.setPreferredWidth(PreferredWidth.fromPoints(144.0));
// When we save a document to HTML, Aspose.Words will only preserve negative indents
// such as the one we have applied to the first table if we set the "AllowNegativeIndent" flag
// in a SaveOptions object that we will pass to "true".
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
{
options.setAllowNegativeIndent(allowNegativeIndent);
options.setTableWidthOutputMode(HtmlElementSizeOutputMode.RELATIVE_ONLY);
}
doc.save(getArtifactsDir() + "HtmlSaveOptions.NegativeIndent.html", options);
String outDocContents = FileUtils.readFileToString(new File(getArtifactsDir() + "HtmlSaveOptions.NegativeIndent.html"), StandardCharsets.UTF_8);
if (allowNegativeIndent) {
Assert.assertTrue(outDocContents.contains(
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:-41.65pt; border:0.75pt solid #000000; -aw-border:0.5pt single #000000; -aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
Assert.assertTrue(outDocContents.contains(
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; -aw-border:0.5pt single #000000; -aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
}
else
{
Assert.assertTrue(outDocContents.contains(
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"border:0.75pt solid #000000; -aw-border:0.5pt single #000000; -aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
Assert.assertTrue(outDocContents.contains(
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; -aw-border:0.5pt single #000000; -aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
}
| Modifier and Type | Field and Description |
|---|---|
static int |
ALL
All element sizes, both in absolute and relative units, specified in the document are exported.
|
static int |
length |
static int |
NONE
Element sizes are not exported.
|
static int |
RELATIVE_ONLY
Element sizes are exported only if they are specified in relative units in the document.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String htmlElementSizeOutputModeName) |
static java.lang.String |
getName(int htmlElementSizeOutputMode) |
static int[] |
getValues() |
static java.lang.String |
toString(int htmlElementSizeOutputMode) |
public static int ALL
public static int RELATIVE_ONLY
public static int NONE
public static int length