繁体   English   中英

Microsoft Report页面方向(VS 2013,C#)

[英]Microsoft Report page orientation (VS 2013, C#)

我正在使用MS Report(c#/ VS2013)打印标签。 标签宽8厘米,高4厘米。 打印机以纵向(不旋转)的方式看到并进给,但报表查看器以横向打印它们,因为宽度大于高度。 打印机在打印之前特定于页面的方向更改会被忽略(!),因此标签始终相对于标签方向旋转90°进行打印。 打印机是工业热转印打印机。

我不明白为什么页面方向绑定到高度和宽度之间的关系,并且不能独立设置! 我已经尝试在打印之前更改方向-这导致标签被打印成几片,但没有旋转。

唯一有帮助的是将纸张尺寸更改为8宽度和8.1高度。 然后标签可以正确打印,但是这会导致很多空白页面(标签),因此不是很好的解决方案。

我目前看到的唯一方法是重新设计所有旋转90°的标签,这是很费力的,因此,如果有人对这种顽固的行为有解决方案,我将不胜感激!

我通过渲染图像并通过PrintDocument对象将其打印来解决了这个问题。 这样,我就可以将横向打印的标签(8cm宽,4cm高)以纵向方式发送到打印机。

我敢肯定,这可以做得更优雅,但是由于时间紧迫,我现在采用以下解决方案:

String tempDir = Path.GetTempFileName();
File.Delete(tempDir);
Directory.CreateDirectory(tempDir);
tempDir = Utils.addBackslash(tempDir);
ExportToPNG(tempDir);
String imageFile = Utils.FindFirstFile(tempDir, "*.png");
if (imageFile != "")
{
    PrintDocument pd = new PrintDocument();
    try
    {
        pd.DefaultPageSettings.PrinterSettings.PrinterName = DB.Instance.getSetting("label.printername");
    }
    catch
    {
        // This is just a preset, it may fail without consequences
    }

    pd.DefaultPageSettings.Landscape = false; // Now I can do it!
    pd.PrintPage += (sender, args) =>
    {
        Image i = Image.FromFile(imageFile);
        Point p = new Point(100, 100);
        args.Graphics.DrawImage(i, 0, 0, i.Width, i.Height);
    };
    PrintDialog pdi = new PrintDialog();
    pdi.Document = pd;
    if (pdi.ShowDialog() == DialogResult.OK)
        pd.Print();
    pd.Dispose();
}

暂无
暂无

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

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