Hi @Donald Symmons,
I tested your code and there is nothing wrong with the code itself. I think the problem you're talking about is that because the file is large, it takes a certain amount of time to load. I think you could add a please wait "animated" gif so it doesn't misunderstand the user.
<div id="mywaitmsg" style="display: none; width: 300px">
<h6>Loading data - please wait</h6>
<div style="text-align: center">
<img src="../images/wait.gif" style="height: 64px; width: 70px" />
</div>
</div>
<div class="btnfront" runat="server" id="portraitBtn" style="margin: 0 auto; width: 100%; margin-top: 5%; padding-bottom: 6px;">
<asp:Button ID="SaveDoc" runat="server" CssClass="btn btn-primary navbar-btn" Text="Save Document" OnClick="DownloadDocument_Click" UseSubmitBehavior="false" OnClientClick="return ConvertDocument(this)" />
</div>
<script type="text/javascript">
function ConvertDocument(SaveDoc) {
html2canvas($("#section")[0], { scale: 3 })
.then(function (canvas) {
var base64 = canvas.toDataURL();
$("[id*=ImageDatahf]").val(base64);
__doPostBack(SaveDoc.name, "");
});
var mywait = document.getElementById("mywaitmsg")
mywait.style.display = 'block';
}
</script>
protected void DownloadDocument_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000);
I discovered a problem during testing. Maybe you haven't updated yet, so I'll mention it here.
According to your previous requirements, the picture completely fills the PDF. You need to change the relevant code as follows:
<div class="col-sm-9" runat="server" id="section" style="width: 80%; height: 80%">
<asp:Image Class="imgfile" ID="imgfile" runat="server" Width="100%" Height="100%" ImageUrl="~/images/4.PNG" />
<asp:Label ID="LabelName" runat="server" Text="Recipient Name"></asp:Label>
<asp:Label ID="LabelDate" runat="server" Text="Date"></asp:Label>
</div>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.