简体   繁体   English

处理打印元数据入门

[英]Getting started with manipulating print meta-data

When sending a document, lets say TIFF images to a printer we can send meta-data with the image such as the paper size "Legal, Photo etc". 在发送文档时,假设TIFF图像发送到打印机,我们可以发送带有图像的元数据,例如纸张尺寸“法律,照片等”。 The printer is able to use this information to select a paper tray matching this paper size. 打印机可以使用此信息来选择与该纸张尺寸匹配的纸盒。

I have a program that generates a tif document and uses PrintDocument to generate a Print job. 我有一个生成tif文档并使用PrintDocument生成打印作业的程序。 This process occurs programmatically (no UI). 此过程以编程方式发生(无UI)。 Is it possible to alter the metadata of the tif image programmatically before I send the job to the printer? 在将作业发送到打印机之前,可以通过编程方式更改tif图像的元数据吗?

EG I want to change the paper size of the image to "Legal". EG我想将图像的纸张尺寸更改为“合法”。 This way I can tell the printer which tray to use. 这样我可以告诉打印机要使用哪个纸盘。 I have explored generating an XPS document out of the TIF. 我探索了从TIF生成XPS文档的方法。 Then going back through a XPS API to set the property. 然后返回通过XPS API设置属性。 However, this solution feels a little heavy. 但是,这种解决方案感觉有点沉重。 I hope for someone with more experience in this type of programming to point me in the right direction. 我希望有更多此类编程经验的人为我指明正确的方向。

The paper size option is available in PrintDocument 纸张尺寸选项在PrintDocument可用

private void SetPaperSize()
{
    int legalPaperIndex = 5;//See all types: http://msdn.microsoft.com/en-us/library/system.drawing.printing.papersize.rawkind.aspx
    for (int i = 0; i < printDocument.PrinterSettings.PaperSizes.Count - 1; i++)
    {
        if (printDocument.PrinterSettings.PaperSizes[i].RawKind == legalPaperIndex)
        {
            printDocument.DefaultPageSettings.PaperSize = printDocument.PrinterSettings.PaperSizes[i];
        }
    }    
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM