[mapguide-users] Re: scale bar image for pdf

Tony techswami at hotmail.com
Thu May 5 18:13:11 EDT 2011


HI there 
i can get the scale bar using prit layout but i dont know how to convert the
dwf file to image so i cna use that in itextsharp

        MemoryStream m = new MemoryStream();
        //Document document = new Document();

        float top = 1.45f;
        float bot = 1f;
        float left = 0.9f;
        float right = 0.75f;
        String Psize = RadComboBox1.SelectedValue.ToString();
        String Pf = RadComboBox2.SelectedValue.ToString();

        UtilityClass utility = new UtilityClass();
        string l_sSession = Session["mgSessionID"].ToString();
        Document document = new Document(iTextSharp.text.PageSize.LETTER,
left, right, top, bot);
             
      
        MgUserInformation userInfo = new MgUserInformation(l_sSession);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgResourceService resourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
        MgMap map = new MgMap();
        map.Open(resourceService, "ora");

        MgDwfVersion dwfVersion = new MgDwfVersion("6.01", "1.2");
        String sSize = null;
        String sPaper = null;
        String sLand = null;
        String sName = "DD";
        MgPlotSpecification plotSpec = new MgPlotSpecification(18f, 12f,
MgPageUnitsType.Inches, 0f, 0f, 0f, 0f);
        plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f);
        MgMappingService mappingService =
siteConnection.CreateService(MgServiceType.MappingService) as
MgMappingService;

        MgLayout layout = null;
        MgResourceIdentifier layoutRes = new
MgResourceIdentifier("Library://WalnutCreek/Print/Planning.PrintLayout");
        layout = new MgLayout(layoutRes, sName, MgPageUnitsType.Inches);

        MgColor color = new MgColor(255, 255, 255);
        double mapCenterX = map.GetViewCenter().Coordinate.X;
        double mapCenterY = map.GetViewCenter().Coordinate.Y;
        double mapScale = map.GetViewScale();



        MgByteReader byteReader = null;
        MgCoordinate mapCenter = map.GetViewCenter().GetCoordinate();


        byteReader = mappingService.GeneratePlot(map, mapCenter, mapScale,
plotSpec, layout, dwfVersion);
        
        byte[] forImg = null;
        MemoryStream memBuf = new MemoryStream();
        byte[] byteBuffer = new byte[1024];
        int numBytes = byteReader.Read(byteBuffer, 1024);
        while (numBytes > 0)
        {
            memBuf.Write(byteBuffer, 0, numBytes);//
            numBytes = byteReader.Read(byteBuffer, 1024);
        }

        forImg = memBuf.ToArray();
        iTextSharp.text.Image jpg1 =
iTextSharp.text.Image.GetInstance(forImg);        document.Add(jpg1);
        map.Dispose();


is there any idea to convert the byte array from dwf to jpg  or difrectly to
pdf , i have gooled it for a day there is no programming solution ,any  idea
would work 

Tony 

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/scale-bar-image-for-pdf-tp6332139p6335851.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list