[mapguide-users] Printing

Jonio, Dennis (Aviation) DJonio at miami-airport.com
Tue Nov 20 12:22:16 EST 2007


Ok ...

Here goes. No, there is no "scaling". In this generation the
fundamentals are very, very simple ... Whatever the map shows gets
captured via RenderMap. In my case, RenderMap produces a PNG(could just
as well be a jpeg) that is passed on to iText methods that turn that
stream into an image which in turn is used to "size" the paper selection
for the PDF. The page is added to the PDF document and the PDF document
is streamed to the http response stream. Obviously all of the save,
zoom, select, pan and print functions of Adobe Reader are there. 

 

Here are the contents of scribblepdfdoc.ashx.

 

<%@ WebHandler Language="C#" Class="scribblepdfdoc" %>

 

using System;

using System.Web;

 

public class scribblepdfdoc : IHttpHandler {

    

    public void ProcessRequest (HttpContext context) {

 

        ScribbleMethodsMgr smm = new ScribbleMethodsMgr();

        byte[] v =
smm.MaterializeMapPDFPage(context.Request.QueryString[0],

 
context.Request.QueryString[1],

 
System.Convert.ToInt32(context.Request.QueryString[2]),

 
System.Convert.ToInt32(context.Request.QueryString[3]),

 
context.Request.QueryString[4]);

        context.Response.AppendHeader("Expires", "0");

        context.Response.AppendHeader("Cache-Control", "post-check=0,
pre-check=0");

        context.Response.AppendHeader("Pragma", "public");

        context.Response.ContentType = "application/pdf";

        context.Response.BinaryWrite(v);

        context.Response.Flush();    

    }

 

    public bool IsReusable {

        get {

            return false;

        }

    }

}

 

I choose to put the actual stream creation inside a class that contains
a whole lot more than just creating a PDF stream. There is however no
reason why that method could not be placed inside this helper. I have
done it before for other applications. 

 

I have gotten the impression from reading other pages on OSGeo that this
forum does not like submissions, of code, that do not meet their
requirements for portability etc, etc. So I am hesitant to provide more.
I really do not wish to get them upset :-)  Maybe they don't mind a
snippet at a time ....????

 

I hope this much helps. Give a shout if you wish more .... 

dennis

 

 

 

________________________________

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Chris
Tallman
Sent: Tuesday, November 20, 2007 11:06 AM
To: MapGuide Users Mail List
Subject: RE: [mapguide-users] Printing

 

Dennis,

 

I like your approach, Does it allow you to print on large format to a
scale?

 

Chris

 

________________________________

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Jonio,
Dennis (Aviation)
Sent: Monday, November 19, 2007 10:50 AM
To: MapGuide Users Mail List
Subject: RE: [mapguide-users] Printing

Chris,

 

I decided before even starting on MGOS to output to PDF file format. Let
Adobe Reader handle all the printing output options and the zooming and
the panning and the .... options,options,options. 

 

All my stuff is .NET specific. My boss has 'guidelines' after all ...

 

I have been producing PDF's  using "iText" for a couple years now and
irrespective of what I think the users love it. I will not burden you
with all the details but I am use "ikvm" in conjunction with "iText" ...
(this way I am able to stay up to date with "iText"). There is however a
.NET version of out there that is somewhat behind Bruno's work.

 

The guts of what I have done relies on RenderMap .. (MgByteReader
byteReader = renderingService.RenderMap(map, selection,
mapCenterCoordinate, mapScale, width, height, color,
imageflavor.ToUpper());

 

I would be glad to share but I have not a clue how to go about this
within this forum. 

 

.... As an example ....

I have done it using http "ashx" request and the latest iteration uses a
ajax .net 1.0 webmethod call from javascript.

 

function ScribblePDF()

{

                tmp_control = document.getElementById("sessionName");

                SESSION = tmp_control.value;

                tmp_control = document.getElementById("mapName");

                MAPNAME = tmp_control.value;

                w = window.open("scribblepdfdoc.ashx?SESSION=" + SESSION
+ "&MAPNAME=" +MAPNAME + "&WIDTH=" + SCRIBBLEPDF_WIDTH + "&HEIGHT="
+SCRIBBLEPDF_HEIGHT + "&TYPE=" +SCRIBBLEPDF_TYPE
,"pdfmap","toolbar=no,status=no,width=550,height=720,resizable=yes,scrol
lbars=yes",false);

              try {

                   w.focus();

                } catch(Exception) { }   

            }

 

Let me know if you wish additional info ...

dennis

 

 

 

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Chris
Tallman
Sent: Monday, November 19, 2007 9:28 AM
To: MapGuide Users Mail List
Subject: [mapguide-users] Printing

 

Morning,

 

Has anyone built a printing app for MGOS?  I have a client that would
like to be able to print on a large format plotter.  I've not worked
with the printing functions and wondered if someone had already built
something that gives printing options and would be willing to share with
the group.

 

Thanks,

 

Chris

________________________________

E-mails are automatically scanned for viruses using McAfee. 

________________________________

E-mails are automatically scanned for viruses using McAfee. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20071120/ad3db530/attachment.html


More information about the mapguide-users mailing list