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 http://www.lowagie.com/iText/ I am amazed at how many commercial packages are based on and actually include this work.
IKVM – Jeroen Frijiters http://www.ikvm.net/ 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 - http://www.codeplex.com/
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.
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"; theFrameScribble.Controls.Add(frame1);
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.
I used the following ikvmc commands to create the itext and bouncycastle dll’s
::REM 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 :: FINALLY ikvmc -target:library -reference:IKVM.GNU.Classpath.dll -reference:bcmail-jdk15-137.dll -reference:bcprov-jdk15-137.dll itext-2.0.6.jar ::REM
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
itext-2.0.6.dll IKVM.Runtime.dll IKVM.GNU.Classpath.dll bcprov-jdk15-137.dll bcmail-jdk15-137.dll
Drop these dll’s into your applications bin directory, make your references to them and start “using”
using java.io; 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 as PDF
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.
* MGOS2 Scribble Package (at www.spatialgis.com due to size restrictions)
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.
- 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.
(92.0 KB) - added by jbirch
7 years ago.
Scribble Code (no DLLs)
(36.2 KB) - added by jbirch
7 years ago.
Scribble Markup Example
(44.5 KB) - added by jbirch
7 years ago.
Scribble Markup as PDF
(43.1 KB) - added by jbirch
7 years ago.
Scribble Query Page
(28.9 KB) - added by jbirch
7 years ago.
Scribble Query HTML output
(6.9 KB) - added by amorsell
6 years ago.
Alternative PDF generation code