Example #1
0
    static void Main(string[] args)
    {
        string customerKey  = "PUT_YOUR_CUSTOMER_KEY_HERE";
        string secretPhrase = ""; //leave secret phrase empty, if not needed

        var options = new Dictionary <string, string>();

        // mandatory parameter
        options.Add("url", "https://www.google.com");
        // all next parameters are optional, see our website to PDF API guide for more details
        options.Add("paper", "letter");
        options.Add("orientation", "portrait");
        options.Add("media", "print");
        options.Add("bg", "nobg");
        options.Add("delay", "2000");
        options.Add("scale", "50");

        ScreenshotMachine sm = new ScreenshotMachine(customerKey, secretPhrase);

        string pdfApiUrl = sm.GeneratePdfApiUrl(options);

        //save PDF file
        string output = "output.pdf";

        new WebClient().DownloadFile(pdfApiUrl, output);
        Console.Write("Pdf saved as " + output);
    }
    static void Main(string[] args)
    {
        string customerKey  = "PUT_YOUR_CUSTOMER_KEY_HERE";
        string secretPhrase = ""; //leave secret phrase empty, if not needed

        var options = new Dictionary <string, string>();

        // mandatory parameter
        options.Add("url", "https://www.google.com");
        // all next parameters are optional, see our webtite screenshot API guide for more details
        options.Add("dimension", "1366x768"); // or "1366xfull" for full length screenshot
        options.Add("device", "desktop");
        options.Add("format", "png");
        options.Add("cacheLimit", "0");
        options.Add("delay", "200");
        options.Add("zoom", "100");

        ScreenshotMachine sm = new ScreenshotMachine(customerKey, secretPhrase);

        string apiUrl = sm.GenerateScreenshotApiUrl(options);

        //use final apiUrl where needed
        Console.WriteLine(apiUrl);

        //or save screenshot directly
        string output = "output.png";

        new WebClient().DownloadFile(apiUrl, output);
        Console.WriteLine("Screenshot saved as " + output);
    }