Hi Ramya,
Unfortunately I am not authorised to provide video of our application. I will attempt to explain better.
In my view I have a diagram. I click the GeneratePDF button using this code:
Pictogram.cshtml:
<div class="col-sm-1">
<input type="button" class="btn btn-satcom-primary btn-wider" value="GeneratePDF" onclick="GeneratePdf()" />
</div>
<script type="text/javascript">
$(function () {
});
function GeneratePdf() {
console.log("GeneratePdf()");
$('#loading-icon').show();
var fileType = "png";
var fileName = "diagram";
var region = "content";
var diagram = $("#Pictogram").data("ejDiagram");
var image = diagram.exportDiagram({ mode : "data"});
$.ajax({
url: '@Url.Action("ExportToPdf", "SalesBOM")',
type: "POST",
dataType: 'text',
data: { base64data: image },
success: function (data) {
window.open("../Images/" + data);
},
error: function(xhr) {
console.log("Error in error callback");
},
complete: function() {
$('#loading-icon').delay(500).fadeOut(1000);
}
});
}
</script>
SalesBOMController.cs:
Syncfusion.Pdf.PdfDocument document = new Syncfusion.Pdf.PdfDocument();
[HttpPost]
public ActionResult ExportToPdf()
{
string filename = "sample.pdf";
string filepath = null;
if (Request.Form["base64data"] != null)
{
string image = Request.Form["base64data"].ToString();
image = image.Substring(image.IndexOf(',') + 1);
byte[] data = Convert.FromBase64String(image);
var path = Path.Combine(Server.MapPath("~/Images"), "snapshot.png");
// An image is generated.
System.IO.File.WriteAllBytes(path, data);
Thread t = new Thread(CreateDocument);
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
filepath = Path.Combine(Server.MapPath("~/Images"), "sample.pdf");
//Saves the PDF document.
document.Save(filepath);
document.Close(true);
}
return Content(filename);
}
This page is opened in a new tab.
With regards to the sample application you provided.
I run the program.
The following NullReferenceException is thrown in Visual Studio:
I hope this is helpful.
Neill