Select to view content in your preferred language

Advanced print solution

53736
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
TomSchuller
Frequent Contributor
ericv,
the jar file seems to contain the source files (xxxx.java).
It should contain the compiled files (xxxx.class).

You could open the jar with a simple zip-client to see the content.

Tom
0 Kudos
EricVenden
Frequent Contributor
ericv,
the jar file seems to contain the source files (xxxx.java).
It should contain the compiled files (xxxx.class).

You could open the jar with a simple zip-client to see the content.

Tom


Tom,
We downloaded Eclipse, installed the plug-in (ArcObjects), created a project, added a library (simpleimageinfo) that wasn't included in the source.  We then made it an SOE project...then exported it.

This appears to have worked - we just used your source files.  Not onto modification.
Thanks
Eric V
0 Kudos
MattiasEkström
Frequent Contributor
Hi Tom, thanks for your time!
I used wget on my server and the first url (http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer?f=lyr&v=9.3) did return a lyr-file, though it wasn't defined as a .lyr just an unknown file.
Second one (http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr) did not, it returned an error 404: Not Found.

In my ArcGIS log file posted earlier there was errors for 0.lyr, 1.lyr, 2.lyr and 5.lyr. If a look in the .../arcgisoutput/BGK_BGKtest_MapServer/lyr/ folder there actually are lyr files 0, 1, 2, 3 and a copy of them all named like 1_layername.lyr and a layers_ALL.lyr
So if I use wget to get one of them it returns a lyr file. All lyr files seems to be ok in ArcMap, I have to copy them to my computer and the data sources gets broken but if I repair them they seems to work as they should.
Although they lyr files pointing to a arcgis mapservice doesn't work because outside the server the domain gisdev.hallberg.se isn't recognized I have to use IP-number instead, it's a test server and the domain isn't set up in our network yet, could this be a problem? I'm running the flex application from another server using the IP-number to access the services.

the full path to my ArcGIS-server configuration directory is /opt/arcgis/server10.0/server/user/cfg

/Mattias
0 Kudos
TomSchuller
Frequent Contributor
mattias_j,
you have to get running the "wget" to load a lyr-file from the arcgisouput directory on your AGSserver.

if this return a 404 error:
wget http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr

could you try with the ip-address, I suppose:
wget http://10.202.101.108:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr

To get high quality working, you have to get this url working with the wget command:
  http://xxxxxxx/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr


You are saying that the "gisdev.hallsber.se" isn't known outside the server?
Do your client need to use the ip-address to access it?
Did your clients actually get a map-image?

What does this page return when using FORMAT=json:
http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer/export
Does it return a valid url?

I uploaded a new jar-file considering your Linux-AGS-HOME: PCharcgisSOE.jar

Tom
0 Kudos
MattiasEkström
Frequent Contributor
Tom,
I updated the jar-file (just copied it and restarted my map services).
Tried tp print again, and this time I only get one error for each print attempt in the arcGIS Server log.
It's "downloadFile.FileNotFoundException: http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/5.lyr"
The thing is that this BGKtest mapservice I'm using for testing is a simple map with only 4 layers, one annotation, two line features and one polygon feature. In the arcgisoutput/BGK_BGKtest_MapServer/lyr/ folder there is four lyr-files (0,1,2,3.lyr). I can get all thoose running the wget (for example wget http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/BGK_BGKtest_MapServer/lyr/2.lyr). So to me it seems to be looking for a lyr-file that isn't supposed to be there.
I also tried with my "real" map containing 105 layers, 105 lyr files are created, 0-104.lyr, but it is looking for a 105.lyr that doesn't exists.

The client uses the ip-adress to access the services and that works, i'm getting map-images.
the page http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer/export returns a valid url using the json format, here's an example:
{
 "href": "http://gisdev.hallsberg.se:8399/arcgis/server/arcgisoutput/_ags_map392d5114a7cd11e08538080027ac2eb4.png",
 "width": 400,
 "height": 400,
 "extent": {
  "xmin": 1459300,
  "ymin": 6549050.000000001,
  "xmax": 1460400,
  "ymax": 6550150.000000001,
  "spatialReference": {"wkid": 3021}
 },
 "scale": 10393.679999999998
}   


