Hi,
I have an application which I want to host on GCP and generate pdf from html. Can you please help how this can be fixed
I have tried multiple options, both of them doesn't download the file
when i try memory stream the stream length is 0
when I try with to create a pdf on tmp in gcp the file doesn't get created
But I see in this in gcp logs.
OutPdfFileName:/tmp/192a08c5-fdfe-417f-a680-5e3b2434342b.pdf
PageSize:(1000,1000)
PageMargins:(0,0,0,0)
Start conversion...
Conversion finished.
Option 1:
HtmlConverter.PluginPath = pluginPath;
using (MemoryStream stream = new MemoryStream())
{
HtmlConverter.Convert(model.Content, stream, true, int.MaxValue, new SizeF(model.width, model.height), new PdfMargins(0), LoadHtmlType.URL);
stream.Position = 0;
Console.WriteLine("stream.Length.ToString()" + stream.Length.ToString());
return File(stream.ToArray(), "application/pdf", model.FileName);
}
Option 2:
HtmlConverter.Convert(model.Content, filePathPdf, true, int.MaxValue, new SizeF(model.width, model.height), new PdfMargins(0), LoadHtmlType.SourceCode);
byte[] fileBytes = await System.IO.File.ReadAllBytesAsync(model.FileName);
var memoryStream = new MemoryStream(fileBytes);
return File(memoryStream.ToArray(), "application/pdf", model.FileName);
Thanks
Anoop