Good evening, I am unable to create the PDF on my host server (production) alone. The local file on my PC works perfectly. I have already been granted permissions on my host. I am just unable to create the PDFs on their server. Please help me, thank you!
In the HTML string, I pass the HTML page code (formatted in HTML) and the document would simply be the number (name) of the PDF that I need to create and access. Remember that it works normally locally on my PC, but it doesn't work on my server host alone. Nothing happens.
public void geraPDFcss(string html, string documento)
{
byte[] pdf;
var cssText = File.ReadAllText(HttpContext.Current.Server.MapPath("css/StyleSheet1.css"));
using (var memoryStream = new MemoryStream())
{
var document = new Document(PageSize.A4, 10, 10, 10, 10);
var writer = PdfWriter.GetInstance(document, memoryStream);
document.Open();
using (var cssMemoryStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(cssText)))
{
using (var htmlMemoryStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)))
{
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, htmlMemoryStream, cssMemoryStream);
}
}
document.Close();
var Path = "~/uploads/documentos/andaimes/";
var FileName = documento + ".pdf";
System.IO.FileStream file = System.IO.File.Create(HttpContext.Current.Server.MapPath(Path + FileName));
pdf = memoryStream.ToArray();
file.Write(pdf, 0, pdf.Length);
file.Close();
System.Diagnostics.Process.Start(HttpContext.Current.Server.MapPath(Path + FileName));
}
}