Hi,
When I try to save map into PDF files Im getting a empty pdf files.
The below is the code that im using in my web page. Am i missing something ?
Thanks
Ugendran.
protected void btnToPdf_Click(object sender, EventArgs e)
{
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
//if (rdlOptions.SelectedItem.Text == "Landscape")
//{
page.Orientation = PageOrientation.Landscape;
//}
PdfGeoCanvas pdfGeoCanvas = new PdfGeoCanvas();
// This allows you to control the area in which you want the
// map to draw in. Leaving this commented out uses the whole page
//pdfGeoCanvas.DrawingArea = new Rectangle(200, 50, 400, 400);
Collection<SimpleCandidate> labelsInLayers = new Collection<SimpleCandidate>();
foreach (Layer layer in MapMaster.StaticOverlay.Layers)
{
RectangleShape printExtent = ExtentHelper.GetDrawingExtent(MapMaster.CurrentExtent, (float)MapMaster.WidthInPixels, (float)MapMaster.HeightInPixels);
pdfGeoCanvas.BeginDrawing(page, printExtent, GeographyUnit.DecimalDegree);
layer.Open();
layer.Draw(pdfGeoCanvas, labelsInLayers);
layer.Close();
pdfGeoCanvas.EndDrawing();
}
string filename = Server.MapPath(".") + "\\MapSuitePDFMap.pdf";
document.Save(filename);
OpenPdfFile(filename);
}
private void OpenPdfFile(string filename)
{
string javascriptFormat = "<script language=\"javascript\" type=\"text/javascript\">{0}</script>";
try
{
ClientScript.RegisterStartupScript(this.GetType(), "showPdfFile", string.Format(javascriptFormat, "function A() {window.open('MapSuitePDFMap.pdf');};A();"));
}
catch (Win32Exception ex)
{
if (ex.Message == "No application is associated with the specified file for this operation")
{
ClientScript.RegisterStartupScript(this.GetType(), "showPdfFile", string.Format(javascriptFormat, "function A() {alert('Failed to generate PDF file.');};A();"));
}
}
}