And antoher problem I have is that sometimes I can't restart my services that I have enabled the printSOE on, I'm getting this error in the log:
ERROR   PrintTask().IOException: AutomationException: No such interface supported

Thanks! /Mattias
0 Kudos
TomSchuller
Frequent Contributor
mattias_j,
the layer-id-5 seems to be related to wrong parameters generated from the FlexWidget.

First we have to get running the SOE, so could you please post the generated url of the FlexWidget.
Ever start the viewer in debug mode using FlexBuilder and check the output window after making a print or use Fiddler (free web debugger).

Please post the whole url, the http-address and the paremeters.

Tom
0 Kudos
MattiasEkström
Frequent Contributor
It feels like I'm going backwards with this, before I didn't got any errors in the flex application until the service timed out and the ArcGIS Server log showed the 'file not found error'. Now when I try to print from the flex application I get an 'Error during print!' at once. The ArcGIS Server log doesn't show any errors or warnings. But now every time I start or restart a service that has PCHPrintSOE enabled I'm getting the error:
ERROR   PrintTask().IOException: AutomationException: No such interface supported
that doesn't sounds good to me at all...

Anyway, trying to print in debug mode I can se urls like this:
http://10.202.101.108:8399/arcgis/rest/services/layout/MapServer/exts/PCHPrintSOE/printMap?mapExtent={"xmin":1459087.998475997,"ymin":6549246.780543561,"xmax":1460612.001524003,"ymax":6549953.219456439,"spatialReference":{"wkid":3021}}&printOutput={"mapRotation":0,"pageUnits":1,"format":"pdf","exportSettings":null,"height":9.673913043478262,"width":20.869565217391305,"toRemoveLayoutElements":[],"resolution":92,"borderWidth":[0.5,0.5,0.5,0.5]}&mapElements=[]&layoutElements=[]&mapServices=[{"alpha":1,"visibleIds":"0,1,2,5,6,7","type":"AGS","url":"http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer","name":"testMap"}]

or if in the other state of the widget something longer like:

http://10.202.101.108:8399/arcgis/rest/services/layout/MapServer/exts/PCHPrintSOE/printLayout?mapExtent={"xmin":1459785.9770552877,"ymin":6549455.489437812,"xmax":1459885.9770552877,"ymax":6549598.989437812,"spatialReference":{"wkid":3021}}&printOutput={"resolution":100,"format":"pdf","exportSettings":null,"width":21,"height":29.7,"borderWidth":[0.5,0.5,0.5,0.5],"toRemoveLayoutElements":["*"],"mapRotation":0,"pageUnits":8}&mapElements=[]&layoutElements=[{"xOffset":0,"yOffset":0,"anchor":"bottomleft","symbol":{"size":48,"type":"pchNorthArrow"},"geometry":{"x":0.5,"y":0.5},"visible":true,"name":null},{"xOffset":0,"yOffset":0,"anchor":"topmid","symbol":{"text":"Title","textSymbol":{"angle":0,"color":{"green":0,"alpha":255,"blue":0,"red":0},"text":null,"font":null,"xoffset":0,"yoffset":0,"borderLineColor":null,"type":"agsJsonSymbol"},"type":"pchTextElement"},"geometry":{"x":10.5,"y":29.2},"visible":true,"name":"myTitle"},{"xOffset":0,"yOffset":0,"anchor":"bottomleft","symbol":{"barHeight":5,"type":"pchScaleBar"},"geometry":{"x":0.5,"y":0.5},"visible":true,"name":"myScaleBar"},{"xOffset":0,"yOffset":0,"anchor":"bottommid","symbol":{"text":"© copyright pch","textSymbol":{"angle":0,"color":{"green":255,"alpha":255,"blue":255,"red":255},"text":null,"font":null,"xoffset":0,"yoffset":0,"borderLineColor":null,"type":"agsJsonSymbol"},"type":"pchTextElement"},"geometry":{"x":10.5,"y":0.5},"visible":true,"name":"myCopyRight"},{"xOffset":0,"yOffset":0,"anchor":"topleft","symbol":{"mapUnits":8,"separator":":","pageUnits":9,"backgroundColor":{"green":255,"alpha":255,"blue":255,"red":255},"style":0,"numberFormat":{"roundingOption":0,"roundingValue":3},"pageUnitLabel":"","mapUnitLabel":"","type":"pchScaleText"},"geometry":{"x":0.5,"y":29.2},"visible":true,"name":null}]&mapServices=[{"alpha":1,"type":"AGS","url":"http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer","name":"testMap","visibleIds":"0,1,2,5,6,7"}]


