【问题标题】:Per-page orientation in a WPF FixedDocumentWPF FixedDocument 中的每页方向
【发布时间】:2013-02-13 03:35:15
【问题描述】:

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

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

【问题讨论】:

  • 好问题。我想自己知道。

标签: wpf printing orientation


【解决方案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;
}

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

【讨论】:

  • 每个 PrintTicket 都会产生一个新的打印作业。打印到 PDF 等软件打印机时,每个作业都将写入自己的文件中。所以创建一个新的 PrintTicket 将创建多个 PDF 文件,这在我的情况下是不可接受的。我需要在一个文档中使用不同的方向,以便它可以作为一个打印。
  • 我同意多个 PDF 文件而不是一个是不可接受的。感谢您清理它。我把我的答案作为一个教训,告诉我如何不这样做;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-24
  • 2011-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多