XPS Paketi içindeki çapraz paket işlemleri

XPS Paketi içindeki sayfaları, renkleri ve glifleri C# ile işleyin

 

Aspose.Page API Solution for .NET, XPS dosyalarıyla çalışmak için ayrı bir kitaplık olarak XPS Paketini içerir. Zengin işlevselliği, dosyaları birleştirme, dönüştürme, grafiklerle çalışma vb. gibi birçok kullanışlı ve popüler özellik içerir.

XPS, bir belgede birkaç dosya tutabilir. Bu nedenle, herhangi bir XPS Paketi, bu dosyaları ve bunların sayfalarını belge içinde ve farklı XPS belgeleri arasında değiştirme işlevine sahip olmalıdır. Bu tür manipülasyonlara çapraz paket işlemleri denir. Ayrı ayrı açıklanmalıdırlar.

Burada sayfa manipülasyonları ve glifler ve renkler ekleme gibi çapraz paket operasyonlarının örneklerini bulacaksınız.

XPS Paketi C# içindeki sayfaları değiştirme adımları.

  1. Belgeler dizininin yolunu ayarlayın.
  2. XpsDocument Sınıfı kullanarak bir XPS dosyası oluşturun.
  3. Bir belgeden başka bir belgenin başına etkin bir sayfa eklemek için InsertPage() kullanın Yöntem.
  4. Bir belgeden başka bir belgenin sonuna etkin sayfa eklemek için AddPage() Yöntemini kullanın.
  5. Boş bir sayfayı kaldırmak için RemovePage() Yöntemini kullanın.
  6. Bir belgeden başka bir belgeye sayfa kaldırmak için InsertPage() ve SelectActivePage() kullanın. Yöntemler.
  7. XPsDocument.Save kullanarak değiştirilen XPS belgelerini kaydedin.

Sayfalarla çapraz paket manipülasyonları için C# Kodu

    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 Paketi C# içinde bir glif klonu ekleme adımları.

  1. Belgeler dizininin yolunu ayarlayın.
  2. XPS dosyasının bir akışını açın.
  3. XpsDocument Sınıfını kullanarak bir XPS dosyası oluşturun.
  4. AddGlyphs() Yöntemini kullanarak belgeye glifler ekleyin.
  5. XpsDocument Sınıfını kullanarak ikinci XPS dosyasını oluşturun.
  6. Glifi ilk dosyadan ikinci dosyaya kopyalamak için Add() ve Clone() Yöntemler kullanın.
  7. XPsDocument.Save() Yöntemi aracılığıyla her iki XPS belgesini de kaydedin.

XPS Paketi içinde bir glyth kopyalamak için C# Kodu

    // 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");

Görüntü dolu bir Glif C# ekleme adımları.

  1. Belgeler dizininin yolunu ayarlayın.
  2. XPS dosyasının bir akışını açın.
  3. XpsDocument Sınıfını kullanarak bir XPS dosyası oluşturun.
  4. AddGlyphs() Yöntemini kullanarak belgeye glifler ekleyin.
  5. Glifleri bir görüntü fırçasıyla doldurmak için CreateImageBrush() Yöntemini kullanın.
  6. XpsDocument Sınıfını kullanarak ikinci XPS dosyasını oluşturun.
  7. AddGlyphs() Yöntemini kullanarak ilk belgedeki yazı tipiyle glifleri ikinci belgeye ekleyin.
  8. CreateImageBrush() Yöntemini kullanarak ilk belgenin dolgusundan bir görüntü fırçası oluşturun ve ikinci belgedeki glifleri doldurun.
  9. XPsDocument.Save() Yöntemi aracılığıyla her iki XPS belgesini de kaydedin

XPS Paketi içinde görüntü dolu bir Glif oluşturmak için C# Kodu

    // 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");



SSS

1. XPS Paketi Nedir?

XPS Paketi, XPS dosyalarını yönetmek için ayrı bir kitaplıktır. XPS’yi düzenlemek için kendi dönüştürücülerinizi, okuyucularınızı veya diğer uygulamalarınızı oluşturmak için bunu kullanın.

2. XPS Paketini nasıl alabilirim?

XPS Paketi, Aspose.Page Çözümüne dahildir.

3. Hangi çapraz paket işlemleri mevcut?

Aspose XPS Paketini kullanarak sayfaları bir belgeden diğerine aktarabilir, glifler, stiller veya ayarlar gibi nesneleri kopyalayabilirsiniz.

4. XPS belgeleri arasındaki sayfalar nasıl değiştirilir?

Bu XPS Paketi ile dosya aktarmak için XpsDocument Sınıfının InsertPage(), AddPage(), RemovePage() ve SelectActivePage() Yöntemlerini kullanın.

XPS XPS Dosya Biçimi nedir

XPS formatı, PDF formatına benzer. Her ikisi de sayfa açıklama dili (PDL) biçimleridir. EPS, PostScript diline değil, HTML'ye dayalıdır. .eps dosyası, belgenin nasıl görüneceğine ilişkin bilgilerle birlikte belgenin yapısının bir işaretini içerebilir. Belgenin nasıl yazdırılacağına ve oluşturulacağına ilişkin ek talimatlar da vardır. Formatın özelliği, belgenin açıklamasını düzeltmesidir, bu da onu kimden ve hangi işletim sisteminden açarsa açsın aynı görüneceği anlamına gelir.