HI,
Recently we moved the Share point Content DB to Azure.After moving Convert to PDFcustom button in the webpart page is not Loading the Images and Videos. We usedwkhtmltopdf latest version(0.12.5).
The webpart page is having html content with content,images and one small video.
In Onpremise Loading all things perfectly. After move only the DB to Azure, Images are not loading. We are used azure VM only for storing our database.
The Convert to PDF custom button code is given below
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, 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)
{
}
}
And .aspx Design code is :
<asp:TextBox ID="divContent" class="divcontent" runat="server" Style="display: none"></asp:TextBox>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<SharePoint:ScriptLink Name="MicrosoftAjax.js" runat="server" Defer="False" Localizable="false"/>
<script type="text/javascript" defer="defer">
ExecuteOrDelayUntilBodyLoaded(init);
function init() {
'use strict';
// console.log("init");
debugger;
stickyAction();
var currentUrl = window.location.href;
// currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/'));
//currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/'));
currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/Pages/'));
document.getElementById("<%=GoToOverviewLink.ClientID%>").setAttribute('href', currentUrl);
document.getElementById("<%=GoToOverviewLink.ClientID%>").setAttribute('title', '<%= SPContext.Current.ListItem.Web.ParentWeb == null ? SPContext.Current.ListItem.Web.Title : SPContext.Current.ListItem.Web.ParentWeb.Title
%>');
//demoFromHTML();
var pdfContent = $("#printZone").html();
pdfContent= pdfContent.replace(/\http:/g, 'https:');
$(".divcontent").val(pdfContent);
}
var url = window.location.href;
function stickyAction() {
var isCheckedOut = false;
(typeof (PageState) != "undefined" && PageState) ? isCheckedOut = PageState.ItemIsCheckedOutToOtherUser == "1" : false;
($("#MSOLayout_InDesignMode").val() == "1" || url.toLowerCase().indexOf("controlmode=edit") > 0 || !isCheckedOut) ? $('.floatingBar').removeClass('navbar-fixed-top') : false;
($('.stickyActionBar').length > 1) ? alert('Sticky Action Bar should be one per page') : false;
var stickpos = parseInt($('#stickyActionBar').parent().parent().parent().offset().top), hedpos = parseInt($('.header-wrapper').prev().offset().top);
$('#stickyActionBar').parent().parent().addClass('floatingBar').parent().attr('data-pos', stickpos);
$('.floatingBar').css('top', hedpos);
var imgload = $('.ms-webpart-zone').find('img').length;
$('.ms-webpart-zone').find('img').load(function () {
if (imgload == imgload) {
titlePos();
} else {
return false;
}
});
}
//function titlePos() {
function titlePos() {
var thistitle = 'MENU <span class="caret"></span>';
$("#menuGroup").empty();
$("h1").each(function () {
var menuItem = $(this).text(), menuId = $(this).attr('id'), menuPos = parseInt($(this).offset().top) - 150; //console.log(menuPos);
$(this).attr('data-pos', menuPos);
$("<li><a href='#" + menuId + "' data-pos='" + menuPos + "'>" + menuItem + "</a></li>").appendTo("#menuGroup");
});
$("#menuGroup li > a").click(function () {
$('#actionMenu').parent().removeClass('open');
thistitle = $(this).text().trim() + ' <span class="caret"></span>';
var thisId = $(this).attr('href'), thisPos = $(this).attr('data-pos');//$(thisId).offset().top;
//console.log(thisPos);
$('#actionMenu').html(thistitle);
$('#s4-workspace').animate({ scrollTop: thisPos }, 1000);
return false;
});
$('#s4-workspace').scroll(function () {
$('#actionMenu').parent().removeClass('open');
if ($('#s4-workspace').scrollTop() >= $('#stickyActionBar').parent().parent().parent().attr('data-pos')) {
($("#MSOLayout_InDesignMode").val() == "1" || url.toLowerCase().indexOf("controlmode=edit") > 0) ? $('.floatingBar').removeClass('navbar-fixed-top') : $('.floatingBar').addClass('navbar-fixed-top').find('#actionMenu').html('MENU<span class="caret"></span>');
} else {
$('.floatingBar').removeClass('navbar-fixed-top');
}
$("h1").not(':first').each(function () {
if ($('#s4-workspace').scrollTop() >= $(this).attr('data-pos')) {
var thistitle = $(this).text().trim() + ' <span class="caret"></span>';
$('#actionMenu').html(thistitle);
}
});
});
}
$(window).load(function test() {
titlePos()
});
</script>
Could you Please look and provide a solution/root cause of the issue?