IXpsFixedDocumentWriter 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義用於寫入 FixedDocument 的方法和屬性。
public interface class IXpsFixedDocumentWriter : System::Windows::Xps::Packaging::IDocumentStructureProvider
public interface IXpsFixedDocumentWriter : System.Windows.Xps.Packaging.IDocumentStructureProvider
type IXpsFixedDocumentWriter = interface
interface IDocumentStructureProvider
Public Interface IXpsFixedDocumentWriter
Implements IDocumentStructureProvider
- 實作
範例
下列範例示範如何使用 AddFixedDocument 方法來取得固定檔寫入器,以便將內容新增 FixedPage 至 XpsDocument 。
// ------------------------- AddPackageContent ----------------------------
/// <summary>
/// Adds a predefined set of content to a given XPS document.</summary>
/// <param name="xpsDocument">
/// The package to add the document content to.</param>
/// <param name="attachPrintTicket">
/// true to include a PrintTicket with the
/// document; otherwise, false.</param>
void AddPackageContent (XpsDocument^ xpsDocument, bool attachPrintTicket)
{
try
{
PrintTicket^ printTicket = GetPrintTicketFromPrinter();
// PrintTicket is null, there is no need to attach one.
if (printTicket == nullptr)
{
attachPrintTicket = false;
}
// Add a FixedDocumentSequence at the Package root
IXpsFixedDocumentSequenceWriter^ documentSequenceWriter = xpsDocument->AddFixedDocumentSequence();
// Add the 1st FixedDocument to the FixedDocumentSequence. - - - - -
IXpsFixedDocumentWriter^ fixedDocumentWriter = documentSequenceWriter->AddFixedDocument();
AddDocumentContent(fixedDocumentWriter);
// Commit the 1st Document
fixedDocumentWriter->Commit();
// Add a 2nd FixedDocument to the FixedDocumentSequence. - - - - - -
fixedDocumentWriter = documentSequenceWriter->AddFixedDocument();
// Add content to the 2nd document.
AddDocumentContent(fixedDocumentWriter);
// If attaching PrintTickets, attach one at the FixedDocument level.
if (attachPrintTicket)
{
fixedDocumentWriter->PrintTicket = printTicket;
}
// Commit the 2nd document.
fixedDocumentWriter->Commit();
// If attaching PrintTickets, attach one at
// the package FixedDocumentSequence level.
if (attachPrintTicket)
{
documentSequenceWriter->PrintTicket = printTicket;
}
// Commit the FixedDocumentSequence
documentSequenceWriter->Commit();
} catch (XpsPackagingException^ xpsException)
{
throw xpsException;
}
};// end:AddPackageContent()
// ------------------------- AddPackageContent ----------------------------
/// <summary>
/// Adds a predefined set of content to a given XPS document.</summary>
/// <param name="xpsDocument">
/// The package to add the document content to.</param>
/// <param name="attachPrintTicket">
/// true to include a PrintTicket with the
/// document; otherwise, false.</param>
private void AddPackageContent(
XpsDocument xpsDocument, bool attachPrintTicket)
{
try
{
PrintTicket printTicket = GetPrintTicketFromPrinter();
// PrintTicket is null, there is no need to attach one.
if (printTicket == null)
attachPrintTicket = false;
// Add a FixedDocumentSequence at the Package root
IXpsFixedDocumentSequenceWriter documentSequenceWriter =
xpsDocument.AddFixedDocumentSequence();
// Add the 1st FixedDocument to the FixedDocumentSequence. - - - - -
IXpsFixedDocumentWriter fixedDocumentWriter =
documentSequenceWriter.AddFixedDocument();
// Add content to the 1st document
AddDocumentContent(fixedDocumentWriter);
// Commit the 1st Document
fixedDocumentWriter.Commit();
// Add a 2nd FixedDocument to the FixedDocumentSequence. - - - - - -
fixedDocumentWriter = documentSequenceWriter.AddFixedDocument();
// Add content to the 2nd document.
AddDocumentContent(fixedDocumentWriter);
// If attaching PrintTickets, attach one at the FixedDocument level.
if (attachPrintTicket)
fixedDocumentWriter.PrintTicket = printTicket;
// Commit the 2nd document.
fixedDocumentWriter.Commit();
// If attaching PrintTickets, attach one at
// the package FixedDocumentSequence level.
if (attachPrintTicket)
documentSequenceWriter.PrintTicket = printTicket;
// Commit the FixedDocumentSequence
documentSequenceWriter.Commit();
}
catch (XpsPackagingException xpsException)
{
throw xpsException;
}
}// end:AddPackageContent()
' ------------------------- AddPackageContent ----------------------------
''' <summary>
''' Adds a predefined set of content to a given XPS document.</summary>
''' <param name="xpsDocument">
''' The package to add the document content to.</param>
''' <param name="attachPrintTicket">
''' true to include a PrintTicket with the
''' document; otherwise, false.</param>
Private Sub AddPackageContent(ByVal xpsDocument As XpsDocument, ByVal attachPrintTicket As Boolean)
Try
Dim printTicket As PrintTicket = GetPrintTicketFromPrinter()
' PrintTicket is null, there is no need to attach one.
If printTicket Is Nothing Then
attachPrintTicket = False
End If
' Add a FixedDocumentSequence at the Package root
Dim documentSequenceWriter As IXpsFixedDocumentSequenceWriter = xpsDocument.AddFixedDocumentSequence()
' Add the 1st FixedDocument to the FixedDocumentSequence. - - - - -
Dim fixedDocumentWriter As IXpsFixedDocumentWriter = documentSequenceWriter.AddFixedDocument()
' Add content to the 1st document
AddDocumentContent(fixedDocumentWriter)
' Commit the 1st Document
fixedDocumentWriter.Commit()
' Add a 2nd FixedDocument to the FixedDocumentSequence. - - - - - -
fixedDocumentWriter = documentSequenceWriter.AddFixedDocument()
' Add content to the 2nd document.
AddDocumentContent(fixedDocumentWriter)
' If attaching PrintTickets, attach one at the FixedDocument level.
If attachPrintTicket Then
fixedDocumentWriter.PrintTicket = printTicket
End If
' Commit the 2nd document.
fixedDocumentWriter.Commit()
' If attaching PrintTickets, attach one at
' the package FixedDocumentSequence level.
If attachPrintTicket Then
documentSequenceWriter.PrintTicket = printTicket
End If
' Commit the FixedDocumentSequence
documentSequenceWriter.Commit()
Catch xpsException As XpsPackagingException
Throw xpsException
End Try
End Sub
屬性
DocumentNumber |
取得 FixedDocument 中 FixedDocumentSequence 的以零起始的位置。 |
PrintTicket |
設定 FixedDocument 的預設列印選項。 |
Uri |
取得 FixedDocument 的 URI。 |
方法
AddDocumentStructure() |
將 |
AddFixedPage() |
將新的 FixedPage 加入至 FixedDocument。 |
AddThumbnail(XpsImageType) |
為 XpsThumbnail 加入 FixedDocument 影像。 |
Commit() |
清除並關閉 FixedDocument 寫入器。 |