PlainTextDocument
PlainTextDocument(string)
Erstellt ein Nur-Text-Dokument aus einer Datei. Erkennt automatisch das Dateiformat.
public PlainTextDocument(string fileName)
Parameter | Typ | Beschreibung |
---|---|---|
fileName | String | Name der Datei, aus der der Text extrahiert werden soll. |
Ausnahmen
Ausnahme | Bedingung |
---|---|
UnsupportedFileFormatException | Das Dokumentformat wird nicht erkannt oder nicht unterstützt. |
FileCorruptedException | Das Dokument scheint beschädigt zu sein und kann nicht geladen werden. |
Exception | Es liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden. |
IOException | Es liegt eine Ein-/Ausgabeausnahme vor. |
IncorrectPasswordException | Das Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben. |
ArgumentException | Der Name der Datei darf nicht null oder eine leere Zeichenfolge sein. |
Beispiele
Zeigt, wie der Inhalt eines Microsoft Word-Dokuments im Klartext geladen wird.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
doc.Save(ArtifactsDir + "PlainTextDocument.Load.docx");
PlainTextDocument plaintext = new PlainTextDocument(ArtifactsDir + "PlainTextDocument.Load.docx");
Assert.AreEqual("Hello world!", plaintext.Text.Trim());
Siehe auch
- class PlainTextDocument
- namensraum Aspose.Words
- Montage Aspose.Words
PlainTextDocument(string, LoadOptions)
Erstellt ein Nur-Text-Dokument aus einer Datei. Ermöglicht die Angabe zusätzlicher Optionen wie z. B. eines Verschlüsselungskennworts.
public PlainTextDocument(string fileName, LoadOptions loadOptions)
Parameter | Typ | Beschreibung |
---|---|---|
fileName | String | Name der Datei, aus der der Text extrahiert werden soll. |
loadOptions | LoadOptions | Zusätzliche Optionen zum Laden eines Dokuments. Kann seinNull . |
Ausnahmen
Ausnahme | Bedingung |
---|---|
UnsupportedFileFormatException | Das Dokumentformat wird nicht erkannt oder nicht unterstützt. |
FileCorruptedException | Das Dokument scheint beschädigt zu sein und kann nicht geladen werden. |
Exception | Es liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden. |
IOException | Es liegt eine Ein-/Ausgabeausnahme vor. |
IncorrectPasswordException | Das Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben. |
ArgumentException | Der Name der Datei darf nicht null oder eine leere Zeichenfolge sein. |
Beispiele
Zeigt, wie der Inhalt eines verschlüsselten Microsoft Word-Dokuments im Klartext geladen wird.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.Password = "MyPassword";
doc.Save(ArtifactsDir + "PlainTextDocument.LoadEncrypted.docx", saveOptions);
LoadOptions loadOptions = new LoadOptions();
loadOptions.Password = "MyPassword";
PlainTextDocument plaintext = new PlainTextDocument(ArtifactsDir + "PlainTextDocument.LoadEncrypted.docx", loadOptions);
Assert.AreEqual("Hello world!", plaintext.Text.Trim());
Siehe auch
- class LoadOptions
- class PlainTextDocument
- namensraum Aspose.Words
- Montage Aspose.Words
PlainTextDocument(Stream)
Erstellt ein Nur-Text-Dokument aus einem Stream. Erkennt automatisch das Dateiformat.
public PlainTextDocument(Stream stream)
Parameter | Typ | Beschreibung |
---|---|---|
stream | Stream | Der Stream, aus dem der Text extrahiert werden soll. |
Ausnahmen
Ausnahme | Bedingung |
---|---|
UnsupportedFileFormatException | Das Dokumentformat wird nicht erkannt oder nicht unterstützt. |
FileCorruptedException | Das Dokument scheint beschädigt zu sein und kann nicht geladen werden. |
Exception | Es liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden. |
IOException | Es liegt eine Ein-/Ausgabeausnahme vor. |
IncorrectPasswordException | Das Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben. |
ArgumentNullException | Der Stream darf nicht null sein. |
NotSupportedException | Der Stream unterstützt weder Lesen noch Suchen. |
ObjectDisposedException | Der Stream ist ein entsorgtes Objekt. |
Bemerkungen
Das Dokument muss am Anfang des Streams gespeichert werden. Der Stream muss eine zufällige Positionierung unterstützen.
Beispiele
Zeigt, wie der Inhalt eines Microsoft Word-Dokuments mithilfe von Stream im Klartext geladen wird.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
doc.Save(ArtifactsDir + "PlainTextDocument.LoadFromStream.docx");
using (FileStream stream = new FileStream(ArtifactsDir + "PlainTextDocument.LoadFromStream.docx", FileMode.Open))
{
PlainTextDocument plaintext = new PlainTextDocument(stream);
Assert.AreEqual("Hello world!", plaintext.Text.Trim());
}
Siehe auch
- class PlainTextDocument
- namensraum Aspose.Words
- Montage Aspose.Words
PlainTextDocument(Stream, LoadOptions)
Erstellt ein Nur-Text-Dokument aus einem Stream. Ermöglicht die Angabe zusätzlicher Optionen wie z. B. eines Verschlüsselungskennworts.
public PlainTextDocument(Stream stream, LoadOptions loadOptions)
Parameter | Typ | Beschreibung |
---|---|---|
stream | Stream | Der Stream, aus dem der Text extrahiert werden soll. |
loadOptions | LoadOptions | Zusätzliche Optionen zum Laden eines Dokuments. Kann seinNull . |
Ausnahmen
Ausnahme | Bedingung |
---|---|
UnsupportedFileFormatException | Das Dokumentformat wird nicht erkannt oder nicht unterstützt. |
FileCorruptedException | Das Dokument scheint beschädigt zu sein und kann nicht geladen werden. |
Exception | Es liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden. |
IOException | Es liegt eine Ein-/Ausgabeausnahme vor. |
IncorrectPasswordException | Das Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben. |
ArgumentNullException | Der Stream darf nicht null sein. |
NotSupportedException | Der Stream unterstützt weder Lesen noch Suchen. |
ObjectDisposedException | Der Stream ist ein entsorgtes Objekt. |
Bemerkungen
Das Dokument muss am Anfang des Streams gespeichert werden. Der Stream muss eine zufällige Positionierung unterstützen.
Beispiele
Zeigt, wie der Inhalt eines verschlüsselten Microsoft Word-Dokuments mithilfe eines Streams im Klartext geladen wird.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.Password = "MyPassword";
doc.Save(ArtifactsDir + "PlainTextDocument.LoadFromStreamWithOptions.docx", saveOptions);
LoadOptions loadOptions = new LoadOptions();
loadOptions.Password = "MyPassword";
using (FileStream stream = new FileStream(ArtifactsDir + "PlainTextDocument.LoadFromStreamWithOptions.docx", FileMode.Open))
{
PlainTextDocument plaintext = new PlainTextDocument(stream, loadOptions);
Assert.AreEqual("Hello world!", plaintext.Text.Trim());
}
Siehe auch
- class LoadOptions
- class PlainTextDocument
- namensraum Aspose.Words
- Montage Aspose.Words