PlainTextDocument

PlainTextDocument(string)

Erstellt ein Nur-Text-Dokument aus einer Datei. Erkennt automatisch das Dateiformat.

public PlainTextDocument(string fileName)
ParameterTypBeschreibung
fileNameStringName der Datei, aus der der Text extrahiert werden soll.

Ausnahmen

AusnahmeBedingung
UnsupportedFileFormatExceptionDas Dokumentformat wird nicht erkannt oder nicht unterstützt.
FileCorruptedExceptionDas Dokument scheint beschädigt zu sein und kann nicht geladen werden.
ExceptionEs liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden.
IOExceptionEs liegt eine Ein-/Ausgabeausnahme vor.
IncorrectPasswordExceptionDas Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben.
ArgumentExceptionDer 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


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)
ParameterTypBeschreibung
fileNameStringName der Datei, aus der der Text extrahiert werden soll.
loadOptionsLoadOptionsZusätzliche Optionen zum Laden eines Dokuments. Kann seinNull.

Ausnahmen

AusnahmeBedingung
UnsupportedFileFormatExceptionDas Dokumentformat wird nicht erkannt oder nicht unterstützt.
FileCorruptedExceptionDas Dokument scheint beschädigt zu sein und kann nicht geladen werden.
ExceptionEs liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden.
IOExceptionEs liegt eine Ein-/Ausgabeausnahme vor.
IncorrectPasswordExceptionDas Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben.
ArgumentExceptionDer 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


PlainTextDocument(Stream)

Erstellt ein Nur-Text-Dokument aus einem Stream. Erkennt automatisch das Dateiformat.

public PlainTextDocument(Stream stream)
ParameterTypBeschreibung
streamStreamDer Stream, aus dem der Text extrahiert werden soll.

Ausnahmen

AusnahmeBedingung
UnsupportedFileFormatExceptionDas Dokumentformat wird nicht erkannt oder nicht unterstützt.
FileCorruptedExceptionDas Dokument scheint beschädigt zu sein und kann nicht geladen werden.
ExceptionEs liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden.
IOExceptionEs liegt eine Ein-/Ausgabeausnahme vor.
IncorrectPasswordExceptionDas Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben.
ArgumentNullExceptionDer Stream darf nicht null sein.
NotSupportedExceptionDer Stream unterstützt weder Lesen noch Suchen.
ObjectDisposedExceptionDer 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


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)
ParameterTypBeschreibung
streamStreamDer Stream, aus dem der Text extrahiert werden soll.
loadOptionsLoadOptionsZusätzliche Optionen zum Laden eines Dokuments. Kann seinNull.

Ausnahmen

AusnahmeBedingung
UnsupportedFileFormatExceptionDas Dokumentformat wird nicht erkannt oder nicht unterstützt.
FileCorruptedExceptionDas Dokument scheint beschädigt zu sein und kann nicht geladen werden.
ExceptionEs liegt ein Problem mit dem Dokument vor und es sollte den Aspose.Words-Entwicklern gemeldet werden.
IOExceptionEs liegt eine Ein-/Ausgabeausnahme vor.
IncorrectPasswordExceptionDas Dokument ist verschlüsselt und erfordert zum Öffnen ein Passwort, Sie haben jedoch ein falsches Passwort angegeben.
ArgumentNullExceptionDer Stream darf nicht null sein.
NotSupportedExceptionDer Stream unterstützt weder Lesen noch Suchen.
ObjectDisposedExceptionDer 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