赞
踩
Print:https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#methods-summary
require(["esri/widgets/Print"], function(Print) { /* code goes here */ });
Print小部件将应用程序与打印服务连接起来,以允许打印地图。它利用ArcGIS的ExportWebMap服务,利用服务器端、高质量、完整的地图打印功能,可以配置自定义布局模板。
有两个必需的属性:view (MapView的引用)和printServiceUrl (Export Web Map Task的REST端点的URL)。
- const print = new Print({
- view: view,
- // specify your own print service
- printServiceUrl:
- "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
- });
-
- // Adds widget below other elements in the top left corner of the view
- view.ui.add(print, {
- position: "top-left"
- });
PrintTask:https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html
require(["esri/tasks/PrintTask"], function(PrintTask) { /* code goes here */ });
PrintTask使用ArGIS Server 10.1及更高版本的导出Web地图任务生成可用的地图打印版本。当您希望对用户界面有更细粒度的控制时,例如,如果您希望为用户提供定义打印页面上显示内容的能力,则使用这个类。
使用PrintParameters设置任务的打印选项。
- var printTask = new PrintTask({
- url: printUrl
- });
-
- var template = new PrintTemplate({
- format: "pdf",
- exportOptions: {
- dpi: 300
- },
- layout: "a4-portrait",
- layoutOptions: {
- titleText: "Warren Wilson College Trees",
- authorText: "Sam"
- }
- });
-
- var params = new PrintParameters({
- view: view,
- template: template
- });
-
- printTask.execute(params).then(printResult, printError);
PrintTemplate:https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions
require(["esri/tasks/support/PrintTemplate"], function(PrintTemplate) { /* code goes here */ });
定义 PrintTask 和 Print 用于生成打印页面的布局模板选项。
以下个人测试:
-
- this.mapView.when(() => {
- var printTask = new PrintTask({
- url: "https://cl.arcgis.online:6443/arcgis/rest/services/test11/GPServer/%E5%AF%BC%E5%87%BA%20Web%20%E5%9C%B0%E5%9B%BE"
- });
-
- var template = new PrintTemplate({
- format: "pdf",
- // exportOptions: {
- // dpi: 300
- // },
- layout: "PrintTestCL",
- // layoutOptions: {
- // titleText: "Warren Wilson College Trees",
- // authorText: "Sam"
- // }
- });
-
- var params = new PrintParameters({
- view: this.mapView,
- template: template
- });
-
- printTask.execute(params).then(function printResult(result){
- console.log("result-->",result)
- }, function printError(error){
- console.log("error-->",error)
-
- });
- })
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。