Domanda

Come posso creare un generatore di firme del forum dinamico usando ASP.NET MVC. Al momento ho un fetcher di statistiche che recupera le informazioni dell'utente da utilizzare nella firma del forum.

Sto cercando di creare un generatore di firma del forum in cui un utente può inserire il proprio nome utente e generare un'immagine che può inserire nella firma del forum che mostrerà a tutti le statistiche degli utenti.

qualcosa del genere http://www.xfire.com/miniprofile

Devo aver perso le tracce di quello che stavo facendo, non intendevo fornire così poche informazioni, ma penso che avrai un'idea di cosa sto provando a fare ora ..

È stato utile?

Soluzione

Vorrei utilizzare il componente abcPdf, l'immagine sarebbe un documento pdf ad alta risoluzione.

dovresti solo passare testo, font, colore, x, y, w, h

quindi esegui il rendering del PDF come flusso jpg

un'idea di base per farti andare potrebbe essere così;

        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;
     }

questo è il codice per aggiungere testo e anche per renderizzare il PDF come JPG stream componente molto molto buono.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top