2

MSDN(リンク)のソースコードを使用して、レポートを( )Imageにエクスポートし、次にを使用して画像をプリンターに印刷することにより、レポートRDLCをPOSプリンターに直接印刷しようとしています。数値に基づいてレポートの高さを計算します。行の数(1行の高さ= 0.6 cm)。EMFPrintDocument

問題は、レポートが長すぎる(複数のページ)と、行が互いに縮小(圧縮)されることです。

この問題を解決する方法は?レポートを画像にエクスポートして画像を印刷する代わりに、POSプリンターライブラリ(.NET POS)を使用する必要がありますか?。ソースコードは(こちら)からダウンロードできます。

高度に感謝します。

4

3 に答える 3

0

私は紙のサイズを変更することでそれを解決しました:

PaperSize pkCustomSize = new System.Drawing.Printing.PaperSize("Custom Paper Size", Convert.ToInt32((WidthInInCM / 2.54) * 100), Convert.ToInt32((HeightInInCM / 2.54) * 100));
            printDoc.DefaultPageSettings.PaperSize = pkCustomSize;
            printDoc.DefaultPageSettings.Margins.Top = 0;
            printDoc.DefaultPageSettings.Margins.Bottom = 0;
            printDoc.DefaultPageSettings.Margins.Left = 0;
            printDoc.DefaultPageSettings.Margins.Right = 0;

            if (!printDoc.PrinterSettings.IsValid)
            {
                String msg = String.Format("Can't find printer \"{0}\".", PrinterName);
                MessageBox.Show(msg, "Print Error");
                return;
            }
            printDoc.PrinterSettings.DefaultPageSettings.PaperSize = printDoc.DefaultPageSettings.PaperSize;
            printDoc.PrinterSettings.DefaultPageSettings.Margins = printDoc.DefaultPageSettings.Margins;

更新されたソースコードは(ここ)からダウンロードできます。

于 2012-12-22T15:02:00.683 に答える
0

別の解決策は、大きな画像(レポートをエクスポートする)を多くのページに印刷することです。

private void PrintPage(Object sender, PrintPageEventArgs ev)
        {
            if (pageImage == null)
                return;
            ev.Graphics.PageUnit = GraphicsUnit.Pixel;

            ev.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            ev.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
            float a = (ev.PageSettings.PrintableArea.Width / 100) * ev.Graphics.DpiX;
            float b = ((ev.PageSettings.PrintableArea.Height / 100) * ev.Graphics.DpiY);
            float scale = 1500;
            scale = 0;
            RectangleF srcRect = new RectangleF(0, startY, pageImage.Width, b - scale);
            RectangleF destRect = new RectangleF(0, 0, a, b);
            ev.Graphics.DrawImage(pageImage, destRect, srcRect, GraphicsUnit.Pixel);
            startY = startY + b - scale;
            float marignInPixel = (0.5f / 2.54f) * ev.Graphics.DpiY;
            ev.HasMorePages = (startY + marignInPixel < pageImage.Height);
        }

ソースコードは(こちら)からダウンロードできます。

于 2012-12-24T15:05:47.900 に答える
0

私は同様の問題で立ち往生しています。

私は以下を使用してそれを修正することができました:

    private void PrintPage(object sender, PrintPageEventArgs ev)
    {

        Metafile pageImage =
          new Metafile(m_streams[m_currentPageIndex]);
//That's the fix - Units set to Display
        ev.Graphics.PageUnit = GraphicsUnit.Display;
//Drawing it scaled
        ev.Graphics.DrawImage(pageImage, 0, 0, ev.MarginBounds.Width, ev.MarginBounds.Height);

        m_currentPageIndex++;
        ev.HasMorePages = (m_currentPageIndex < m_streams.Count);            
    }

ページは、拡大縮小されたプリンタキャンバスに描画されます。

于 2013-08-01T20:02:24.223 に答える