• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

AE,C#,按纸张打印地图

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

private void PrintAuto(IActiveView pActiveView)
{

    IPaper pPaper = new Paper();
    IPrinter pPrinter = new EmfPrinterClass();

    System.Drawing.Printing.PrintDocument sysPrintDocumentDocument = new System.Drawing.Printing.PrintDocument();

    pPaper.PrinterName = sysPrintDocumentDocument.PrinterSettings.PrinterName;
    pPrinter.Paper = pPaper;

    int Resolution = pPrinter.Resolution;

    double w, h;
    IEnvelope PEnvelope = pActiveView.Extent;
    w = PEnvelope.Width;
    h = PEnvelope.Height;
    double pw, ph;//纸张
    pPrinter.QueryPaperSize(out pw, out ph);
    tagRECT userRECT = pActiveView.ExportFrame;

    userRECT.left = (int)(pPrinter.PrintableBounds.XMin * Resolution);
    userRECT.top = (int)(pPrinter.PrintableBounds.YMin * Resolution);

    if ((w / h) > (pw / ph))//以宽度来调整高度
    {

        userRECT.right = userRECT.left + (int)(pPrinter.PrintableBounds.Width * Resolution);
        userRECT.bottom = userRECT.top + (int)((pPrinter.PrintableBounds.Width * Resolution) * h / w);
    }
    else
    {
        userRECT.bottom = userRECT.top + (int)(pPrinter.PrintableBounds.Height * Resolution);
        userRECT.right = userRECT.left + (int)(pPrinter.PrintableBounds.Height * Resolution * w / h);

    }

    IEnvelope pDriverBounds = new EnvelopeClass();
    pDriverBounds.PutCoords(userRECT.left, userRECT.top, userRECT.right, userRECT.bottom);

    ITrackCancel pCancel = new CancelTrackerClass();
    int hdc = pPrinter.StartPrinting(pDriverBounds, 0);

    pActiveView.Output(hdc, pPrinter.Resolution,
    ref userRECT, pActiveView.Extent, pCancel);

    pPrinter.FinishPrinting();

}


调用
PrintAuto(this.axMapControl1.ActiveView);


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#判断一个字符串是否为url发布时间:2022-07-13
下一篇:
C#WinformTabControl双击关闭TabPage发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap