عمليات الحزم المتقاطعة ضمن حزمة XPS

معالجة الصفحات والألوان والحروف الرسومية داخل حزمة XPS عبر C#

 

يتضمن حل Aspose.Page API لـ .NET من بين التنسيقات الأخرى حزمة XPS كمكتبة منفصلة للعمل مع ملفات XPS. تحتوي وظائفه الغنية على العديد من الميزات المفيدة والشائعة مثل دمج الملفات والتحويل والعمل بالرسومات وما إلى ذلك.

يمكن أن يحتوي XPS على عدة ملفات في مستند واحد. لذلك يجب أن تتمتع أي حزمة XPS بوظيفة معالجة هذه الملفات وصفحاتها داخل المستند وبين مستندات XPS المختلفة. تسمى هذه التلاعبات عمليات الحزم المتقاطعة. يجب شرحها بشكل منفصل.

ستجد هنا أمثلة لعمليات الحزم المتقاطعة مثل معالجة الصفحة وإضافة الصور الرمزية والألوان.

خطوات معالجة الصفحات داخل XPS Package C#.

  1. حدد المسار إلى دليل المستندات.
  2. أنشئ ملف XPS باستخدام XpsDocument Class .
  3. لإدراج صفحة نشطة من مستند إلى بداية مستند آخر ، استخدم InsertPage() طريقة.
  4. لإدراج صفحة نشطة من مستند إلى نهاية مستند آخر ، استخدم الطريقة AddPage() .
  5. لإزالة صفحة فارغة ، استخدم طريقة RemovePage() .
  6. لإزالة صفحة من مستند إلى مستند آخر ، استخدم InsertPage() و SelectActivePage() طُرق.
  7. احفظ مستندات XPS التي تم تغييرها باستخدام XPsDocument.Save .

C# رمز لمعالجة الحزم المتقاطعة مع الصفحات

    using Aspose.Page.XPS;
    using Aspose.Page.XPS.XpsModel;
    using System.Drawing;
    // The path to the documents directory.
    string dataDir = RunExamples.GetDataDir_WorkingWithCrossPackageOperations();

    // Create the first XPS Document
    XpsDocument doc1 = new XpsDocument(dataDir + "input1.xps");

    // Create the second XPS Document
    XpsDocument doc2 = new XpsDocument(dataDir + "input2.xps");

    // Create the third XPS Document
    XpsDocument doc3 = new XpsDocument(dataDir + "input3.xps");

    // Create the fourth XPS Document
    XpsDocument doc4 = new XpsDocument();

    // Insert the active page (1 in this case) from the second document to the beginning of the fourth document
    doc4.InsertPage(1, doc2.Page, false);

    // Insert the active page (1 in this case) from the third document to the end of the fourth document
    doc4.AddPage(doc3.Page, false);

    // Remove page 2 from the fourth document. This is an empty page that was created when the document had been created.
    doc4.RemovePageAt(2);

    // Insert page 3 from the first document to the second postion of the fourth document
    doc4.InsertPage(2, doc1.SelectActivePage(3), false);

    // Save the fourth XPS document
    doc4.Save(dataDir + "out.xps");

خطوات لإضافة نسخة رمزية داخل XPS Package C#.

  1. حدد المسار إلى دليل المستندات.
  2. افتح دفق ملف XPS.
  3. قم بإنشاء ملف XPS باستخدام XpsDocument Class.
  4. أضف صورًا رمزية إلى المستند باستخدام طريقة AddGlyphs() .
  5. قم بإنشاء ملف XPS الثاني باستخدام XpsDocument Class.
  6. لنسخ الصورة الرمزية من الملف الأول إلى الملف الثاني ، استخدم Add() و Clone() الأساليب.
  7. احفظ كلا وثيقي XPS عن طريق طريقة XPsDocument.Save().

كود C# لنسخ glyth داخل حزمة XPS

    // The path to the documents directory.
    string dataDir = RunExamples.GetDataDir_WorkingWithCrossPackageOperations();

    // Create the first XPS Document
    XpsDocument doc1 = new XpsDocument();

    // Add glyphs to the first document
    XpsGlyphs glyphs = doc1.AddGlyphs("Times New Roman", 200, FontStyle.Bold, 50, 250, "Test");

    // Fill glyphs in the first document with one color
    glyphs.Fill = doc1.CreateSolidColorBrush(Color.Green);

    // Create the second XPS Document
    XpsDocument doc2 = new XpsDocument();

    // Add glyphs cloned from the one's from the first document
    glyphs = doc2.Add(glyphs.Clone());

    // Fill glyphs in the second document with another color
    ((XpsSolidColorBrush)glyphs.Fill).Color = doc2.CreateColor(Color.Red);

    // Save the first XPS document
    doc1.Save(dataDir + "out1.xps");

    // Save the second XPS document
    doc2.Save(dataDir + "out2.xps");

