HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › General questions / FAQ › .net html string › Re: Re: .net html string
August 24, 2012 at 11:41
#29100
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();
}
}
}[/language:22f8vtt0]
If the HTML refers to any resources (images, CSS) by relative URLs, use render() API method with base URL parameter.