WPF FixedDocument中的每页方向

ygo*_*goe 5 printing wpf orientation

使用PrintDialog从WPF打印时,您只能为要打印的所有页面设置默认页面方向.我正在使用FixedDocument并为我自己布局的不同内容创建多个页面,包括页眉和页脚行.其中一些页面必须是风景,其他页面必须是肖像.

如何设置单个页面的方向?FixedPage类不提供这样的属性.

J P*_*ack -1

使用 PrintTicket 怎么样?

PrintTicket 对象是某种类型的 XML 文档(称为 PrintTicket 文档)的易于使用的表示形式。后者是一组指令,告诉打印机如何设置其各种功能(例如双面打印、整理和装订)。

我还没有清楚地了解它,但在这里似乎可以一一更改页面的方向:

// Use different PrintTickets for different FixedDocuments.
PrintTicket ptFD = new PrintTicket();

if (_firstDocumentPrintTicket <= 1)
{   // Print the first document in black/white and in portrait 
    // orientation.  Since the PrintTicket at the 
    // FixedDocumentSequence level already specifies portrait 
    // orientation, this FixedDocument can just inherit that 
    // setting without having to set it again.
    ptFD.PageOrientation = PageOrientation.Portrait;
    ptFD.OutputColor = OutputColor.Monochrome;
    _firstDocumentPrintTicket++;
}

else // if (_firstDocumentPrintTicket > 1)
{   // Print the second document in color and in landscape 
    // orientation.  Since the PrintTicket at the 
    // FixedDocumentSequence level already specifies portrait 
    // orientation, this FixedDocument needs to set its 
    // PrintTicket with landscape orientation in order to 
    // override the higher level setting.
    ptFD.PageOrientation = PageOrientation.Landscape;
    ptFD.OutputColor = OutputColor.Color;
}
Run Code Online (Sandbox Code Playgroud)

http://msdn.microsoft.com/en-us/library/system.printing.pageorientation.aspx

  • 每个 PrintTicket 都会引发一个新的打印作业。当打印到 PDF 等软件打印机时,每个作业都将写入其自己的文件中。因此,创建新的 PrintTicket 将创建多个 PDF 文件,这在我的情况下是不可接受的。我需要在单个文档中使用不同的方向,以便可以将其作为一个文档打印。 (2认同)