internal void GerarPdf(Document doc, PdfWriter wrt, Int32 projetoId, Hashtable hashData, bool isUsePageEvent) { tempFile1 = TempPath + Path.GetRandomFileName() + ".pdf"; tempFile2 = TempPath + Path.GetRandomFileName() + ".pdf"; tempFile3 = TempPath + Path.GetRandomFileName() + ".pdf"; _da = new MxdLayoutDa(); _mxd.ZoomPercentage(1); if (_tipo == ArquivoMxd.MAPA_DOMINIALIDADE) { //Aplicando filtros _mxd.ActivateMap("MAPA_PRINCIPAL"); foreach (var layer in ObterLayers()) { _mxd.SetQueryDefinition(layer.Name, String.Format(layer.Query, projetoId)); layer.Source = _mxd.GetDataSource(layer.Name); if (String.IsNullOrEmpty(layer.Query)) { _mxd.SetLayerVisibility(layer.Name, true); } else { _mxd.SetLayerVisibility(layer.Name, _da.ObterQuantidade(layer, projetoId) > 0); } } _mxd.ActivateMap("MINI_MAPA"); _mxd.SetQueryDefinition("Ponto empreendimento", "EMPREENDIMENTO=" + hashData["EMPREENDIMENTO"]); _mxd.ActivateMap("MAPA_PRINCIPAL"); //Setar as informações no mxd _mxd.SetElementText("municipio", hashData["MUNICIPIO"].ToString()); _mxd.SetElementText("uf", hashData["UF"].ToString()); _mxd.SetElementText("data", DateTime.Today.ToString("dd/MM/yyyy")); _mxd.SetElementText("precisao", hashData["PRECISAO"].ToString()); //Definir Zoom _mxd.ZoomToFeature("Área total da propriedade", "PROJETO", projetoId.ToString()); _mxd.ZoomPercentage(1.1); _mxd.ZoomToBestScale("MAPA_PRINCIPAL", 250D); _mxd.AdjustGrid("MAPA_PRINCIPAL", 3, 3); _mxd.ActivateMap("MINI_MAPA"); string[] coord = hashData["COORDENADA"].ToString().Split(';'); int centerX = Convert.ToInt32(coord[0]); int centerY = Convert.ToInt32(coord[1]); _mxd.ZoomToEnvelope(new Envelope(centerX - 2000, centerX + 2000, centerY - 2000, centerY + 2000)); _mxd.ZoomToBestScale("MINI_MAPA", 800000D); _mxd.ActivateMap("MAPA_PRINCIPAL"); //---------------------------------------- //Mapa Tematico _mxd.SetLayerVisibility("IMAGEM", false); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui da Dominialidade"); _mxd.SetElementText("imagem", String.Empty); _mxd.ExportToPDF(tempFile1, 300); loadPdfToDocument(doc, wrt, tempFile1, isUsePageEvent); doc.NewPage(); //---------------------------------------- //---------------------------------------- //Mapa Imagem _mxd.SetLayerVisibility("IMAGEM", true); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui com Imagem"); _mxd.SetElementText("imagem", "Aerolevantamento: ano 2007/2008"); _mxd.ExportToPDF(tempFile2, 300); loadPdfToDocument(doc, wrt, tempFile2, isUsePageEvent); doc.NewPage(); //---------------------------------------- } else if (_tipo == ArquivoMxd.MAPA_ATIVIDADE) { int dominialidade = Convert.ToInt32(hashData["DOMINIALIDADE"]); //Aplicando filtros _mxd.ActivateMap("MAPA_PRINCIPAL"); foreach (var layer in ObterLayers()) { _mxd.SetLayerVisibility(layer.Name, true); if (layer.Grupo == 1) //Dominialidade { _mxd.SetQueryDefinition(layer.Name, String.Format(layer.Query, dominialidade)); } else { _mxd.SetQueryDefinition(layer.Name, String.Format(layer.Query, projetoId)); } } _mxd.ActivateMap("MINI_MAPA"); _mxd.SetQueryDefinition("Ponto empreendimento", "EMPREENDIMENTO=" + hashData["EMPREENDIMENTO"]); //Setar as informações no mxd _mxd.SetElementText("atividade", hashData["ATIVIDADE"].ToString()); _mxd.SetElementText("municipio", hashData["MUNICIPIO"].ToString()); _mxd.SetElementText("uf", hashData["UF"].ToString()); _mxd.SetElementText("data", DateTime.Today.ToString("dd/MM/yyyy")); _mxd.SetElementText("precisao", hashData["PRECISAO"].ToString()); //Definir Zoom _mxd.ZoomToFeature("Área total da propriedade", "PROJETO", dominialidade.ToString()); _mxd.ZoomPercentage(1.5); _mxd.ZoomToBestScale("MAPA_PRINCIPAL", 250D); _mxd.AdjustGrid("MAPA_PRINCIPAL", 3, 3); _mxd.ActivateMap("MINI_MAPA"); string[] coord = hashData["COORDENADA"].ToString().Split(';'); int centerX = Convert.ToInt32(coord[0]); int centerY = Convert.ToInt32(coord[1]); _mxd.ZoomToEnvelope(new Envelope(centerX - 2000, centerX + 2000, centerY - 2000, centerY + 2000)); _mxd.ZoomToBestScale("MINI_MAPA", 800000D); _mxd.ActivateMap("MAPA_PRINCIPAL"); //---------------------------------------- //Mapa Tematico _mxd.SetLayerVisibility("IMAGEM", false); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui da Atividade"); _mxd.SetElementText("imagem", String.Empty); _mxd.ExportToPDF(tempFile1, 300); loadPdfToDocument(doc, wrt, tempFile1, isUsePageEvent); doc.NewPage(); //---------------------------------------- //---------------------------------------- //Mapa Imagem _mxd.SetLayerVisibility("IMAGEM", true); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui com Imagem"); _mxd.SetElementText("imagem", "Aerolevantamento: ano 2007/2008"); _mxd.ExportToPDF(tempFile2, 300); loadPdfToDocument(doc, wrt, tempFile2, isUsePageEvent); doc.NewPage(); //---------------------------------------- } else if (_tipo == ArquivoMxd.MAPA_PECA_TECNICA) { //Aplicando filtros _mxd.ActivateMap("MAPA_PRINCIPAL"); foreach (var layer in ObterLayers()) { _mxd.SetQueryDefinition(layer.Name, String.Format(layer.Query, projetoId)); _mxd.SetLayerVisibility(layer.Name, true); } //Setar as informações no mxd _mxd.SetElementText("processo", " "); _mxd.SetElementText("precisao", hashData["PRECISAO"].ToString()); _mxd.SetElementText("data_emissao", DateTime.Today.ToString("dd/MM/yyyy")); List <Hashtable> lstQuadroTotal = hashData["QUADRO_TOTAL"] as List <Hashtable>; var hashATP = lstQuadroTotal.SingleOrDefault(x => x["CLASSE"].ToString() == "ATP"); _mxd.SetElementText("nome_interessado", " "); _mxd.SetElementText("municipio_uf", " "); _mxd.SetElementText("bairro_gleba_comunidade", " "); _mxd.SetElementText("distrito_localidade", " "); _mxd.SetElementText("area_m2", FormatNumber(hashATP["AREA_M2"])); _mxd.SetElementText("perimetro_m", FormatNumber(hashData["ATP_PERIMETRO"], 3)); _mxd.SetElementText("nome_responsavel_tecnico", " "); _mxd.SetElementText("profissao_responsavel_tecnico", " "); _mxd.SetElementText("orgao_classe_art_responsavel_tecnico", " "); //Definir Zoom _mxd.ZoomToFeature("Área total da propriedade", "PROJETO", projetoId.ToString()); _mxd.ZoomPercentage(1.1); _mxd.ZoomToBestScale("MAPA_PRINCIPAL", 250D); _mxd.AdjustGrid("MAPA_PRINCIPAL", 3, 3); //---------------------------------------- //Mapa Tematico _mxd.SetLayerVisibility("IMAGEM", false); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("titulo_croqui", "Croqui da Peça Técnica"); _mxd.SetElementText("imagem", String.Empty); _mxd.ExportToPDF(tempFile1, 300); loadPdfToDocument(doc, wrt, tempFile1, isUsePageEvent); doc.NewPage(); //---------------------------------------- //---------------------------------------- //Mapa Imagem _mxd.SetLayerVisibility("IMAGEM", true); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("titulo_croqui", "Croqui da Peça Técnica com Imagem"); _mxd.SetElementText("imagem", "Aerolevantamento: ano 2007/2008"); _mxd.ExportToPDF(tempFile2, 300); loadPdfToDocument(doc, wrt, tempFile2, isUsePageEvent); doc.NewPage(); //---------------------------------------- } else if (_tipo == ArquivoMxd.MAPA_FISCALIZACAO) { //Aplicando filtros _mxd.ActivateMap("MAPA_PRINCIPAL"); _mxd.SetQueryDefinition("Ponto fiscalizado", "PROJETO=" + projetoId); _mxd.SetQueryDefinition("Linha fiscalizada", "PROJETO=" + projetoId); _mxd.SetQueryDefinition("Área fiscalizada", "PROJETO=" + projetoId); _mxd.SetLayerVisibility("Ponto fiscalizado", true); _mxd.SetLayerVisibility("Linha fiscalizada", true); _mxd.SetLayerVisibility("Área fiscalizada", true); _mxd.ActivateMap("MINI_MAPA"); _mxd.SetQueryDefinition("Ponto de fiscalização", "FISCALIZACAO=" + hashData["FISCALIZACAO"]); //Setar as informações no mxd _mxd.SetElementText("municipio", hashData["MUNICIPIO"].ToString()); _mxd.SetElementText("uf", hashData["UF"].ToString()); _mxd.SetElementText("data", DateTime.Today.ToString("dd/MM/yyyy")); _mxd.SetElementText("precisao", hashData["PRECISAO"].ToString()); _mxd.SetElementText("total_ponto", FormatNumber(hashData["TOTAL_PONTOS"], 0)); _mxd.SetElementText("total_linha", FormatNumber(hashData["TOTAL_LINHAS"], 0) + " ( " + FormatNumber(hashData["SOMA_LINHAS"], 3) + " m)"); _mxd.SetElementText("total_areas", FormatNumber(hashData["TOTAL_AREAS"], 0) + " ( " + FormatNumber(hashData["SOMA_AREAS"], 2) + " m²)"); string[] envelope = hashData["ENVELOPE"].ToString().Split(';'); //Definir Zoom Envelope envelopeRect = new Envelope(Convert.ToInt32(envelope[0]), Convert.ToInt32(envelope[2]), Convert.ToInt32(envelope[1]), Convert.ToInt32(envelope[3])); if (envelope[0] == envelope[2] && envelope[1] == envelope[3]) { Envelope envelopeZoom = new Envelope(envelopeRect.Xmin - 100, envelopeRect.Xmax + 100, envelopeRect.Ymin - 100, envelopeRect.Ymax + 100); _mxd.ZoomToEnvelope(envelopeZoom); _mxd.ZoomToScale("MAPA_PRINCIPAL", 5000D); } else { _mxd.ZoomToEnvelope(envelopeRect); _mxd.ZoomPercentage(1.5); _mxd.ZoomToBestScale("MAPA_PRINCIPAL", 250D); } _mxd.AdjustGrid("MAPA_PRINCIPAL", 3, 3); _mxd.ActivateMap("MINI_MAPA"); int centerX = Convert.ToInt32((envelopeRect.Xmax + envelopeRect.Xmin) / 2); int centerY = Convert.ToInt32((envelopeRect.Ymax + envelopeRect.Ymin) / 2); _mxd.ZoomToEnvelope(new Envelope(centerX - 2000, centerX + 2000, centerY - 2000, centerY + 2000)); _mxd.ZoomToBestScale("MINI_MAPA", 800000D); _mxd.ActivateMap("MAPA_PRINCIPAL"); //---------------------------------------- //Mapa Tematico _mxd.SetLayerVisibility("IMAGEM", false); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "CROQUI TEMÁTICO DE FISCALIZAÇÃO"); _mxd.SetElementText("imagem", String.Empty); _mxd.ExportToPDF(tempFile1, 300); loadPdfToDocument(doc, wrt, tempFile1, isUsePageEvent); doc.NewPage(); //---------------------------------------- if (_mxd.GetMapScale("MAPA_PRINCIPAL") <= 1750D) { _mxd.ZoomToScale("MAPA_PRINCIPAL", 1750); } //---------------------------------------- //Mapa Imagem _mxd.SetLayerVisibility("IMAGEM", true); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "CROQUI IMAGEM DE FISCALIZAÇÃO"); _mxd.SetElementText("imagem", "Aerolevantamento: ano 2007/2008"); _mxd.ExportToPDF(tempFile2, 300); loadPdfToDocument(doc, wrt, tempFile2, isUsePageEvent); doc.NewPage(); //---------------------------------------- } else if (_tipo == ArquivoMxd.MAPA_CAR) { int projetoDomId = Convert.ToInt32(((Hashtable)hashData["CAR"])["PRJ_DOM_ID"]); //Aplicando filtros _mxd.ActivateMap("MAPA_PRINCIPAL"); foreach (var layer in ObterLayers()) { _mxd.SetQueryDefinition(layer.Name, String.Format(layer.Query, projetoDomId)); layer.Source = _mxd.GetDataSource(layer.Name); if (String.IsNullOrEmpty(layer.Query)) { _mxd.SetLayerVisibility(layer.Name, true); } else { _mxd.SetLayerVisibility(layer.Name, _da.ObterQuantidade(layer, projetoDomId) > 0); } } var layerAppRec = ObterLayers().Find(x => x.Name == "APP a recuperar (Calculado)"); layerAppRec.Source = _mxd.GetDataSource(layerAppRec.Name); _mxd.SetQueryDefinition(layerAppRec.Name, String.Format(layerAppRec.Query, projetoId)); _mxd.SetLayerVisibility(layerAppRec.Name, _da.ObterQuantidade(layerAppRec, projetoId) > 0); _mxd.ActivateMap("MINI_MAPA"); _mxd.SetQueryDefinition("Ponto empreendimento", "EMPREENDIMENTO=" + hashData["EMPREENDIMENTO"]); _mxd.ActivateMap("MAPA_PRINCIPAL"); //Setar as informações no mxd _mxd.SetElementText("municipio", hashData["MUNICIPIO"].ToString()); _mxd.SetElementText("uf", hashData["UF"].ToString()); _mxd.SetElementText("data", DateTime.Today.ToString("dd/MM/yyyy")); _mxd.SetElementText("precisao", hashData["PRECISAO"].ToString()); //Definir Zoom _mxd.ZoomToFeature("Área total da propriedade", "PROJETO", projetoDomId.ToString()); _mxd.ZoomPercentage(1.1); _mxd.ZoomToBestScale("MAPA_PRINCIPAL", 250D); _mxd.AdjustGrid("MAPA_PRINCIPAL", 3, 3); _mxd.ActivateMap("MINI_MAPA"); string[] coord = hashData["COORDENADA"].ToString().Split(';'); int centerX = Convert.ToInt32(coord[0]); int centerY = Convert.ToInt32(coord[1]); _mxd.ZoomToEnvelope(new Envelope(centerX - 2000, centerX + 2000, centerY - 2000, centerY + 2000)); _mxd.ZoomToBestScale("MINI_MAPA", 800000D); _mxd.ActivateMap("MAPA_PRINCIPAL"); //---------------------------------------- //Mapa Tematico _mxd.SetLayerVisibility("IMAGEM", false); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui do CAR"); _mxd.SetElementText("imagem", String.Empty); _mxd.ExportToPDF(tempFile1, 300); loadPdfToDocument(doc, wrt, tempFile1, isUsePageEvent); doc.NewPage(); //---------------------------------------- //---------------------------------------- //Mapa Imagem _mxd.SetLayerVisibility("IMAGEM", true); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui com Imagem"); _mxd.SetElementText("imagem", "Aerolevantamento: ano 2007/2008"); _mxd.ExportToPDF(tempFile2, 300); loadPdfToDocument(doc, wrt, tempFile2, isUsePageEvent); doc.NewPage(); //---------------------------------------- } }
internal void GerarPdf(Document doc, PdfWriter wrt, Int32 projetoId, Hashtable hashData, bool isUsePageEvent) { tempFile1 = TempPath + Path.GetRandomFileName() + ".pdf"; tempFile2 = TempPath + Path.GetRandomFileName() + ".pdf"; tempFile3 = TempPath + Path.GetRandomFileName() + ".pdf"; _da = new MxdLayoutDa(); _mxd.ZoomPercentage(1); if (_tipo == ArquivoMxd.MAPA_DOMINIALIDADE) { //Aplicando filtros _mxd.ActivateMap("MAPA_PRINCIPAL"); foreach (var layer in ObterLayers()) { _mxd.SetQueryDefinition(layer.Name, String.Format(layer.Query, projetoId)); layer.Source = _mxd.GetDataSource(layer.Name); if (String.IsNullOrEmpty(layer.Query)) { _mxd.SetLayerVisibility(layer.Name, true); } else { _mxd.SetLayerVisibility(layer.Name, _da.ObterQuantidade(layer, projetoId) > 0); } } _mxd.ActivateMap("MINI_MAPA"); _mxd.SetQueryDefinition("Ponto empreendimento", "PROJETO=" + projetoId.ToString()); string[] coord = hashData["COORDENADA"].ToString().Split(';'); int centerX = Convert.ToInt32(coord[0]); int centerY = Convert.ToInt32(coord[1]); _mxd.ZoomToEnvelope(new Envelope(centerX - 2000, centerX + 2000, centerY - 2000, centerY + 2000)); _mxd.ZoomToBestScale("MINI_MAPA", 800000D); _mxd.ActivateMap("MAPA_PRINCIPAL"); //Setar as informações no mxd _mxd.SetElementText("municipio", hashData["MUNICIPIO"].ToString()); _mxd.SetElementText("uf", hashData["UF"].ToString()); _mxd.SetElementText("data", DateTime.Today.ToString("dd/MM/yyyy")); _mxd.SetElementText("precisao", hashData["PRECISAO"].ToString()); //Definir Zoom _mxd.ZoomToFeature("Área total da propriedade", "PROJETO", projetoId.ToString()); _mxd.ZoomPercentage(1.1); _mxd.ZoomToBestScale("MAPA_PRINCIPAL", 250D); _mxd.AdjustGrid("MAPA_PRINCIPAL", 3, 3); _mxd.ActivateMap("MINI_MAPA"); coord = hashData["COORDENADA"].ToString().Split(';'); centerX = Convert.ToInt32(coord[0]); centerY = Convert.ToInt32(coord[1]); _mxd.ZoomToEnvelope(new Envelope(centerX - 2000, centerX + 2000, centerY - 2000, centerY + 2000)); _mxd.ZoomToBestScale("MINI_MAPA", 800000D); _mxd.ActivateMap("MAPA_PRINCIPAL"); //---------------------------------------- //Mapa Tematico _mxd.SetLayerVisibility("IMAGEM", false); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui da Dominialidade"); _mxd.SetElementText("imagem", String.Empty); _mxd.ExportToPDF(tempFile1, 300); loadPdfToDocument(doc, wrt, tempFile1, isUsePageEvent); doc.NewPage(); //---------------------------------------- //---------------------------------------- //Mapa Imagem _mxd.SetLayerVisibility("IMAGEM", true); _mxd.RefreshLegends(scaleSymbols: true); _mxd.SetElementText("nome_croqui", "Croqui com Imagem"); _mxd.SetElementText("imagem", "Aerolevantamento: ano 2007/2008"); _mxd.ExportToPDF(tempFile2, 300); loadPdfToDocument(doc, wrt, tempFile2, isUsePageEvent); doc.NewPage(); //---------------------------------------- } }