Select to view content in your preferred language

Advanced print solution

53232
296
02-19-2011 10:52 AM
TomSchuller
Frequent Contributor
Please find in the codegallery my first version of an advanced print solution:
http://www.arcgis.com/home/item.html?id=6809086326ea4c76bf026a32bb9dd698

The backend is developed in Java as a ServerObjectExtension: PChPrintSOE

The communication to the SOE is realized by the REST.
So, any client can be used Flex, Javascript, ...
I just created a simple FlexWidget.

Some features:
- full print over the rest api (usable by any client)
- export to pdf,jpeg,png,emf and mxd!
- view paper layout extent live on map
- make print on a "template" mapservice by keeping the predefined layout
- multi-mapservices/multi-server support
- add graphics on the map view positioned in map units
- add elements on the layout view positioned in paper units like scalebar, scaletext


The code is under full development:
- support for wms layer
- code clean up and reorganization

Any suggestions, remarques or help is welcome.

Live demo with public Esri mapservices (last print button):
http://gis.pch.etat.lu/flexViewerPrint/
   - use this print widget with your PChPrintSOE-enabled mapservices for high quality
   - draw first some graphics with the DrawWidget prior making your print (in mxd format)
Tags (2)
0 Kudos
296 Replies
JustinConner
Frequent Contributor
First let me say great widget! Vast improvement over the ESRI sample and other geoprocessing examples that are out there. But I have a couple things I'd like to bring up.

- I noticed that when the widget is minimized, its size is still quite large when compared to the other widgets.

- Is there a way to customize the layout? What I'm trying to do is move the title above the map frame or add a white background like the legend or scale text. I'm also having a heck of a time with the logo in regards to image size, shape and placement on the map layout. How about changing the north arrow, etc. Does changing the "layout" mxd have any effect on the printed page?

- On install it took me a few tries to learn the proper syntax it wanted. As far as the server name goes. Also, in my case I was getting tripped up on the Java path. My path wasn't exactly the same as what I copied and pasted from the instructions. Stupid mistake but maybe others will see this and not make the same one.

- "Printing" to an mxd doesn't work for me because the results add an extra mxd file extension. I havent looked into it much so it may be something silly i'm doing.

I should add that i'm using the compiled version.

Thanks again and if I notice anything I'll let you know.
0 Kudos
IrfanClemson
Frequent Contributor
Hi Tom,
Here is what the Flex debugger's console says. Copied/Pasted after removing a chunk of coordinates--it was otherwise a very large .txt file. Again, the error happens when we get a large number of data rows (160+ or may be lesser) in the enhance Search Result Widget. Zooming out fully without any large result set does not cause the problem.
Anyway, here it is.
Thanks!
Meengla


http://maps.xxx.edu/ArcGIS/rest/services/layout/MapServer/exts/PCHPrintSOE/printMap?mapExtent={"xmin":-9224874.90590084,"ymin":4116635.130069679,"xmax":-9217231.20307212,"ymax":4121589.2049655425,"spatialReference":{"wkid":102100}}&printOutput={"width":17.391304347826086,"height":11.271739130434783,"borderWidth":[0.5,0.5,0.5,0.5],"format":"pdf","mapRotation":0,"toRemoveLayoutElements":[],"pageUnits":1,"resolution":92,"exportSettings":null}&mapElements=[{"geometry":{"rings":[[[-9222627.767492853,4120212.7932154266],[-9222625.709194576,4120197.8460673364],[-9222513.589208428,4120210.5774521423],[-9222511.399682475,4120206.36094105],[-9222486.420188498,4120163.809580012],[-9222400.88746764,4120043.823456807],[-9222378.154607851,4120012.3996253754],[-9222283.298156029,4119881.2837072853],[-9222211.862679211,4119783.3473444553],[-9222169.539700389,4119726.179863304],[-9222129.450324766,4119675.8988936916],[-9222090.614872798,4119633.6527687423],[-9222050.299832985,4119596.0718720327],[-9222012.836583393,4119565.805082913],[-9221978.37482264,4119538.984883782],[-9221935.220534319,4119511.8480072333],[-9221891.934163688,4119485.814329291],[-9221850.35538644,4119464.8091736916],[-9221797.87402056,4119441.8484209357],[-9221254.913329689,4111103.0530483574],[-9221254.387765499,4111102.5297378153],[-9221253.868759751,4111101.9997247816],[-9221253.356565928,4111101.4636144657],[-9221252.79201595,4111100.8569742157]]],"spatialReference":{"wkid":102100}},"symbol":{"style":"esriSFSSolid","color":{"blue":0,"alpha":127.5,"red":255,"green":0},"outline":{"width":2,"style":"esriSLSSolid","color":{"blue":0,"alpha":204,"red":255,"green":0},"type":"esriSLS"},"type":"esriSFS"}}]&layoutElements=[]&mapServices=[{"alpha":1,"url":"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer","name":"Streets","visibleIds":"0","type":"AGS"},{"alpha":0.8984375,"url":"http://maps.xxxxx.edu/ArcGIS/rest/services/CU_LAND_v2/MapServer","name":"ccc Land","visibleIds":"0,1,2","type":"AGS"}]



0 Kudos
TomSchuller
Frequent Contributor
conner_justin,
I will take a look to the minimize widget size.
To customize the layout, you have several possibilies:
  - define the layout in the widget config file
  - define the layout in ActionScript in the widget source
  - define the layout directly in the "layout" mxd (remember to configure the "toRemoveLayoutElements")

