Skip to content

Instantly share code, notes, and snippets.

@Microncode
Last active March 1, 2020 15:15
Show Gist options
  • Save Microncode/713dced91644162511cc1485a5dae9de to your computer and use it in GitHub Desktop.
Save Microncode/713dced91644162511cc1485a5dae9de to your computer and use it in GitHub Desktop.
Here is a snap example of using the CSPhantomJS using C#:
//Create a new instance of the library with the path of
//the phantomjs libraries:
_WebpageCapture = new CSPhantomJS(@"../../../libs/phantomjs/bin", "UserName", "RegKey");
_WebpageCapture.DestinationFormat = DestinationFormat.Image;
_WebpageCapture.ImageFormat = "1920px";
_WebpageCapture.URL = "https://www.microncode.com";
_WebpageCapture.OutFile = _FileName;
//You can add an additional arguments:
//_WebpageCapture.ArgsAdditional = "-more arg1";
//Or if you want to set your own arguments:
//_WebpageCapture.ArgsDirect = "";
//You can get the final arguments of the command:
//string cmd = _WebpageCapture.GetArgs();
//On start event
_WebpageCapture.OperationStart += (o) =>
{
Debug.WriteLine("Start");
};
//On progress event
_WebpageCapture.OperationOutput += (o, s) =>
{
Debug.WriteLine(s);
};
//On closed
_WebpageCapture.OperationClosed += (o) =>
{
Debug.WriteLine("Closed");
};
//On done
_WebpageCapture.OperationDone += (o) =>
{
this.Invoke(new Action(() =>
{
Debug.WriteLine("Done");
}));
};
//Start the capture operation
_WebpageCapture.Capture();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment