Hi Royce,This is what I have been using for the last few years.I built some functions to copy the map into a bitmap object and crop it to suit whatever size is needed.It doesnt matter the size of the browser window it uses the ratio of the desired print size to crop the map.The Bitmap can the be used in AlivePDF. (no cloning of maps needed).As you say it is what it is and sometimes using the latest and greatest is not an option.I have not tested in AGS Flex API 3.1 because our organisation is still on 10.x of flash, and 10.0 of ArcGIS.Sounds like the new 10.1 print options would be great, but no good to me at the moment.Basic rundownWhen generating pdf use the PrintMapUtil.trimmedMap function.
protected function button1_clickHandler(event:MouseEvent):void
{
var pdf:PDF = new PDF(Orientation.LANDSCAPE,Unit.INCHES,Size.LETTER);
pdf.setDisplayMode (Display.FULL_PAGE);
pdf.setMargins(0.5,0.5,0.5,0.5);
pdf.addPage();
pdf.setAutoPageBreak(false,0.5);
//Use the PDF page margins for the width and height of printable map area.
//The content width and height are the desired map size on the page. This example is
//just fitting the map to the margins.
var marginsRectangle:Rectangle = pdf.getMargins();
var contentWidth:Number = marginsRectangle.width;
var contentHeigth:Number = marginsRectangle.height ;
var newBitmap:Bitmap = PrintMapUtil.trimmedMap(map, contentWidth, contentHeigth);
// Add the map image
pdf.addImage(newBitmap, null ,0, 0,
contentWidth , contentHeigth , 0, 1, true, ImageFormat.JPG, 75);
pdf.save(Method.REMOTE,
"http://alivepdf.bytearray.org/wp-content/demos/create.php",
Download.ATTACHMENT, "report.pdf");
}
public static function trimmedMap(map:Map, printAreaWidth:Number, printAreaHeight:Number):Bitmap
{
var rectangle:Rectangle = clipRectangle(map, printAreaWidth, printAreaHeight);
//get the map as bitmapdata so the part we want can be copied and clipped.
var myBitmapData:BitmapData = new BitmapData(map.width,map.height);
myBitmapData.draw(map,null,null,null,rectangle,true);
// create a new cropped map image to fit the print area.
var newBitmapData:BitmapData = new BitmapData(rectangle.width, rectangle.height)
newBitmapData.copyPixels(myBitmapData, rectangle, new Point(0, 0));
return new Bitmap(newBitmapData);
}
See attached for a sample project and the full PrintMapUtil with the clipRectangle function. (fxp file is inside the zip)