إضافة كائن منحنى إلى ملف PDF

تعمل مقتطفات الشيفرة التالية أيضًا مع مكتبة Aspose.PDF.Drawing .

إضافة كائن منحنى

المنحنى Curve هو اتحاد متصل من الخطوط الإسقاطية، حيث يلتقي كل خط بثلاثة خطوط أخرى في نقاط مزدوجة عادية.

يوضح Aspose.PDF for .NET كيفية استخدام منحنيات بيزير في الرسوم البيانية الخاصة بك. تستخدم منحنيات بيزير على نطاق واسع في الرسوميات الحاسوبية لنمذجة المنحنيات السلسة. يتم احتواء المنحنى بالكامل في الغلاف المحدب لنقاط التحكم الخاصة به، ويمكن عرض النقاط رسوميًا واستخدامها للتلاعب بالمنحنى بشكل بديهي. يتم احتواء المنحنى بالكامل في الرباعي الذي تكون زواياه هي النقاط الأربعة المعطاة (غلافها المحدب).

في هذا المقال، سنستكشف منحنيات الرسوم البيانية البسيطة، والمنحنيات المملوءة، التي يمكنك إنشاؤها في مستند PDF الخاص بك.

اتبع الخطوات أدناه:

  1. إنشاء مثيل Document .
  2. إنشاء كائن رسم بأبعاد معينة.
  3. تعيين حدود لكائن الرسم.
  4. إضافة كائن رسم بياني إلى مجموعة الفقرات في الصفحة.
  5. حفظ ملف PDF الخاص بنا.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExampleCurve()
{
    // The path to the document directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Images();

    // Create PDF document
    using (var document = new Aspose.Pdf.Document())
    {
        // Add page
        var page = document.Pages.Add();

        // Create Drawing object with certain dimensions
        var graph = new Aspose.Pdf.Drawing.Graph(400, 200);

        // Set border for Drawing object
        var borderInfo = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Green);
        graph.Border = borderInfo;

        // Create a curve and set its properties
        var curve1 = new Aspose.Pdf.Drawing.Curve(new float[] { 10, 10, 50, 60, 70, 10, 100, 120 })
        {
            GraphInfo = 
            { 
                Color = Aspose.Pdf.Color.GreenYellow 
            }
        };

        // Add the curve to the graph shapes
        graph.Shapes.Add(curve1);

        // Add Graph object to paragraphs collection of page
        page.Paragraphs.Add(graph);

        // Save PDF document
        document.Save(dataDir + "DrawingCurve1_out.pdf");
    }
}

تظهر الصورة التالية النتيجة الناتجة عن تنفيذ مقتطف الشيفرة الخاص بنا:

رسم منحنى

إنشاء كائن منحنى مملوء

يوضح هذا المثال كيفية إضافة كائن منحنى مملوء باللون.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void CurveFilled()
{
    // The path to the document directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Images();

    // Create PDF document
    using (var document = new Aspose.Pdf.Document())
    {
        // Add page
        var page = document.Pages.Add();

        // Create Drawing object with certain dimensions
        var graph = new Aspose.Pdf.Drawing.Graph(400, 200);

        // Set border for Drawing object
        var borderInfo = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Green);
        graph.Border = borderInfo;

        // Create a curve and set fill color
        var curve1 = new Aspose.Pdf.Drawing.Curve(new float[] { 10, 10, 50, 60, 70, 10, 100, 120 })
        {
            GraphInfo = 
            { 
                FillColor = Aspose.Pdf.Color.GreenYellow 
            }
        };

        // Add the curve to the graph shapes
        graph.Shapes.Add(curve1);

        // Add Graph object to paragraphs collection of page
        page.Paragraphs.Add(graph);

        // Save PDF document
        document.Save(dataDir + "DrawingCurve2_out.pdf");
    }
}

انظر إلى نتيجة إضافة منحنى مملوء:

منحنى مملوء