PrettyFormat
محتويات
[
يخفي
]SaveOptions.PrettyFormat property
عندماحقيقي
، تنسيقات الإخراج الجميلة حيثما ينطبق ذلك. القيمة الافتراضية هيخطأ شنيع
.
public bool PrettyFormat { get; set; }
ملاحظات
تم ضبطه علىحقيقي
لجعل مخرجات HTML وMHTML وEPUB وWordML وRTF وDOCX وODT قابلة للقراءة من قبل البشر. مفيدة للاختبار أو التصحيح.
أمثلة
يوضح كيفية تحسين قابلية قراءة الكود الخام لمستند .html المحفوظ.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
HtmlSaveOptions htmlOptions = new HtmlSaveOptions(SaveFormat.Html) { PrettyFormat = usePrettyFormat };
doc.Save(ArtifactsDir + "HtmlSaveOptions.PrettyFormat.html", htmlOptions);
// يؤدي تمكين التنسيق الجميل إلى جعل كود HTML الخام أكثر قابلية للقراءة عن طريق إضافة علامة تبويب وأحرف سطر جديدة.
string html = File.ReadAllText(ArtifactsDir + "HtmlSaveOptions.PrettyFormat.html");
string newLine = Environment.NewLine;
if (usePrettyFormat)
Assert.AreEqual(
$"<html>{newLine}" +
$"\t<head>{newLine}" +
$"\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />{newLine}" +
$"\t\t<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />{newLine}" +
$"\t\t<meta name=\"generator\" content=\"{BuildVersionInfo.Product} {BuildVersionInfo.Version}\" />{newLine}" +
$"\t\t<title>{newLine}" +
$"\t\t</title>{newLine}" +
$"\t</head>{newLine}" +
$"\t<body style=\"font-family:'Times New Roman'; font-size:12pt\">{newLine}" +
$"\t\t<div>{newLine}" +
$"\t\t\t<p style=\"margin-top:0pt; margin-bottom:0pt\">{newLine}" +
$"\t\t\t\t<span>Hello world!</span>{newLine}" +
$"\t\t\t</p>{newLine}" +
$"\t\t\t<p style=\"margin-top:0pt; margin-bottom:0pt\">{newLine}" +
$"\t\t\t\t<span style=\"-aw-import:ignore\"> </span>{newLine}" +
$"\t\t\t</p>{newLine}" +
$"\t\t</div>{newLine}" +
$"\t</body>{newLine}</html>",
html);
else
Assert.AreEqual(
"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" +
"<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />" +
$"<meta name=\"generator\" content=\"{BuildVersionInfo.Product} {BuildVersionInfo.Version}\" /><title></title></head>" +
"<body style=\"font-family:'Times New Roman'; font-size:12pt\">" +
"<div><p style=\"margin-top:0pt; margin-bottom:0pt\"><span>Hello world!</span></p>" +
"<p style=\"margin-top:0pt; margin-bottom:0pt\"><span style=\"-aw-import:ignore\"> </span></p></div></body></html>",
html);
أنظر أيضا
- class SaveOptions
- مساحة الاسم Aspose.Words.Saving
- المجسم Aspose.Words