And I've forgot to mention that I'm getting two warnings when compiling the flex widget:
1084: function 'getClass' will be scoped to the default namespace: BaseWidget: internal.  It will not be visible outside of this package. PchPrintWidget.mxml /Hallsbergskartan_231_test/src/lu/etat/pch/gis/widgets/pchPrintWidget line 488 Flex Problem

3596: Duplicate variable definition. PchPrintWidget.mxml /Hallsbergskartan_231_test/src/lu/etat/pch/gis/widgets/pchPrintWidget line 469 Flex Problem


And when running in debug mode I also get a lot of warnings like these:
warning: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
warning: unable to bind to property 'popupClass' on class 'Object' (class is not an IEventDispatcher)
warning: unable to bind to property 'visible' on class 'Object' (class is not an IEventDispatcher)
warning: unable to bind to property 'label' on class 'Object' (class is not an IEventDispatcher)
warning: unable to bind to property 'editable' on class 'Object' (class is not an IEventDispatcher)


/Mattias
0 Kudos
TomSchuller
Frequent Contributor
mattias_j,
you can ignore the warnings.
These are not blocking the SOE.

This part in the url is important:
&mapServices= [{"alpha":1,"type":"AGS","url":"http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer","name":"testMap","visibleIds":"0,1,2,5,6,7"}]


It indicates that your mapservice "BGKtest has at least 8 layers [0,...,7].
How many layers are in your mapservice? You can check it on this page:
http://10.202.101.108:8399/arcgis/rest/services/BGK/BGKtest/MapServer
What's the highest layer id?

How many layers did you find in the <arcgisoutput>/BKG/BKGtest/lyr folder?

The layer count in the directory should be all the layers + a _all.lyr-file. Is that correct?
If not,
please configure the ArcGIS-server-log to "verbose", restart your mapservice and make a print.
Post this "server.log" file.

Tom
0 Kudos
MattiasEkström
Frequent Contributor
Tom,
I think I know what the problem is, if I look at the REST-page of my service it indicates that it has 8 layers, because the first layer is an Annotation Layer which has four Annotation sublayers, so that is treated as five layers by REST page. However in ArcMap one Annotation Feature Class with four subtypes/annotationclasses is treated as one layer.
I guess that's why only one lyr-file is created for layer 0-5 in my rest mapservice. I'm getting 0.lyr which is the whole annotation layer (id 0-4) and 1.lyr that is a Feature Layer with the id 5, and 2.lyr for the Feature Layers with the id 6 and so on...

I have tested to create a new mapservice without the annotations and successfully created several PDFs from it together with other services that uses labels instead of annotations.

But I need to be able to print mapservices that has annotationlayers with sublayers if I'm going to implement this print solution in my map application, and I would really like that, it's a great print solution you've made.
Would it be possible to fix this? and if so I'm guessing it would be in the java code that I'm not familiar with at all?
0 Kudos
TomSchuller
Frequent Contributor
mattias_j,
I just have added support for AnnotationLayers.

Could you try this new jar: http://gis.pch.etat.lu/flexViewerPrint/PCHarcgisSOE.jar
Replace it and restart your  ArcGIS-server services.

In the output directory, you should directly find the correct list of lyr-files.

Tom
0 Kudos