0

ASP.NET MVC を使用して動的フォーラム署名ジェネレーターを作成するにはどうすればよいですか? 私は現在、フォーラム署名で使用されるユーザー情報を取得する統計フェッチャーを持っています。

ユーザーが自分のユーザー名を入力して、ユーザーの統計をすべての人に表示するフォーラム署名に入れることができる画像を生成できるフォーラム署名ジェネレーターを作成しようとしています。

このようなものhttp://www.xfire.com/miniprofile

私は自分が何をしていたかを見失っていたに違いありません.そんなに小さな情報を提供するつもりはありません.

4

1 に答える 1

1

私は abcPdf コンポーネントを使用します。画像は高解像度の PDF ドキュメントになります。

次に、テキスト、フォント、色、x、y、w、h を渡すだけです。

次に、PDFをjpgストリームとしてレンダリングします

あなたを動かすための基本的なアイデアは次のようになります。

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

これは、テキストを追加し、PDF をストリーム JPG としてレンダリングするコードであり、非常に優れたコンポーネントです。

于 2009-09-11T14:40:28.423 に答える