I'm printing PDFs using PdfSharp and XGraphics. I started out by using the provided examples but my PDFs were coming out to be way too large in file size to be useful (since it was all vector data). Average size was about 30MB. I decided I'd try to generate a high-resolution (300dpi) image and force feed that to the PdfSharp. It worked out much better. However, I have a problem... my PointStyle are not scaling. Everything looks great except I have very tiny points for my PointStyle and IconStyle. LineStyle and AreaStyle are fine. Any ideas on what I could do to have these come out properly?
Any help/tips would be appreciated...
Thanks,
Abner
public void RaiseCallbackEvent( string ea )
{
string[] arguments = ea.Split( '|' );
if ( arguments.GetLength( 0 ) < 2 )
{
callbackResult = "ERROR: Could not acquire active layer list.";
return;
}
string[] bounds = arguments[0].Split( ',' );
string[] overlays = arguments[1].Split( ',' );
GdiPlusGeoCanvas Canvas = new GdiPlusGeoCanvas( );
PdfDocument document = new PdfDocument( );
PdfPage page = document.AddPage( );
page.Orientation = PageOrientation.Landscape;
GeoSolidBrush br = (GeoSolidBrush) Map.MapBackground.BackgroundBrush;
Bitmap MapBit = new Bitmap( 3200, 2400 );
MapBit.SetResolution( 300, 300 );
XGraphics gfx = XGraphics.FromPdfPage( page );
Graphics gf = Graphics.FromImage( MapBit );
gf.Clear( Color.FromArgb( (int) br.Color.AlphaComponent, (int) br.Color.RedComponent, (int) br.Color.GreenComponent, (int) br.Color.BlueComponent ) );
try
{
Map.CurrentExtent = new RectangleShape( double.Parse( bounds[0] ), double.Parse( bounds[1] ), double.Parse( bounds[2] ), double.Parse( bounds[3] ) );
Canvas.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
Canvas.Dpi = 300f;
Collection<SimpleCandidate> labelsInLayers = new Collection<SimpleCandidate>( );
for ( int i = 0; i < overlays.GetLength( 0 ); ++i )
{
if ( overlays[i] == "Legend" ) continue;
foreach ( Layer layer in ( (LayerOverlay) Map.CustomOverlays[overlays[i]] ).Layers )
{
//ExtentHelper.get
Canvas.BeginDrawing( MapBit, ExtentHelper.GetDrawingExtent( Map.CurrentExtent, (float) ( page.Width.Point ), (float) ( page.Height.Point ) ), GeographyUnit.Meter );
//Canvas.BeginDrawing( MapBit, Map.CurrentExtent, GeographyUnit.Meter );
layer.Open( );
layer.Draw( Canvas, labelsInLayers );
layer.Close( );
Canvas.EndDrawing( );
}
}
XImage img = XImage.FromGdiPlusImage( (System.Drawing.Image) MapBit );
string unique = System.Guid.NewGuid( ).ToString( ) + ".pdf";
string filename = Server.MapPath( "~/pdfexport/" + unique );
gfx.DrawImage( img, 10, 10 );
document.Save( filename );
document.Close( );
callbackResult = "pdfexport/" + unique;
}
catch ( Exception e )
{
callbackResult = "ERROR: " + e.Source + " " + e.Message;
}
}