views:

272

answers:

1

How could I create a dynamic forum signature generator using ASP.NET MVC. I currently have a Stats fetcher that retrieves the user info to be used in the Forum Signature.

I'm trying to create a forum signature generator where a user can enter their user name and generate an image that they can put in their forum signature that will show everyone the users stats.

something like this http://www.xfire.com/miniprofile

I must have lost track of what I was doing I didn't mean supply such little info, But I think you will have an idea of what im trying to do now..

+1  A: 

i would use abcPdf component, the image would be a hi-res pdf document.

you would then just need to pass text, font, color, x, y, w, h

then your render the PDF out as a jpg stream

a basic idea to get you going could be like this;

        private void addTextToPDF(string cmyk, int fs, string fontname, Double posx,
    Double posY, Double mWidth, Double mHeight, String text, Double hpos)
    {
        text = secure.reverseCleanup(text);
        int lettercount1 = 0;
        foreach (char c in text)
        { lettercount1 ++; }

        TheDoc.Color.String = cmyk;
        TheDoc.FontSize = fs;
        var theFont = fontname;
        TheDoc.Rect.Position(posx, posY);
        TheDoc.Rect.Width = mWidth;
        TheDoc.Rect.Height = mHeight;
        TheDoc.HPos = hpos;
        TheDoc.Font = TheDoc.EmbedFont(theFont, "Latin", false, true, true);
        int didwrite = TheDoc.AddText(text);
        string addedchars = TheDoc.GetInfo(didwrite, "Characters");
        var oldid = didwrite;

        if (addedchars != lettercount1.ToString())
            didwrite = 0;

        while (didwrite==0) // hits this if first run did not add text
        {
            TheDoc.Delete(oldid);
            fs = fs - 2;
            TheDoc.Color.String = cmyk;
            TheDoc.FontSize = fs;
            theFont = fontname;
            TheDoc.Rect.Position(posx, posY);
            TheDoc.Rect.Width = mWidth;
            TheDoc.Rect.Height = mHeight;
            TheDoc.HPos = hpos;
            TheDoc.Font = TheDoc.EmbedFont(theFont, "Latin", false, true, true);
            didwrite = TheDoc.AddText(secure.reverseCleanup(text));
            addedchars = TheDoc.GetInfo(didwrite, "Characters");
            oldid = didwrite;

            if (addedchars != lettercount1.ToString())
                didwrite = 0;
        }

    }

    public byte[] convertPDFToImageStream()
    {
        byte[] jpgBytes = null;
        byte[] theData = null;
        theData = TheDoc.GetData();
        TheDoc.Clear();
        TheDoc.Read(theData);
        TheDoc.Rendering.DotsPerInch = getDPI();
        TheDoc.Rendering.ColorSpace = "RGB";
        jpgBytes = TheDoc.Rendering.GetData("preview.jpg");

        return jpgBytes;
     }

that is the code to add text and also to render the PDF out as a stream JPG very very good component.

minus4