You’d need to build a MemoryStream object from the string, like the following:

[language=java:22f8vtt0]private static byte[] GeneratePdf(string html) {
PD4ML pd4ml = new PD4ML();
using (var output = new MemoryStream())
var encodedBytes = Encoding.UTF8.GetBytes(html);
using (var input = new MemoryStream(encodedBytes))
pd4ml.render(input, output);
return output.ToArray();

If the HTML refers to any resources (images, CSS) by relative URLs, use render() API method with base URL parameter.