感謝一路走來默默支持和陪伴的你~~~
----------------------歡迎來訪,拒絕轉載----------------------
1. 調用ArcGIS API的Print實現地圖的打印輸出,部分代碼如下:
//打印輸出的參數數組,為打印輸出的模板提供參數准備 var layouts = [{ name:"Letter ANSI A Landscape", label:"Landscape(PDF)", format:"pdf", options:{ "legendLayers":[legendlayer0,legendlayer1,legendLayer3], 'scalebarUnit':"Miles", 'titleText': dom.byId('print_title').value, "authorText":dom.byId('print_author').value, "copyrightText":dom.byId('print_copyright').value } },{ name:"Letter ANSI A Portrait", label:"Portrait(Image)", format:"jpg", options:{ "legendLayers":[legendlayer0,legendlayer1,legendLayer3], "scalebarUnit":"Miles", "titleText": dom.byId('print_title').value, "authorText":dom.byId('print_author').value, "copyrightText":dom.byId('print_copyright').value } }]; //定義打印輸出的模板 var templates = array.map(layouts,function(lo){ var t = new PrintTemplate(); t.layout = lo.name; t.label = lo.label; t.format = lo.format; t.layoutOptions = lo.options; return t; }); //打印輸出功能 printer = new Print({ map: map, templates:templates, url: "http://192.168.18.102:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task" }, dom.byId("printButton")); printer.startup(); });
在瀏覽器端執行,輸入圖名、單位等信息並進行打印輸出,選擇打印的方式,如下:
以為你會愉快的運行,然而卻遇到了一個醬紫的問題:輸出的中文全部為亂碼,怎么辦呢?
-----------------------這是一條華麗麗的分割線---------------------
2.問題分析
仔細查閱,打印的API中也並為提供對PrintTemplate的字體的設置,然而PrintTask服務也是調用了ArcGIS Server中內置的出圖模板,找到目錄,打開模板進行查看:
打開在代碼中所使用的相應的模板進行查看,驚奇大發現:所有輸出為亂碼的圖名、單位名稱等在模板中的默認字體均為Arial歐洲字體,怎能不可亂碼~~~

-----------------------這是一條華麗麗的分割線---------------------
3. 問題解決:
很簡單嘍,修改每一處的字體為中文字體:以圖名為例,右鍵單擊圖名選址properties,點擊Change Symbol,修改字體類型。修改完畢后保存並關閉MXD文檔。如下:
再次執行查看效果:

問題解決了~~~
----------------歡迎來訪,拒絕轉載----------------
版權聲明:本文為博主原創文章,未經博主允許不得轉載。