I have provide my PDF button code. This code working fine in onpremise environment but not working properly for cloud environment.
Content and styles are loading fine But Images and Video files are not downloading into PDF file in Cloud environment We used third party tool called wkhtmltopdf.
Please help to resolve ?
protected void btnConver_Click(object sender, EventArgs e){
try
{
#region file download code
string wkhtmlToPdfExePath = HttpContext.Current.Server.MapPath(@"~\bin\wkhtmltopdf.exe");
string expPdfFname = Request.Url.Segments.Last().Contains('.') ? Request.Url.Segments.Last().Split('.')[0]+ ".pdf" : ConfigurationManager.AppSettings["expPdfFname"];
// byte[] buffer = GetFileInBytes(divContent.Text.Replace("\"","'").Replace("src=\"/","src=\"" + SPContext.Current.Web.Url + "/").Replace("src='/", "src='" + SPContext.Current.Web.Url + "/").Replace("src='../", "src='" + SPContext.Current.Web.Url+ "/").Replace("src=\"../", "src=\"" + SPContext.Current.Web.Url + "/"), wkhtmlToPdfExePath);
//String pdfFile = divContent.Text.Replace("http:", "https:");
byte[] buffer = GetFileInBytes(divContent.Text, wkhtmlToPdfExePath);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + expPdfFname);
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.BinaryWrite(buffer);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Close();
#endregion
}
catch (Exception ex)
{
}
}