اجعل HTML باستخدام مكتبة .NET

تتيح مكتبتنا C# القوية للمطورين إنشاء HTML برمجيًا في بضع خطوات فقط

يمكن للمطورين .NET إنشاء HTML بسهولة باستخدام واجهة برمجة تطبيقات منتجنا الفعالة فقط. هذا يعني أن الحل الذي نقدمه سيزود المبرمجين بكل ما يحتاجونه للإنشاء HTML في C#.

اعرض مقتطف الشفرة

جعل HTML في C# برمجيًا

مع مطوري مكتبة C# لدينا يمكنهم بسهولة إنشاء HTML من البداية. للقيام بذلك، يحتاج مطورو .NET إلى تنفيذ بضع خطوات فقط:

  1. أضف اسم الملف
  2. ابدأ في إنشاء مستند HTML باستخدام C#
  3. احفظ ملف HTML الناتج

تجدر الإشارة إلى أنه من المفترض أن يحتوي المستند الفارغ من الناحية الفنية على فقرة واحدة، لذلك عندما تقوم بإنشاء مستند HTML برمجيًا، ستحصل بالضبط على هيكل المستند الأساسي هذا.

لاحظ أنه يمكنك إضافة محتوى على الفور إلى ملف HTML تم إنشاؤه حديثًا. وبالتالي، لن تحصل على مستند فارغ فحسب، بل مستند يحتوي على المحتوى الضروري. لمزيد من المعلومات حول كيفية تحرير مستند، راجع صفحة التحرير.

قم بإنشاء HTML في C#

تتيح لك مكتبة .NET هذه إنشاء مستندات HTML برمجيًا. جرب وظائفنا القوية واطلع على كيفية إنشاء HTML في بعض التنسيقات باستخدام المثال التالي:

إنشاء HTML جديد باستخدام C#
حدد التنسيق الهدف من القائمة
قم بتشغيل الكود
using Aspose.Words;

var doc = new Document();
var builder = new DocumentBuilder(doc);

var font = builder.Font;
font.Name = "Courier New";            
font.Color = Color.Blue;
font.Size = 36;
font.HighlightColor = Color.Yellow;

builder.Write("Morbi enim nunc faucibus a.");

doc.Save("Output.html");
using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); doc.Save("Output.html"); using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); var saveOptions = new PdfSaveOptions(); saveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Aspose bookmark", 1); doc.Save("Output.html", saveOptions);
using Aspose.Words;

var doc = new Document();

var run = new Run(doc, "Proin eros metus, sagittis sed.");
var para = doc.FirstSection.Body.FirstParagraph;
para.AppendChild(run);

var comment = new Comment(doc)
{
    Author = "John Doe",
    Initial = "JD",
    DateTime = DateTime.Now
};
comment.SetText("Quisque fringilla leo.");            

var commentRangeStart = new CommentRangeStart(doc, comment.Id);
var commentRangeEnd = new CommentRangeEnd(doc, comment.Id);

run.ParentNode.InsertBefore(commentRangeStart, run);
run.ParentNode.InsertAfter(commentRangeEnd, run);
commentRangeEnd.ParentNode.InsertAfter(comment, commentRangeEnd);

comment.AddReply("Jane Doe", "JD", DateTime.Now, "Pellentesque vel sapien justo.");

doc.Save("Output.html");
using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); doc.Save("Output.html"); using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); var saveOptions = new PdfSaveOptions(); saveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Aspose bookmark", 1); doc.Save("Output.html", saveOptions);
using Aspose.Words;

var doc = new Document();
var builder = new DocumentBuilder(doc);

var firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
var secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun);
doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun);

builder.MoveTo(secondRun);
builder.StartBookmark("Aspose bookmark");
// إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة.
if (secondRun.NextSibling != null)            
    builder.MoveTo(secondRun.NextSibling);            
else            
    builder.MoveTo(secondRun.ParentParagraph);            
builder.EndBookmark("Aspose bookmark");

doc.Save("Output.html");
using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); doc.Save("Output.html"); using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); var saveOptions = new PdfSaveOptions(); saveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Aspose bookmark", 1); doc.Save("Output.html", saveOptions);
using Aspose.Words;

var doc = new Document();
var builder = new DocumentBuilder(doc);

Shape shape = builder.InsertChart(ChartType.Pie, 432, 252);
Chart chart = shape.Chart;
chart.Title.Text = "Demo Chart";

chart.Series.Clear();
chart.Series.Add("Series 1",
    new string[] { "Category1", "Category2", "Category3" },
    new double[] { 2.7, 3.2, 0.8 });

doc.Save("Output.html");
using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); doc.Save("Output.html"); using Aspose.Words; var doc = new Document(); var builder = new DocumentBuilder(doc); var firstRun = new Run(doc, "Proin eros metus, sagittis sed. "); var secondRun = new Run(doc, "Morbi enim nunc faucibus a."); doc.FirstSection.Body.FirstParagraph.AppendChild(firstRun); doc.FirstSection.Body.FirstParagraph.AppendChild(secondRun); builder.MoveTo(secondRun); builder.StartBookmark("Aspose bookmark"); // إذا كانت NextSibling فارغة، فمن المرجح أن يكون هذا هو آخر Run في الفقرة. if (secondRun.NextSibling != null) builder.MoveTo(secondRun.NextSibling); else builder.MoveTo(secondRun.ParentParagraph); builder.EndBookmark("Aspose bookmark"); var saveOptions = new PdfSaveOptions(); saveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Aspose bookmark", 1); doc.Save("Output.html", saveOptions);
قم بتشغيل الكود

كيف تصنع HTML في C#

  1. تثبيت Aspose.Words for .NET
  2. أضف مرجع مكتبة (استيراد المكتبة) إلى مشروع C# الخاص بك
  3. قم بإنشاء مستند HTML جديد
  4. استدعاء طريقة "Save()"، مرر اسم الملف
  5. احصل على النتيجة كملف منفصل

C# مكتبة لإنشاء HTML

هناك ثلاثة خيارات بديلة لتثبيت "Aspose.Words for .NET" على نظامك. يرجى اختيار واحد يناسب احتياجاتك واتبع التعليمات خطوة بخطوة:

متطلبات النظام

منتجنا متعدد المنصات بالكامل ويدعم جميع تطبيقات .NET الرئيسية:

  • .NET ≥ 5.0
  • .NET Core ≥ 2.0
  • .NET Standard ≥ 2.0
  • .NET Framework ≥ 3.5
  • MonoMac
  • MonoAndroid
  • Xamarin

بقدر ما لا يعتمد كود .NET على الأجهزة الأساسية أو نظام التشغيل، ولكن فقط على Virtual Machine، فأنت حر في تطوير أي نوع من البرامج لأنظمة Windows، وmacOS، وAndroid، وiOS، وLinux. فقط تأكد من تثبيت الإصدار المقابل من .NET Framework, .NET Core, Windows Azure, Mono أو Xamarin.

نوصي باستخدام بيئات التطوير المتكاملة Microsoft Visual Studio وXamarin وMonoDevelop لإنشاء تطبيقات C#, F#, VB.NET.

لمزيد من التفاصيل يرجى الرجوع إلى وثائق المنتج.

تنسيقات الملفات المدعومة الأخرى

يمكنك إنشاء مستندات بتنسيقات ملفات أخرى:

5%

اشترك في Aspose Product Updates

احصل على رسائل إخبارية وعروض شهرية يتم تسليمها مباشرة إلى صندوق البريد الخاص بك.

© Aspose Pty Ltd 2001-2024. كل الحقوق محفوظة.