zoukankan      html  css  js  c++  java
  • AE, C#,按纸张打印地图

    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);

    一起学习GIS及其二次开发,一起进步!
  • 相关阅读:
    破解Excel写密码保护方法
    【收藏推荐】JavaScript 秘密花园
    Flask框架第六篇.Flask中的蓝图和特殊装饰器
    Flask框架第四篇.Flask 中的 请求Request和session
    Flask框架第三篇.Flask 中的 Response
    Flask框架第八篇.请求上下文
    Flask框架第一篇.Flask框架基础
    Flask框架第二篇.Flask中的配置
    Flask框架第五篇.Flask 中的路由
    Flask框架第七篇.CBV和Flasksession
  • 原文地址:https://www.cnblogs.com/tuncaysanli/p/1330079.html
Copyright © 2011-2022 走看看