I have all attribute data at my client side how I can create pdf.
I know I can pass this data to .ashx or serverside and create a pdf at backend. But is this idle way
Robert Scheitlin, GISP . Please provide your valueable inputs. If i wrap this application in MVC will it work
Shafi,
I have not attempted to create PDFs in JS, so I don't have any advice for you on this.
I have already done this by sending data to server side but now In final report I want to make consolidated report that will contain Map also in single pdf file.
Shafi,
OK. here is some code to get the map image and add it to the DOM. How you get this to the server or do this differently using your server generated pdf workflow is all on you. This is just a concept example.
'esri/tasks/PrintTemplate', 'esri/tasks/PrintParameters', 'esri/tasks/PrintTask', 'dojo/dom-construct', //Hide the maps info window this.map.infoWindow.hide(); var oWid = this.map.width; var oHgt = this.map.height; var printTask = new PrintTask('http://your server/arcgis/rest/services/ExportWebMap/GPServer/your servers Export Web Map task'); var template = new PrintTemplate(); //my calculation to maintain the maps aspect ratio and still have good resolution in output this.imgHeight = (740/oWid) * oHgt; template.exportOptions = { width: 1542, height: (1542/oWid) * oHgt, dpi: 200 }; template.format = "jpg"; template.layout = "MAP_ONLY"; template.preserveScale = false; template.showAttribution = false; var params = new PrintParameters(); params.map = this.map; params.template = template; printTask.execute(params, lang.hitch(this, this.printResult)); //I place a div that will be a place holder for the map image and have a image inside it that indicates work is in progress var map = domConstruct.toDom('<div id="mapImgDiv" style="height:400px;width:740px;border:solid 1px black;background-color:lightgray;"><div style="width:100%;height:100%;position:relative;"><div class="loading-container"><img src="images/downloading.gif"/><p>Retrieving Print Quality Map Image...</p></div></div></div>'); domConstruct.place(map, dom.byId('main'), 'last'); //in the printResult function I replace the temp map div in the dom with the returned map image printResult: function(rsltURL){ var mapImg = domConstruct.toDom('<img src="'+rsltURL.url+'" border="0" style="width:740px;height:'+this.imgHeight+'px;"/>'); domConstruct.place(mapImg, dom.byId('mapImgDiv'), 'replace'); },
Dear Robert,
Thanks for your reply will go through it and will update you
Shafi