public class FieldRD extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Identifies a file to include when you create a table of contents, a table of authorities, or an index with the TOC, TOA, or INDEX field
Examples:
Shows to use the RD field to create a table of contents entries from headings in other documents.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Use a document builder to insert a table of contents,
// and then add one entry for the table of contents on the following page.
builder.insertField(FieldType.FIELD_TOC, true);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
builder.writeln("TOC entry from within this document");
// Insert an RD field, which references another local file system document in its FileName property.
// The TOC will also now accept all headings from the referenced document as entries for its table.
FieldRD field = (FieldRD) builder.insertField(FieldType.FIELD_REF_DOC, true);
field.setFileName("ReferencedDocument.docx");
field.isPathRelative(true);
Assert.assertEquals(field.getFieldCode(), " RD ReferencedDocument.docx \\f");
// Create the document that the RD field is referencing and insert a heading.
// This heading will show up as an entry in the TOC field in our first document.
Document referencedDoc = new Document();
DocumentBuilder refDocBuilder = new DocumentBuilder(referencedDoc);
refDocBuilder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
refDocBuilder.writeln("TOC entry from referenced document");
referencedDoc.save(getArtifactsDir() + "ReferencedDocument.docx");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.RD.docx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getFileName()
Gets the name of the file to include when generating a table of contents, table of authorities, or index.
|
int |
getSwitchType(java.lang.String switchName) |
boolean |
isPathRelative()
Gets whether the path is relative to the current document.
|
void |
isPathRelative(boolean value)
Sets whether the path is relative to the current document.
|
void |
setFileName(java.lang.String value)
Sets the name of the file to include when generating a table of contents, table of authorities, or index.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getFileName()
Examples:
Shows to use the RD field to create a table of contents entries from headings in other documents.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Use a document builder to insert a table of contents,
// and then add one entry for the table of contents on the following page.
builder.insertField(FieldType.FIELD_TOC, true);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
builder.writeln("TOC entry from within this document");
// Insert an RD field, which references another local file system document in its FileName property.
// The TOC will also now accept all headings from the referenced document as entries for its table.
FieldRD field = (FieldRD) builder.insertField(FieldType.FIELD_REF_DOC, true);
field.setFileName("ReferencedDocument.docx");
field.isPathRelative(true);
Assert.assertEquals(field.getFieldCode(), " RD ReferencedDocument.docx \\f");
// Create the document that the RD field is referencing and insert a heading.
// This heading will show up as an entry in the TOC field in our first document.
Document referencedDoc = new Document();
DocumentBuilder refDocBuilder = new DocumentBuilder(referencedDoc);
refDocBuilder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
refDocBuilder.writeln("TOC entry from referenced document");
referencedDoc.save(getArtifactsDir() + "ReferencedDocument.docx");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.RD.docx");
public void setFileName(java.lang.String value)
throws java.lang.Exception
Examples:
Shows to use the RD field to create a table of contents entries from headings in other documents.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Use a document builder to insert a table of contents,
// and then add one entry for the table of contents on the following page.
builder.insertField(FieldType.FIELD_TOC, true);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
builder.writeln("TOC entry from within this document");
// Insert an RD field, which references another local file system document in its FileName property.
// The TOC will also now accept all headings from the referenced document as entries for its table.
FieldRD field = (FieldRD) builder.insertField(FieldType.FIELD_REF_DOC, true);
field.setFileName("ReferencedDocument.docx");
field.isPathRelative(true);
Assert.assertEquals(field.getFieldCode(), " RD ReferencedDocument.docx \\f");
// Create the document that the RD field is referencing and insert a heading.
// This heading will show up as an entry in the TOC field in our first document.
Document referencedDoc = new Document();
DocumentBuilder refDocBuilder = new DocumentBuilder(referencedDoc);
refDocBuilder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
refDocBuilder.writeln("TOC entry from referenced document");
referencedDoc.save(getArtifactsDir() + "ReferencedDocument.docx");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.RD.docx");
value - The name of the file to include when generating a table of contents, table of authorities, or index.java.lang.Exceptionpublic boolean isPathRelative()
Examples:
Shows to use the RD field to create a table of contents entries from headings in other documents.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Use a document builder to insert a table of contents,
// and then add one entry for the table of contents on the following page.
builder.insertField(FieldType.FIELD_TOC, true);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
builder.writeln("TOC entry from within this document");
// Insert an RD field, which references another local file system document in its FileName property.
// The TOC will also now accept all headings from the referenced document as entries for its table.
FieldRD field = (FieldRD) builder.insertField(FieldType.FIELD_REF_DOC, true);
field.setFileName("ReferencedDocument.docx");
field.isPathRelative(true);
Assert.assertEquals(field.getFieldCode(), " RD ReferencedDocument.docx \\f");
// Create the document that the RD field is referencing and insert a heading.
// This heading will show up as an entry in the TOC field in our first document.
Document referencedDoc = new Document();
DocumentBuilder refDocBuilder = new DocumentBuilder(referencedDoc);
refDocBuilder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
refDocBuilder.writeln("TOC entry from referenced document");
referencedDoc.save(getArtifactsDir() + "ReferencedDocument.docx");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.RD.docx");
public void isPathRelative(boolean value)
throws java.lang.Exception
Examples:
Shows to use the RD field to create a table of contents entries from headings in other documents.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Use a document builder to insert a table of contents,
// and then add one entry for the table of contents on the following page.
builder.insertField(FieldType.FIELD_TOC, true);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
builder.writeln("TOC entry from within this document");
// Insert an RD field, which references another local file system document in its FileName property.
// The TOC will also now accept all headings from the referenced document as entries for its table.
FieldRD field = (FieldRD) builder.insertField(FieldType.FIELD_REF_DOC, true);
field.setFileName("ReferencedDocument.docx");
field.isPathRelative(true);
Assert.assertEquals(field.getFieldCode(), " RD ReferencedDocument.docx \\f");
// Create the document that the RD field is referencing and insert a heading.
// This heading will show up as an entry in the TOC field in our first document.
Document referencedDoc = new Document();
DocumentBuilder refDocBuilder = new DocumentBuilder(referencedDoc);
refDocBuilder.getCurrentParagraph().getParagraphFormat().setStyleName("Heading 1");
refDocBuilder.writeln("TOC entry from referenced document");
referencedDoc.save(getArtifactsDir() + "ReferencedDocument.docx");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.RD.docx");
value - Whether the path is relative to the current document.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)