خطوات إضافة صورة مملوءة بالرسم C#.

  1. حدد المسار إلى دليل المستندات.
  2. افتح دفق ملف XPS.
  3. قم بإنشاء ملف XPS باستخدام XpsDocument Class.
  4. أضف صورًا رمزية إلى المستند باستخدام طريقة AddGlyphs().
  5. لتعبئة الصور الرمزية بفرشاة صورة ، استخدم طريقة CreateImageBrush() .
  6. قم بإنشاء ملف XPS الثاني باستخدام XpsDocument Class.
  7. أضف صورًا رمزية بالخط من المستند الأول إلى المستند الثاني باستخدام طريقة AddGlyphs().
  8. قم بإنشاء فرشاة صورة من تعبئة المستند الأول وقم بتعبئة الصور الرمزية في المستند الثاني باستخدام طريقة CreateImageBrush().
  9. احفظ كلا وثيقي XPS عن طريق طريقة XPsDocument.Save()

C# Code لإنشاء حرف رسومي مملوء بالصورة داخل حزمة XPS

    // The path to the documents directory.
    string dataDir = RunExamples.GetDataDir_WorkingWithCrossPackageOperations();

    // Create the first XPS Document
    XpsDocument doc1 = new XpsDocument();

    // Add glyphs to the first document
    XpsGlyphs glyphs1 = doc1.AddGlyphs("Times New Roman", 200, FontStyle.Bold, 50, 250, "Test");

    // Fill the glyphs with an image brush
    glyphs1.Fill = doc1.CreateImageBrush(dataDir + "R08SY_NN.tif", new RectangleF(0f, 0f, 128f, 192f),
        new RectangleF(0f, 0f, 64f, 96f));
    ((XpsImageBrush)glyphs1.Fill).TileMode = XpsTileMode.Tile;

    // Create the second XPS Document
    XpsDocument doc2 = new XpsDocument();

    // Add glyphs with the font from the first document to the second document
    XpsGlyphs glyphs2 = doc2.AddGlyphs(glyphs1.Font, 200, 50, 250, "Test");

    // Create an image brush from the fill of the the first document and fill glyphs in the second document
    glyphs2.Fill = doc2.CreateImageBrush(((XpsImageBrush)glyphs1.Fill).Image, new RectangleF(0f, 0f, 128f, 192f),
        new RectangleF(0f, 0f, 128f, 192f));
    ((XpsImageBrush)glyphs2.Fill).TileMode = XpsTileMode.Tile;

    // Save the first XPS document
    doc1.Save(dataDir + "out1.xps");

    // Save the second XPS document
    doc2.Save(dataDir + "out2.xps");



التعليمات

1. ما هي باقة XPS؟

تعد حزمة XPS مكتبة منفصلة لإدارة ملفات XPS. استخدمه لإنشاء المحولات أو القراء أو التطبيقات الأخرى الخاصة بك لتحرير XPS.

2. كيف يمكنني الحصول على باقة XPS؟

تم تضمين حزمة XPS في حل Aspose.Page .

3. ما هي العمليات المتاحة عبر الحزمة؟

باستخدام Aspose XPS Package، يمكنك نقل الصفحات من مستند إلى آخر، واستنساخ الكائنات مثل الحروف الرسومية، أو الأنماط، أو الإعدادات.

4. كيفية التعامل مع الصفحات بين مستندات XPS؟

لنقل الملفات باستخدام حزمة XPS هذه، استخدم أساليب InsertPage() وAddPage() وRemovePage() وSelectActivePage() الخاصة بفئة XpsDocument.

XPS ما هو XPS تنسيق الملف

تنسيق XPS مشابه لتنسيق PDF. كلاهما عبارة عن تنسيقات لغة وصف الصفحة (PDL). يعتمد EPS على HTML وليس على لغة PostScript. يمكن أن يحتوي ملف .eps على ترميز لهيكل المستند بالإضافة إلى معلومات حول الشكل الذي سيبدو عليه المستند. هناك أيضًا إرشادات مضافة حول كيفية طباعة المستند وتقديمه. تتمثل ميزة التنسيق في أنه يعمل على إصلاح وصف المستند مما يعني أنه سيبدو كما هو بغض النظر عن من ومن أي نظام تشغيل يفتحه.