If you have improved instructions, just post them. I will add them.

For each print you are making, there is generated the output file AND a mxd file. The mxd file is useful for debugging purpose if there are problems with layers or graphics.
I you set the outputformat to "mxd", only the mxd file will be generated.

Tom
0 Kudos
TomSchuller
Frequent Contributor
Meengla,
could you please post/mail the verbose ArcGIS server log?
I would like to check for errors concerning maxjsonlength.
This problem is described here:
http://forums.arcgis.com/threads/28386-maxjsonlength-in-ArcGIS-REST-SOE

Tom
0 Kudos
IrfanClemson
Frequent Contributor
Tom,
I don't know if I can get to turn on the Verbose Logging without too much hassles--not my server. But if the issue can be fixed in the next version of Arc GIS Server then we can wait till then.
Thanks!
Meengla
0 Kudos
EricVenden
Frequent Contributor
Tom,
We are looking to tweak your Java code a bit.  We used the Java SDK to package your source code into a .jar file.  The resultant jar file did not work so well.  Can you tell me what you use to package your code into a jar file that AGS will find acceptable?

Thanks for your time.
Eric V
Gurnee, IL
0 Kudos
TomSchuller
Frequent Contributor
ericv,
could you post your non-working jar file?
There is nother special in my build/packaging.

May I ask what you want to improve/add?

Tom
0 Kudos
MattiasEkström
Frequent Contributor
Hi Tom!
I've been looking forward to look in to this print solution a long time (my users are frequently asking for something like it), and finally I've got an ArcGIS Server 10 up and running and the time to look in to this.
I haven't been able to get this to work and have some questions that I haven't found an answer to in the forum.
I tried to follow your quick installations steps, but couldn't run the soemanager.bat since my server is a linux server (SUSE 10). Anyway I looked at some documentation and it seems to be enough to just copy the .jar file to ".../java/lib/ext" and register it in ArcGIS Manager. I have successfully published my layout service and enabled the PCHPrintSOE and printMap, cleared the rest cache and got my PrintUrl.
What about PCHExportSOE? am I supposed to enable that one to or not?
Is it important to check both PCHPrintSOE and the printMap operation?
Do I need to do this for all services that will be used? (or only the layout-service)?

At first I enabled both PCHPrintSOE and PCHExportSOE, print didn't worked, the service timed out, the log filed showed some "PCHExportSOE.init ERRORS" so I disabled that one on all of my services and tried again, still doesn't work. This time the errors I'm getting in the log file are "downloadFile ERRORS". It looks like this:
ERROR   downloadFile.destination: /tmp/AGSLayer5160090355200531065.lyr   2011-07-06T14:50:51   layout.MapServer   gisdev 
ERROR   downloadFile.fileUrl: http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer?f=lyr&v=9.3   2011-07-06T14:50:51   layout.MapServer   gisdev 
ERROR   downloadFile.FileNotFoundException: http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr   2011-07-06T14:50:51   layout.MapServer   gisdev 
ERROR   downloadFile.destination: /tmp/PCHPrintSOELayer1449693673605285143.lyr   2011-07-06T14:50:51   layout.MapServer   gisdev 
ERROR   downloadFile.fileUrl: http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr   2011-07-06T14:50:51   layout.MapServer   gisdev 
ERROR   downloadFile.destination: /tmp/PCHPrintSOELayer4366513632110866785.lyr   2011-07-06T14:50:50   layout.MapServer   gisdev 
ERROR   downloadFile.fileUrl: http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/2.lyr   2011-07-06T14:50:50   layout.MapServer   gisdev 
ERROR   downloadFile.destination: /tmp/PCHPrintSOELayer6368293072691338280.lyr   2011-07-06T14:50:50   layout.MapServer   gisdev 
ERROR   downloadFile.fileUrl: http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/1.lyr   2011-07-06T14:50:50   layout.MapServer   gisdev 
ERROR   downloadFile.destination: /tmp/PCHPrintSOELayer1586290742058941262.lyr   2011-07-06T14:50:49   layout.MapServer   gisdev 
ERROR   downloadFile.fileUrl: http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/0.lyr   2011-07-06T14:50:49   layout.MapServer   gisdev 

Any idea what that means and what I could do to get this working?
(My server is not public so I can't give you any urls to my service directory or something like that)
/Mattias
0 Kudos
TomSchuller
Frequent Contributor
mattias_j,
are any of these url returning a layerfile?
  http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer?f=lyr&v=9.3
  http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr

Please run it on your server with "wget".
Does the layerfiles work in ArcMAP?


Could you also indicate me the full path to your ArcGIS-server configuration directory?
Should be like <AGSHome>/server/user/cfg.


Tom
0 Kudos
EricVenden
Frequent Contributor
ericv,
could you post your non-working jar file?
There is nother special in my build/packaging.

May I ask what you want to improve/add?

Tom


Hi Tom,

I've attached the non-working .jar file.  It appears that in your .jar file there are files that are not in the .jar file we generated using the sdk.  The items in your .jar file are not found in your source java code.

I wanted to change the following:
1) set default text size for the title to something larger than what it is currently
2) enable a background box for the Title - I've added the code in the flex end of things
3) enable the scale to read - 1:50 instead of 1:600 - use the label (from xml) instead of the value

Thanks for your time.
Eric V
0 Kudos