Hi Support team,
We have an application that use Zedgraph to show projects matrix by status based on province for example number of ongoing project and number completed project in New York.
since provinces are very close together zedgraphs overlap each other so we extend the map and show a big map with width:2000 and height:2000. I doubt that it is the right solution. Please Guide me if there is better solution.
anyway the main issue is when we want to print the map, zedgraphs still overlap each other.in the other words Map doesn’t print layers as it shows layers in interface, or the background is bigger than custom layer( find the attached pictures).
my code is:
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
string selectedItemText= args[“selectItemText”].ToString();
if (args[“Orientation”].ToString() == “Landscape”)
page.Orientation = PdfSharp.PageOrientation.Landscape;
else
page.Orientation = PageOrientation.Portrait;
if (args[2].ToString() == “A0”)
page.Size = PageSize.A0;
else if (args[2].ToString() == “A1”)
page.Size = PageSize.A1;
PdfGeoCanvas pdfGeoCanvas = new PdfGeoCanvas();
List<LayerOverlay> lstlayeroverlay = new List<LayerOverlay>();
lstlayeroverlay.Add((LayerOverlay)map.CustomOverlays[“GoogleMap”]); //BackGround layer
lstlayeroverlay.Add((LayerOverlay)map.CustomOverlays[“GraduatedOverlay”]); //show Data from database
lstlayeroverlay.Add((LayerOverlay)map.CustomOverlays[“PaiOverlay”]); //show ZedGraph
XGraphics XGraphics = XGraphics.FromPdfPage(page);
////////////////////////////////////////////Show the header of page---------------it is not important for you/////////////////////////////////////////
int headerHeight = 70;
try
{
XGraphics.DrawRectangle(Brushes.CadetBlue, new Rectangle(0, 0, (int)page.Width, (int)headerHeight));
XGraphics.DrawLine(new XPen(XColor.FromKnownColor(KnownColor.Black), 4), 0, (int)headerHeight + 1, (int)page.Width, (int)headerHeight + 1);
XGraphics.DrawImage(XImage.FromFile(Server.MapPath("~/Skin/Img/LeftLogo.png")), new XRect(0, 0, headerHeight, headerHeight));
//= @“Ministry of Rural Rehabilitation and Development\n National Rural Water Supply, Sanitation and Irrigation Program \n”;
XGraphics.DrawString(“Ministry of Rural Rehabilitation and Development”, new XFont(“Narkisim”, 20, XFontStyle.Bold), XBrushes.Black, new XRect(0,5, page.Width, (int)headerHeight / 3), XStringFormats.Center);
XGraphics.DrawString(“National Rural Water Supply, Sanitation and Irrigation Program”, new XFont(“Narkisim”, 16, XFontStyle.Bold), XBrushes.Black, new XRect(0, (int)headerHeight / 3, page.Width, (int)headerHeight / 3), XStringFormats.Center);
if (!string.IsNullOrEmpty(selectedItemText))
{
XGraphics.DrawString(selectedItemText, new XFont(“AR CENA”, 18), XBrushes.Black, new XRect(0, (int)headerHeight / 3*2-5, page.Width, (int)headerHeight / 3), XStringFormats.Center);
}
XGraphics.DrawImage(XImage.FromFile(Server.MapPath("~/Skin/Img/Right Logo.png")), new XRect(page.Width - headerHeight, 0, headerHeight, headerHeight));
}
finally
{
XGraphics.Dispose();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////it is for footer --------it is not important for you/////////////////////////////////////////
if (ProjectSession.Legend.Count > 0)
pdfGeoCanvas.DrawingArea = new Rectangle(0, headerHeight, (int)page.Width, (int)page.Height - (headerHeight + headerHeight));
else
pdfGeoCanvas.DrawingArea = new Rectangle(0, headerHeight, (int)page.Width, (int)page.Height - (headerHeight));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Collection<SimpleCandidate> labelsInLayers = new Collection<SimpleCandidate>();
RectangleShape rect = ExtentHelper.GetDrawingExtent(map.CurrentExtent,(float)map.WidthInPixels,(float)map.HeightInPixels);
foreach (LayerOverlay layeroverlay in lstlayeroverlay)
{
foreach (Layer layer in layeroverlay.Layers)
{
layer.Open();
pdfGeoCanvas.BeginDrawing(page, rect, map.MapUnit);
???
My Question here, why map doesn’t print layers as it showing them in interface
???
layer.Draw(pdfGeoCanvas, labelsInLayers);
layer.Close();
pdfGeoCanvas.EndDrawing();
}
}
i think we print all element based on the custom layer! how do i change the size of Custom layer based on the map size.
Print map to pdf and zedgraphs overlap each other
Hi hassan,
Have you compared whether the value of "rect" is different when you draw it and print it?
It looks you failed to upload your screen shot, please upload it again, that can help us understand your issue better.
Regards,
Don