This page is one of the MapGuide Community CodeSamples. Visit the CodeSamples page to view more!

About Scribble

Scribble was designed to be an adjunct to any map/layout we created here at MIA. A “kinda-sorta” universal plugin application for pdf output and html table output from a MG selection. The markup came along as part of the generalization process.


First and foremost I must acknowledge the following legends of the open source community:

iText – Bruno Lowagie and Paulo Soares I am amazed at how many commercial packages are based on and actually include this work.

IKVM – Jeroen Frijiters Pretty much single-handedly brought on the demise of Microsoft’s J#


Here is the platform information:

  • MapGuide Open Source 1.1
  • Windows XP or Windows Server 2003
  • .Net Framework 2.0
  • Visual Studio 2005
  • ASP.NET Ajax 1.0
  • ASP.NET 1.0 AjaxControlToolkit -

I also borrowed extensively from the "gt" MGOS sample application. Easily said that this was the starting point for the geometry portion of this application.


This application was designed to run within the taskFrame of MG as an iframe within an AjaxlToolkit TabPanel. Specifically I set this up to be instantiated thusly:

        HtmlControl frame1 = new System.Web.UI.HtmlControls.HtmlGenericControl("iframe");
        frame1.Attributes["src"] = "http://" + dnsname + "/mapguide/Scribble/scribble.aspx?SESSION="
                                    + args["SESSION"] ;
        frame1.Attributes["frameborder"] = "0";
        frame1.Attributes["scrolling"] = "auto";
        frame1.Attributes["width"] = "100%";
        frame1.Attributes["height"] = "400px";
        frame1.Attributes["allowTransparency"] = "true";

This then explains the "parent.parent.parent.mapFrame" references within the javascript.

Needless to say you may do what you wish. (As an aside, I actually have 4 separate applications in 4 tabpanels all interacting with the map).

Preparing iText and IKVM

This step is optional, since the DLLs are included in the package, but worth understanding.

If you know nothing of iText and IKVM I recommend you spend some time reading. These apps are impossible to explain in a few words. I will just tell you what I have done.

I used the following ikvmc commands to create the itext and bouncycastle dll’s

 ikvmc -target:library -reference:IKVM.GNU.Classpath.dll bcpg-jdk15-137.jar 
 ikvmc -target:library -reference:IKVM.GNU.Classpath.dll -reference:bcpg-jdk15-137.dll bctsp-jdk15-137.jar 
 ikvmc -target:library -reference:IKVM.GNU.Classpath.dll -reference:bcpg-jdk15-137.dll -reference:bctsp-jdk15-137.dll bcprov-jdk15-137.jar
 ikvmc -target:library -reference:IKVM.GNU.Classpath.dll -reference:bcpg-jdk15-137.dll -reference:bctsp-jdk15-137.dll -reference:bcprov-jdk15-137.dll bcmail-jdk15-137.jar

 ikvmc -target:library -reference:IKVM.GNU.Classpath.dll -reference:bcmail-jdk15-137.dll -reference:bcprov-jdk15-137.dll itext-2.0.6.jar 

THAT’S IT !!!! You just created .NET dll’s from jars!! (As another aside: there are LOTS of GIS related jars out there)

Do NOT be overly concerned with the warnings coming out of bouncycastle. Most of these have to do with encryption and stamping and mailing. I do not understand fully but I never have had to use those methods anyway. Please keep in mind the older iText stuff works great to! I have used versions from 1.4 – 2.0 without any difficulty. Again the bouncycastle stuff is recent. You are going to be amazed at how simple this really is!!

I currently use these dll’s


Drop these dll’s into your applications bin directory, make your references to them and start “using”

using ikvm.lang;
using com.lowagie.text;
using com.lowagie.text.pdf;
using com.lowagie.text.pdf.codec;

Getting Started with Scribble

Take a look at scribblemethodsmgr.cs and most everything will become obvious. (For all you .NET purists out there the [WEBMETHOD] decoration on some of these methods is pointless I know, but it looks nice.)

 public byte[] MaterializeMapImagePage(string session, string mapname, int width, int height, string imageflavor)


public byte[] MaterializeMapPDFPage(string session, string mapname, int width, int height, string imageflavor)

If you don’t like my approach in using ajax calls just rip out the pdf creation stuff and put it directly into the .ashx helper. This will work just as well and you won’t have to be bothered with the other stuff. I just like keeping the file count down and like the consolidation of codebehind that my approach gives. To each is own.

I have zipped up just the source and the overall structure so you will be able to get a feel of the overall architecture. I also included the web.config and put it into a separate directory.

Enjoy .... dennis



Markup Example

Scribble Markup Example

Markup as PDF

Scribble Markup as PDF

Query Example

Scribble Query Page

Query HTML Output

Scribble Query HTML output

Added (by Andy Morsell) August 2008 for MGOS 2.0 Compatibility

I was looking at integrating this into an application and had some issues making it work with MGOS 2.0.1 and within a generic environment. So, I thought I would share those changes with other users. Go here to download a zip file which includes all of the files necessary to plug-and-play this into the task frame of a standard AJAX layout.

Items that have changed:

  • Edited scribblemethodsmgr.cs to be compatible with API changes from MGOS 1.2 to 2.0. Meaning: MgCoordinateSystemFactory::GetTransform is now used instead of the deleted MgCoordinateSystemTransform constructor.
  • Edited scribble.aspx to remove all hard-coded AJAX viewer frame name dependencies. Replaced with two new global JavaScript variables (mapFrame and mainFrame).
  • Bundled all dll's including any Microsoft .NET and AJAX dependencies. You should not need to install the AJAX Toolkit on the server for this to work.

To use this package: unzip to a folder of your choice. Create a new virtual directory in IIS called Scribble under your existing mapguide virtual directory. Copy the MapGuide dll files from C:\Program Files\!MapGuideOpenSource2.0\WebServerExtensions\www\mapviewernet\bin to your Scribble\bin directory. Open your web layout in Studio and create a new Invoke URL custom command that points to ../Scribble/scribble.aspx with the task pane being the target. Add this custom command to your task bar menu or toolbar. Open your layout and invoke your custom URL.

Alternative PDF Generation

For those of you who use ScribbleR2 I have generated an alternative MaterializeMapPDFPage method. This will produce three(3) images and one(1) text page in the generated PDF file.

        byte[] forPdf1 = MaterializeMapImagePage(session, mapname, width, height, imageflavor);
        byte[] forPdf2 = MaterializeMapImagePage(session, mapname, System.Convert.ToInt32(Math.Ceiling(width * .65)), System.Convert.ToInt32(Math.Ceiling(height * .65)), imageflavor);
        byte[] forPdf3 = MaterializeMapImagePage(session, mapname, System.Convert.ToInt32(Math.Ceiling(width * .40)), System.Convert.ToInt32(Math.Ceiling(height * .40)), imageflavor);

Preferences are set in the output PDF to show thumbnails and Fit.

The fourth(4) page is the text contents of the Scribble markup layer. (centroid of geometry)

If you have made no changes yourself you should be able to rename the existing MaterializeMapPDFPage method that is in scribblemethodsmgr.cs, copy and paste the contents of the attachment and you should be good-to-go.

Last modified 11 years ago Last modified on Feb 6, 2013, 1:19:43 PM

Attachments (6)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.