هل هناك أي طرق مجانية لتحويل صفحة html في صورة مع .صافي

StackOverflow https://stackoverflow.com/questions/147100

سؤال

أريد أن تأخذ html ، بما في ذلك النص والصور وتحويلها إلى صورة واحدة تحتوي على كل شيء.هل هناك طريقة مجانية للقيام بذلك ؟

هذا هو استخدام .net framework 3.5.

انظر أيضا:

ملقم ويب التي تم إنشاؤها لقطات ؟
ما هي أفضل طريقة لإنشاء صفحة ويب مصغرة?

هل كانت مفيدة؟

المحلول

قد تحقق من هذا المشروع أو هذه الصفحة.

على أمل أن يساعد.

نصائح أخرى

هنا بعض التعليمات البرمجية التي قمت بنشرها في مدونتي قبل بضعة أسابيع أن يفعل هذا:

C#:إنشاء صفحة ويب مصغرة الصورة صورة

سوف أيضا إضافة رمز أدناه:

public Bitmap GenerateScreenshot(string url)
{
    // This method gets a screenshot of the webpage
    // rendered at its full size (height and width)
    return GenerateScreenshot(url, -1, -1);
}

public Bitmap GenerateScreenshot(string url, int width, int height)
{
    // Load the webpage into a WebBrowser control
    WebBrowser wb = new WebBrowser();
    wb.ScrollBarsEnabled = false;
    wb.ScriptErrorsSuppressed = true;
    wb.Navigate(url);
    while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }


    // Set the size of the WebBrowser control
    wb.Width = width;
    wb.Height = height;

    if (width == -1)
    {
        // Take Screenshot of the web pages full width
        wb.Width = wb.Document.Body.ScrollRectangle.Width;
    }

    if (height == -1)
    {
        // Take Screenshot of the web pages full height
        wb.Height = wb.Document.Body.ScrollRectangle.Height;
    }

    // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
    Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
    wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
    wb.Dispose();

    return bitmap;
}

وهنا بعض الأمثلة على الاستخدامات:

// Generate thumbnail of a webpage at 1024x768 resolution
Bitmap thumbnail = GenerateScreenshot("http://pietschsoft.com", 1024, 768);

// Generate thumbnail of a webpage at the webpage's full size (height and width)
thumbnail = GenerateScreenshot("http://pietschsoft.com");

// Display Thumbnail in PictureBox control
pictureBox1.Image = thumbnail;

/*
// Save Thumbnail to a File
thumbnail.Save("thumbnail.png", System.Drawing.Imaging.ImageFormat.Png);
*/
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top