PlainTextDocument

PlainTextDocument(string)

يُنشئ مستند نص عادي من ملف. يكتشف تنسيق الملف تلقائيًا.

public PlainTextDocument(string fileName)
معامليكتبوصف
fileNameStringاسم الملف الذي سيتم استخراج النص منه.

استثناءات

استثناءحالة
UnsupportedFileFormatExceptionلم يتم التعرف على تنسيق المستند أو لم يتم دعمه.
FileCorruptedExceptionيبدو أن المستند تالف ولا يمكن تحميله.
Exceptionهناك مشكلة في المستند ويجب الإبلاغ عنها إلى مطوري Aspose.Words.
IOExceptionهناك استثناء الإدخال/الإخراج.
IncorrectPasswordExceptionتم تشفير المستند ويتطلب كلمة مرور لفتحه، ولكنك أدخلت كلمة مرور غير صحيحة.
ArgumentExceptionلا يمكن أن يكون اسم الملف فارغًا أو سلسلة فارغة.

أمثلة

يوضح كيفية تحميل محتويات مستند Microsoft Word في نص عادي.

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());

أنظر أيضا


PlainTextDocument(string, LoadOptions)

يُنشئ مستند نص عادي من ملف. يسمح بتحديد خيارات إضافية، مثل كلمة مرور التشفير.

public PlainTextDocument(string fileName, LoadOptions loadOptions)
معامليكتبوصف
fileNameStringاسم الملف الذي سيتم استخراج النص منه.
loadOptionsLoadOptionsخيارات إضافية لاستخدامها عند تحميل مستند. يمكنباطل.

استثناءات

استثناءحالة
UnsupportedFileFormatExceptionلم يتم التعرف على تنسيق المستند أو لم يتم دعمه.
FileCorruptedExceptionيبدو أن المستند تالف ولا يمكن تحميله.
Exceptionهناك مشكلة في المستند ويجب الإبلاغ عنها إلى مطوري Aspose.Words.
IOExceptionهناك استثناء الإدخال/الإخراج.
IncorrectPasswordExceptionتم تشفير المستند ويتطلب كلمة مرور لفتحه، ولكنك أدخلت كلمة مرور غير صحيحة.
ArgumentExceptionلا يمكن أن يكون اسم الملف فارغًا أو سلسلة فارغة.

أمثلة

يوضح كيفية تحميل محتويات مستند Microsoft Word المشفر في نص عادي.

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());

أنظر أيضا


PlainTextDocument(Stream)

يُنشئ مستند نص عادي من مصدر. يكتشف تنسيق الملف تلقائيًا.

public PlainTextDocument(Stream stream)
معامليكتبوصف
streamStreamالمصدر الذي سيتم استخراج النص منه.

استثناءات

استثناءحالة
UnsupportedFileFormatExceptionلم يتم التعرف على تنسيق المستند أو لم يتم دعمه.
FileCorruptedExceptionيبدو أن المستند تالف ولا يمكن تحميله.
Exceptionهناك مشكلة في المستند ويجب الإبلاغ عنها إلى مطوري Aspose.Words.
IOExceptionهناك استثناء الإدخال/الإخراج.
IncorrectPasswordExceptionتم تشفير المستند ويتطلب كلمة مرور لفتحه، ولكنك أدخلت كلمة مرور غير صحيحة.
ArgumentNullExceptionلا يمكن أن يكون الدفق فارغًا.
NotSupportedExceptionلا يدعم البث القراءة أو البحث.
ObjectDisposedExceptionالدفق هو كائن متصرف.

ملاحظات

يجب تخزين المستند في بداية الدفق. يجب أن يدعم الدفق التموضع العشوائي.

أمثلة

يوضح كيفية تحميل محتويات مستند Microsoft Word في نص عادي باستخدام الدفق.

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());
}

أنظر أيضا


PlainTextDocument(Stream, LoadOptions)

يُنشئ مستند نص عادي من مصدر. يسمح بتحديد خيارات إضافية، مثل كلمة مرور التشفير.

public PlainTextDocument(Stream stream, LoadOptions loadOptions)
معامليكتبوصف
streamStreamالمصدر الذي سيتم استخراج النص منه.
loadOptionsLoadOptionsخيارات إضافية لاستخدامها عند تحميل مستند. يمكنباطل.

استثناءات

استثناءحالة
UnsupportedFileFormatExceptionلم يتم التعرف على تنسيق المستند أو لم يتم دعمه.
FileCorruptedExceptionيبدو أن المستند تالف ولا يمكن تحميله.
Exceptionهناك مشكلة في المستند ويجب الإبلاغ عنها إلى مطوري Aspose.Words.
IOExceptionهناك استثناء الإدخال/الإخراج.
IncorrectPasswordExceptionتم تشفير المستند ويتطلب كلمة مرور لفتحه، ولكنك أدخلت كلمة مرور غير صحيحة.
ArgumentNullExceptionلا يمكن أن يكون الدفق فارغًا.
NotSupportedExceptionلا يدعم البث القراءة أو البحث.
ObjectDisposedExceptionالدفق هو كائن متصرف.

ملاحظات

يجب تخزين المستند في بداية الدفق. يجب أن يدعم الدفق التموضع العشوائي.

أمثلة

يوضح كيفية تحميل محتويات مستند Microsoft Word المشفر في نص عادي باستخدام الدفق.

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());
}

أنظر أيضا