Select to view content in your preferred language

Printing issue with graphics layer and legend

3290
16
05-11-2010 12:46 PM
JamesTanis
Emerging Contributor
I am having some weird behavior with the print page.  First, I am using ESRI's street maps as my base layer then I have a graphics layer on top of along with a legend.  The problems that I am having are if I am zoomed out to the state level and launch the print page the base map is pu into four tiles down the page, while the graphics layer is centered in the page and not in the correct location and the legend does not show up (Picture 1).  Second, if I am zoomed into the a county or tract I have the same problem but this time there are less tiles for the base map and the legend shows up but with no background (Picture 2).  Fianlly, if you use firefox the graphics layer or the lengend never show up in the print page.  Any help would be greatly appreciated.

function clickheretoprint(divId, title, right, top, w, h) {

    if (right == null) right = 100;
    if (top == null) top = 25;
    if (w == null) w = 1000;
    if (h == null) h = 1000;
    if (title == null) title = "Print Screen";

    var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
    disp_setting += "scrollbars=yes,width=" + w + ", height=" + h + ", right=" + right + ", top=" + top;

    //get the html of the div  
    var content_vlue = dojo.byId('mapDiv').innerHTML;
    //strip out the link tags else we'll link back to the mapper page
    content_vlue = content_vlue.replace(/<a/g, "<span");
    content_vlue = content_vlue.replace(/<\/a/g, "</span");

    var docprint = window.open("", "", disp_setting);
    docprint.document.open();
    docprint.document.write('<html><head><title>' + title + '</title>');
    docprint.document.write('<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script>');
    docprint.document.write('</head><body onLoad="self.print()"><left>');
    docprint.document.write('<div id="position" style="position:absolute;margin-left:50px;margin-top:50px;">');
    docprint.document.write(content_vlue);
    docprint.document.write('</left></body></html>');
    docprint.document.close();
    docprint.focus();
}
0 Kudos
16 Replies
MikeMartin
Occasional Contributor
Exploring the Map2PF also...

Curious about the new 2.1 and if you have any sample code written for this using the 2.1 you'd share? and did you use one namespace (pointing to 2.1) or two+ ?

thanks!


All I have is a button that fires the function above. Re. 2.1 namespace, my only references to the api are the script
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script> and the css
<style type="text/css"> @import "http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/tundra/tundra.css";

Hope that answers your question, I'm not an expert at this stuff by any means.
0 Kudos
anwarawad
Deactivated User
dear mmartin
would you plzzzz send me a code snipit showing the complete block of code involved with your function you posted  that works with 2.1v ??

ill be soooo thankful

am trying to print a map with charts on it , which are picture markers
i used the print function mentioned before in the thread but i only can se the graphics on the screen, but not on the printout paper

could you plzzz help ?? its urgent

regards to all
0 Kudos
GlenRhea
Emerging Contributor
text = document
print(text)

This doesn't work when you're creating the page dynamically. Still searching for a halfway decent (and simple) way to print using a js viewer.

Glen
0 Kudos
Todd
by
Regular Contributor
For printing with JSAPI make sure you check out the Image Blender utility.
Regards,
Todd
0 Kudos
anwarawad
Deactivated User
hii

i want to creat a layout page and add the map to that layout with the graphics on it
that layout is printable ,, soo is the image blender is the best choice for that scenario ??
or can i do somethin else ???

thanx for replying
0 Kudos
MikeMartin
Occasional Contributor
dear mmartin 
would you plzzzz send me a code snipit showing the complete block of code involved with your function you posted that works with 2.1v ?? 

ill be soooo thankful 

am trying to print a map with charts on it , which are picture markers 
i used the print function mentioned before in the thread but i only can se the graphics on the screen, but not on the printout paper  

could you plzzz help ?? its urgent  

regards to all


The function itself is
[INDENT]function printscreen(text) {
[INDENT]text = document
print(text)
[/INDENT]}[/INDENT]

In the <body> I have
<button dojoType="dijit.form.Button" onClick="printscreen()">Print Map</button>

That's it. An example of a result is attached, showing a graphics layer, a dynamic layer, a tiled layer, and an info window.

Mike
0 Kudos
anwarawad
Deactivated User
hi

thanx alot for the help ,,
0 Kudos