XpsResource Class

Defines the base class for resources that can be added to an XpsDocument.

Namespace: System.Windows.Xps.Packaging
Assembly: ReachFramework (in reachframework.dll)

public ref class XpsResource : public XpsPartBase, IDisposable
public class XpsResource extends XpsPartBase implements IDisposable
public class XpsResource extends XpsPartBase implements IDisposable
You cannot use this managed class in XAML.

The following example shows how to add XpsResource derived types to an XpsDocument.

// -------------------------- AddPageResources ----------------------------
Dictionary<System::String^,List<XpsResource^>^>^ AddPageResources (IXpsFixedPageWriter^ fixedPageWriter) 
   // Collection of all resources for this page.
   //   Key: "XpsImage", "XpsFont"
   //   Value: List of XpsImage or XpsFont
   Dictionary<System::String^,List<XpsResource^>^>^ resources = gcnew Dictionary<System::String^,List<XpsResource^>^>();

   // Collections of images and fonts used in the current page.
   List<XpsResource^>^ xpsImages = gcnew List<XpsResource^>();
   List<XpsResource^>^ xpsFonts = gcnew List<XpsResource^>();

      XpsImage^ xpsImage;
      XpsFont^ xpsFont;

      // Add, Write, and Commit image1 to the current page.
      xpsImage = fixedPageWriter->AddImage(XpsImageType::JpegImageType);
      WriteToStream(xpsImage->GetStream(), image1);
      xpsImages->Add(xpsImage);    // Add image1 as a required resource.

      // Add, Write, and Commit font 1 to the current page.
      xpsFont = fixedPageWriter->AddFont();
      WriteObfuscatedStream(xpsFont->Uri->ToString(), xpsFont->GetStream(), font1);
      xpsFonts->Add(xpsFont);      // Add font1 as a required resource.

      // Add, Write, and Commit image2 to the current page.
      xpsImage = fixedPageWriter->AddImage(XpsImageType::TiffImageType);
      WriteToStream(xpsImage->GetStream(), image2);
      xpsImages->Add(xpsImage);    // Add image2 as a required resource.

      // Add, Write, and Commit font2 to the current page.
      xpsFont = fixedPageWriter->AddFont(false);
      WriteToStream(xpsFont->GetStream(), font2);
      xpsFonts->Add(xpsFont);      // Add font2 as a required resource.

      // Return the image and font resources in a combined collection.
      resources->Add("XpsImage", xpsImages);
      resources->Add("XpsFont", xpsFonts);
      return resources;
   } catch (XpsPackagingException^ xpsException)
      throw xpsException;

};// end:AddPageResources()

For the complete sample, see Creating an XPS Document Sample.

       Derived Classes

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions