Back to Devexpress

SubDocument.AppendDocumentContent(String, DocumentFormat) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-subdocument-dot-appenddocumentcontent-x28-system-dot-string-devexpress-dot-xtrarichedit-dot-documentformat-x29.md

latest8.0 KB
Original Source

SubDocument.AppendDocumentContent(String, DocumentFormat) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Appends content from the file.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
DocumentRange AppendDocumentContent(
    string fileName,
    DocumentFormat format
)
vb
Function AppendDocumentContent(
    fileName As String,
    format As DocumentFormat
) As DocumentRange

Parameters

NameTypeDescription
fileNameString

A string representing a filename of the document whose content is being appended.

| | format | DocumentFormat |

A DocumentFormat enumeration specifying the format of the data contained in the file.

|

Returns

TypeDescription
DocumentRange

A DocumentRange representing a range with the appended content.

|

Remarks

The AppendDocumentContent method imports the specified file into the internal document model. If the format parameter is set to DocumentFormat.Undefined, the importer attempts to auto detect the format of the specified file.

If the format auto detect fails, a fallback format is used. Currently the fallback format is plain text.

After the file is successfully imported, the new document model is inserted at the end of the main document.

The appended text starts with a new paragraph and preserves formatting. It is appended to an existing section and gets all section details (header, footer, page and print layout).

If the text being inserted contains document styles which are not present in the current document, the styles are copied to the resulting document.

If the document whose content is being inserted contains floating objects, such as pictures or text boxes, they are inserted into the corresponding positions in a newly created range.

The following code snippets (auto-collected from DevExpress Examples) contain references to the AppendDocumentContent(String, DocumentFormat) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

how-to-use-docvariable-fields/CS/DocumentVariablesExample/Form1.cs#L68

csharp
private void richEditControl1_MailMergeRecordFinished(object sender, MailMergeRecordFinishedEventArgs e) {
    e.RecordDocument.AppendDocumentContent("Docs\\bungalow.docx", DocumentFormat.OpenXml);
}

word-document-api-use-docvariable-fields/CS/Program.cs#L91

csharp
{
    e.RecordDocument.AppendDocumentContent("Docs\\bungalow.docx", DocumentFormat.OpenXml);
}

word-document-api-examples/CS/CodeExamples/BasicActions.cs#L37

csharp
// Insert content from the file at the document end.
wordProcessor.Document.AppendDocumentContent("Documents//MovieRentals.docx",DocumentFormat.OpenXml);
#endregion #MergeDocuments

dxrichedit-for-wpf-how-to-implement-progress-indicator/CS/MainWindow.xaml.cs#L49

csharp
private void richEditControl1_MailMergeRecordFinished(object sender, MailMergeRecordFinishedEventArgs e) {
    e.RecordDocument.AppendDocumentContent("Docs\\bungalow.docx", DocumentFormat.OpenXml);
}

wpf-richedit-use-docvariable-fields/CS/MainWindow.xaml.cs#L65

csharp
private void richEditControl1_MailMergeRecordFinished(object sender, MailMergeRecordFinishedEventArgs e) {
    e.RecordDocument.AppendDocumentContent("Docs\\bungalow.docx", DocumentFormat.OpenXml);
}

how-to-use-docvariable-fields/VB/DocumentVariablesExample/Form1.vb#L67

vb
Private Sub richEditControl1_MailMergeRecordFinished(ByVal sender As Object, ByVal e As MailMergeRecordFinishedEventArgs)
    e.RecordDocument.AppendDocumentContent("Docs\bungalow.docx", DocumentFormat.OpenXml)
End Sub

word-document-api-use-docvariable-fields/VB/Program.vb#L72

vb
Private Shared Sub wordProcessor_MailMergeRecordFinished(ByVal sender As Object, ByVal e As MailMergeRecordFinishedEventArgs)
    e.RecordDocument.AppendDocumentContent("Docs\bungalow.docx", DocumentFormat.OpenXml)
End Sub

word-document-api-examples/VB/CodeExamples/BasicActions.vb#L40

vb
' Insert content from the file at the document end.
            wordProcessor.Document.AppendDocumentContent("Documents//MovieRentals.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
#End Region ' #MergeDocuments

dxrichedit-for-wpf-how-to-implement-progress-indicator/VB/MainWindow.xaml.vb#L50

vb
Private Sub richEditControl1_MailMergeRecordFinished(ByVal sender As Object, ByVal e As MailMergeRecordFinishedEventArgs)
    e.RecordDocument.AppendDocumentContent("Docs\bungalow.docx", DocumentFormat.OpenXml)
End Sub

wpf-richedit-use-docvariable-fields/VB/MainWindow.xaml.vb#L64

vb
Private Sub richEditControl1_MailMergeRecordFinished(ByVal sender As Object, ByVal e As MailMergeRecordFinishedEventArgs)
    e.RecordDocument.AppendDocumentContent("Docs\bungalow.docx", DocumentFormat.OpenXml)
End Sub

See Also

SubDocument Interface

SubDocument Members

DevExpress.XtraRichEdit.API.Native Namespace