2013-02-27 74 views
4

使用PrintDialog从WPF进行打印时,只能为要打印的所有页面设置默认页面方向。我正在使用FixedDocument并为我自己布局的不同内容创建多个页面,包括页眉和页脚行。其中一些页面必须是横向的,其他纵向。WPF固定文档中的每个页面方向

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

+0

好问题。我想亲自知道。 – 2013-04-06 16:20:57

回答

0

如何使用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; 
} 

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

+1

每个PrintTicket都会导致新的打印作业。打印到PDF等软件打印机时,每个作业都将在自己的文件中写入。因此创建一个新的PrintTicket将创建多个PDF文件,这在我的情况下是不可接受的。我需要在单个文档中使用不同的方向,以便将其打印为一个文档。 – ygoe 2013-04-06 23:13:41

+0

我同意多个PDF文件而不是一个是不可接受的。感谢您清理它。我留下我的答案作为一个教训,如何不这样做;) – 2013-04-10 07:34:13