Select to view content in your preferred language

Newbie needs help with pdf export

860
2
07-15-2010 06:56 AM
hanswurst
New Contributor
Hi,

i am trainee who has the challange to work with ESRI (not easy :mad:)

At first I have an GUI with an axMapControl.
Now I want to save the active view of the map to an pdf file.

But my export doesnt work with SipleMarker (these objects are not shown on the exportet picture/file)

What can i do to export the SimpleMarker-Objects too??



My Simple marker with are drawing on the map (I also have some single Points)
        private void drawGraphicLineOnMap(List<IPoint> points, IColor color, esriSimpleLineStyle style)
        {
            Polyline lines = new PolylineClass();
            System.Object missing = Type.Missing;

            foreach (IPoint point in points)
            {
                lines.AddPoint(point, ref missing, ref missing);
            }

            ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
            lineSymbol.Style = style;
            lineSymbol.Color = color;
            lineSymbol.Width = 1;

            System.Object objectMarker = (object)lineSymbol;

            this.m_mapControl.DrawShape((IGeometry)lines, ref objectMarker);
        }


here is my pdf export.
    private void saveAsPDF() 
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Textdatei (*.pdf)|*.pdf";
            saveFileDialog.Title = "Export active view to PDF";
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.FileName = System.IO.Path.Combine(saveFileDialog.InitialDirectory, "filename" + DateTime.Now.ToString("(dd-MM-yyyy_HH-mm-ss)"));

            if (saveFileDialog.ShowDialog().Equals(DialogResult.OK))
            {
                //GeoPDF Konvertierung
                IEnvelope pEnvelope;
                pEnvelope = (IEnvelope)axMapControl1.ActiveView.Extent.Envelope;
                IExport pExport;
                pExport = new ExportPDFClass();
                
                // Windows Auflösung ist 96, wir wollen aber in 300 exportieren 
                // Deswegen wird die Grö??e hier neu berechnet 
                System.Int32 screenResolution = 96;
                System.Int32 outputResolution = 300;
                pExport.Resolution = outputResolution;
                ESRI.ArcGIS.Display.tagRECT rectangle;
                rectangle.left = 0;
                rectangle.top = 0;
                rectangle.right = axMapControl1.ActiveView.ExportFrame.right * (outputResolution / screenResolution);
                rectangle.bottom = axMapControl1.ActiveView.ExportFrame.bottom * (outputResolution / screenResolution);
                EnvelopeClass pDriverBounds = new EnvelopeClass();
                pDriverBounds.PutCoords((double)rectangle.left, (double)rectangle.bottom, (double)rectangle.right, (double)rectangle.top);
                pExport.PixelBounds = pDriverBounds;
                pExport.ExportFileName = @saveFileDialog.FileName;

                //Exportieren
                int hDC = pExport.StartExporting();
                
                axMapControl1.ActiveView.Output(hDC, (int)outputResolution, ref rectangle, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();
            }



I hope somebody can help me.
0 Kudos
2 Replies
PhilBlondin
Deactivated User
Here is a little snippet from some vb6 code I have.  You to access the map fonts.

pRECT.Left = 0
pRECT.Top = 0
pRECT.Right = width * pExporter.Resolution
pRECT.bottom = height * pExporter.Resolution

pPixelBounds.PutCoords pRECT.Left, pRECT.Top, pRECT.Right, pRECT.bottom
pExporter.PixelBounds = pPixelBounds

Dim pFME As IFontMapEnvironment
Set pFME = pExporter 'QI

Dim pFMC As IFontMapCollection
Set pFMC = pFME.FontMapCollection

Dim pFont As IFontMap2
Set pFont = New FontMap

'Arial is the TrueType font whereas Courier is the mapped font
pFont.SetMapping "Arial", "Arial"
pFMC.Add pFont
   
Set pFont = New FontMap
pFont.SetMapping "Arial Bold", "Helvetica-Bold"
pFMC.Add pFont
   
hDc = pExporter.StartExporting

pMxdoc.ActiveView.Output hDc, pExporter.Resolution, pRECT, pVisibleBounds, Nothing

pExporter.FinishExporting
0 Kudos
hanswurst
New Contributor
Thank you for your fast answer...

but are you sure that it will works with Font-Collection ?
I want to export the SimpleMarker and SimpleLine objects.

I tried to convert the Code you gave me into c# but i was not successful. (sorry i am a noob :o)

In your code snippet you used always "Set" .... what does this mean? (i never worked with vb)

This is the code i produced...
Maybe everything is wrong... i dont know.
                IFontMapEnvironment pFME;
                pFME = (IFontMapEnvironment)pExport;

                IFontMapCollection pFMC;
                pFMC = pFME.FontMapCollection;

                IFontMap2 pFont;
                pFont = new FontMap();

                pFont.SetMapping("Arial", "Arial");
                pFMC.Add(pFont);

                pFont = new FontMap();
                pFont.SetMapping("Arial Bold", "Helvetica-Bold");
                pFMC.Add(pFont);


I hope you or somebody else can help me
0 Kudos