Google reports are not shown in pdf report in Mvc c#How do I calculate someone's age in C#?What is the difference between String and string in C#?Hidden Features of C#?Calling the base constructor in C#Cast int to enum in C#How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?What are the correct version numbers for C#?Convert HTML + CSS to PDF with PHP?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?
"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"
How does one intimidate enemies without having the capacity for violence?
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
Why can't I see bouncing of a switch on an oscilloscope?
How can bays and straits be determined in a procedurally generated map?
Is it possible to do 50 km distance without any previous training?
Has the BBC provided arguments for saying Brexit being cancelled is unlikely?
Finding angle with pure Geometry.
How to write a macro that is braces sensitive?
What defenses are there against being summoned by the Gate spell?
"You are your self first supporter", a more proper way to say it
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
What is the word for reserving something for yourself before others do?
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?
Why, historically, did Gödel think CH was false?
How is it possible to have an ability score that is less than 3?
How to find program name(s) of an installed package?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
LaTeX closing $ signs makes cursor jump
Test if tikzmark exists on same page
Schoenfled Residua test shows proportionality hazard assumptions holds but Kaplan-Meier plots intersect
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
Arthur Somervell: 1000 Exercises - Meaning of this notation
Google reports are not shown in pdf report in Mvc c#
How do I calculate someone's age in C#?What is the difference between String and string in C#?Hidden Features of C#?Calling the base constructor in C#Cast int to enum in C#How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?What are the correct version numbers for C#?Convert HTML + CSS to PDF with PHP?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm using google charts in reports (https://developers.google.com/chart/)
and I'm generating Pdf files of these html files using the below code:
public FileResult DownloadReport(string viewName, string fileName, MpReportType type, int id = 0, DateRangeType? dateRangeType = null)
const string CONTAINER = "#reportContainer";
var model = GetModel(type, id, true, dateRangeType);
return DownloadReportInternal(viewName, fileName, model, CONTAINER);
private FileResult DownloadReportInternal(string viewName, string fileName, ReportGeneratorModel model, string container = "#reportContainer")
var htmlToConvert = GetHtmlFromView(viewName, model);
var hiddenElements = new string[] ".reportHiddenElement" ;
var pdfStream = ConvertHtmlToPdf(htmlToConvert, container, hiddenElements);
using (var ms = new MemoryStream())
byte[] buffer = new byte[16 * 1024];
int read;
while ((read = pdfStream.Read(buffer, 0, buffer.Length)) > 0)
ms.Write(buffer, 0, read);
var pdfBytes = ms.ToArray();
FileResult fileResult = new FileContentResult(pdfBytes, "application/pdf");
fileResult.FileDownloadName = fileName;
return fileResult;
protected string RenderViewAsString(string viewName, object model)
StringWriter stringWriter = new StringWriter();
ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, null);
ViewContext viewContext = new ViewContext(
ControllerContext,
viewResult.View,
new ViewDataDictionary(model),
new TempDataDictionary(),
stringWriter);
viewResult.View.Render(viewContext, stringWriter);
return stringWriter.ToString();
I'm calling DownloadReport from Views.
this is part of View which contains chart section
<div class="ring-chart__chart" id="cumulativeExpenseSummaryChart"></div>
and this is the function of calling the chart in js:
var drawCharts = function()
@if (Model.ComprehensiveCashflowTrack.ExpensePieChart != null)
var chart = Model.ComprehensiveCashflowTrack.ExpensePieChart;
<text>
var data = google.visualization.arrayToDataTable([
['@chart.Name', '@chart.Description']
@foreach (var item in chart.Items)
<text>, ['@item.Name', @item.Value]</text>
]);
//DrawCashflowRingChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
drawNetCashflowPieChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
</text>
Issue:
the charts are not loaded in pdf reports. they're shown correctly in the HTML page.
c# asp.net-mvc download google-visualization pdf-generation
add a comment |
I'm using google charts in reports (https://developers.google.com/chart/)
and I'm generating Pdf files of these html files using the below code:
public FileResult DownloadReport(string viewName, string fileName, MpReportType type, int id = 0, DateRangeType? dateRangeType = null)
const string CONTAINER = "#reportContainer";
var model = GetModel(type, id, true, dateRangeType);
return DownloadReportInternal(viewName, fileName, model, CONTAINER);
private FileResult DownloadReportInternal(string viewName, string fileName, ReportGeneratorModel model, string container = "#reportContainer")
var htmlToConvert = GetHtmlFromView(viewName, model);
var hiddenElements = new string[] ".reportHiddenElement" ;
var pdfStream = ConvertHtmlToPdf(htmlToConvert, container, hiddenElements);
using (var ms = new MemoryStream())
byte[] buffer = new byte[16 * 1024];
int read;
while ((read = pdfStream.Read(buffer, 0, buffer.Length)) > 0)
ms.Write(buffer, 0, read);
var pdfBytes = ms.ToArray();
FileResult fileResult = new FileContentResult(pdfBytes, "application/pdf");
fileResult.FileDownloadName = fileName;
return fileResult;
protected string RenderViewAsString(string viewName, object model)
StringWriter stringWriter = new StringWriter();
ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, null);
ViewContext viewContext = new ViewContext(
ControllerContext,
viewResult.View,
new ViewDataDictionary(model),
new TempDataDictionary(),
stringWriter);
viewResult.View.Render(viewContext, stringWriter);
return stringWriter.ToString();
I'm calling DownloadReport from Views.
this is part of View which contains chart section
<div class="ring-chart__chart" id="cumulativeExpenseSummaryChart"></div>
and this is the function of calling the chart in js:
var drawCharts = function()
@if (Model.ComprehensiveCashflowTrack.ExpensePieChart != null)
var chart = Model.ComprehensiveCashflowTrack.ExpensePieChart;
<text>
var data = google.visualization.arrayToDataTable([
['@chart.Name', '@chart.Description']
@foreach (var item in chart.Items)
<text>, ['@item.Name', @item.Value]</text>
]);
//DrawCashflowRingChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
drawNetCashflowPieChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
</text>
Issue:
the charts are not loaded in pdf reports. they're shown correctly in the HTML page.
c# asp.net-mvc download google-visualization pdf-generation
the charts are loaded and drawn asynchronously, you will need to wait until their'ready'event fires, before creating the pdf...
– WhiteHat
Mar 8 at 12:09
@WhiteHat thanks for the reply.. but I can see them in the html file created .doesn't it mean they're loaded ?
– Sara N
Mar 11 at 23:28
add a comment |
I'm using google charts in reports (https://developers.google.com/chart/)
and I'm generating Pdf files of these html files using the below code:
public FileResult DownloadReport(string viewName, string fileName, MpReportType type, int id = 0, DateRangeType? dateRangeType = null)
const string CONTAINER = "#reportContainer";
var model = GetModel(type, id, true, dateRangeType);
return DownloadReportInternal(viewName, fileName, model, CONTAINER);
private FileResult DownloadReportInternal(string viewName, string fileName, ReportGeneratorModel model, string container = "#reportContainer")
var htmlToConvert = GetHtmlFromView(viewName, model);
var hiddenElements = new string[] ".reportHiddenElement" ;
var pdfStream = ConvertHtmlToPdf(htmlToConvert, container, hiddenElements);
using (var ms = new MemoryStream())
byte[] buffer = new byte[16 * 1024];
int read;
while ((read = pdfStream.Read(buffer, 0, buffer.Length)) > 0)
ms.Write(buffer, 0, read);
var pdfBytes = ms.ToArray();
FileResult fileResult = new FileContentResult(pdfBytes, "application/pdf");
fileResult.FileDownloadName = fileName;
return fileResult;
protected string RenderViewAsString(string viewName, object model)
StringWriter stringWriter = new StringWriter();
ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, null);
ViewContext viewContext = new ViewContext(
ControllerContext,
viewResult.View,
new ViewDataDictionary(model),
new TempDataDictionary(),
stringWriter);
viewResult.View.Render(viewContext, stringWriter);
return stringWriter.ToString();
I'm calling DownloadReport from Views.
this is part of View which contains chart section
<div class="ring-chart__chart" id="cumulativeExpenseSummaryChart"></div>
and this is the function of calling the chart in js:
var drawCharts = function()
@if (Model.ComprehensiveCashflowTrack.ExpensePieChart != null)
var chart = Model.ComprehensiveCashflowTrack.ExpensePieChart;
<text>
var data = google.visualization.arrayToDataTable([
['@chart.Name', '@chart.Description']
@foreach (var item in chart.Items)
<text>, ['@item.Name', @item.Value]</text>
]);
//DrawCashflowRingChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
drawNetCashflowPieChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
</text>
Issue:
the charts are not loaded in pdf reports. they're shown correctly in the HTML page.
c# asp.net-mvc download google-visualization pdf-generation
I'm using google charts in reports (https://developers.google.com/chart/)
and I'm generating Pdf files of these html files using the below code:
public FileResult DownloadReport(string viewName, string fileName, MpReportType type, int id = 0, DateRangeType? dateRangeType = null)
const string CONTAINER = "#reportContainer";
var model = GetModel(type, id, true, dateRangeType);
return DownloadReportInternal(viewName, fileName, model, CONTAINER);
private FileResult DownloadReportInternal(string viewName, string fileName, ReportGeneratorModel model, string container = "#reportContainer")
var htmlToConvert = GetHtmlFromView(viewName, model);
var hiddenElements = new string[] ".reportHiddenElement" ;
var pdfStream = ConvertHtmlToPdf(htmlToConvert, container, hiddenElements);
using (var ms = new MemoryStream())
byte[] buffer = new byte[16 * 1024];
int read;
while ((read = pdfStream.Read(buffer, 0, buffer.Length)) > 0)
ms.Write(buffer, 0, read);
var pdfBytes = ms.ToArray();
FileResult fileResult = new FileContentResult(pdfBytes, "application/pdf");
fileResult.FileDownloadName = fileName;
return fileResult;
protected string RenderViewAsString(string viewName, object model)
StringWriter stringWriter = new StringWriter();
ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, null);
ViewContext viewContext = new ViewContext(
ControllerContext,
viewResult.View,
new ViewDataDictionary(model),
new TempDataDictionary(),
stringWriter);
viewResult.View.Render(viewContext, stringWriter);
return stringWriter.ToString();
I'm calling DownloadReport from Views.
this is part of View which contains chart section
<div class="ring-chart__chart" id="cumulativeExpenseSummaryChart"></div>
and this is the function of calling the chart in js:
var drawCharts = function()
@if (Model.ComprehensiveCashflowTrack.ExpensePieChart != null)
var chart = Model.ComprehensiveCashflowTrack.ExpensePieChart;
<text>
var data = google.visualization.arrayToDataTable([
['@chart.Name', '@chart.Description']
@foreach (var item in chart.Items)
<text>, ['@item.Name', @item.Value]</text>
]);
//DrawCashflowRingChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
drawNetCashflowPieChart('Monthly Expense Summary', 'cumulativeExpenseSummaryChart', data);
</text>
Issue:
the charts are not loaded in pdf reports. they're shown correctly in the HTML page.
c# asp.net-mvc download google-visualization pdf-generation
c# asp.net-mvc download google-visualization pdf-generation
edited Mar 12 at 3:09
Sara N
asked Mar 8 at 3:58
Sara NSara N
440732
440732
the charts are loaded and drawn asynchronously, you will need to wait until their'ready'event fires, before creating the pdf...
– WhiteHat
Mar 8 at 12:09
@WhiteHat thanks for the reply.. but I can see them in the html file created .doesn't it mean they're loaded ?
– Sara N
Mar 11 at 23:28
add a comment |
the charts are loaded and drawn asynchronously, you will need to wait until their'ready'event fires, before creating the pdf...
– WhiteHat
Mar 8 at 12:09
@WhiteHat thanks for the reply.. but I can see them in the html file created .doesn't it mean they're loaded ?
– Sara N
Mar 11 at 23:28
the charts are loaded and drawn asynchronously, you will need to wait until their
'ready' event fires, before creating the pdf...– WhiteHat
Mar 8 at 12:09
the charts are loaded and drawn asynchronously, you will need to wait until their
'ready' event fires, before creating the pdf...– WhiteHat
Mar 8 at 12:09
@WhiteHat thanks for the reply.. but I can see them in the html file created .doesn't it mean they're loaded ?
– Sara N
Mar 11 at 23:28
@WhiteHat thanks for the reply.. but I can see them in the html file created .doesn't it mean they're loaded ?
– Sara N
Mar 11 at 23:28
add a comment |
1 Answer
1
active
oldest
votes
It works for some of the pdf's after I changed the way google visualization is loading .
instead of loading the charts in document.ready() , as this :
google.charts.load('current',
callback: drawCharts,
packages: ['corechart']
);
I changed it to this :
google.load("visualization", "1", packages:["corechart"]);
google.setOnLoadCallback(drawCharts);
It shouldnt consider as answer since its not successful in some of the pdf s.
google.charts.loadwill wait for the page to load by default, and can be used in place ofdocument.ready-- although it still works,google.loadfrom thejsapilibrary is old and should no longer be used, see the release notes for more info...
– WhiteHat
Mar 12 at 11:16
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056512%2fgoogle-reports-are-not-shown-in-pdf-report-in-mvc-c-sharp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It works for some of the pdf's after I changed the way google visualization is loading .
instead of loading the charts in document.ready() , as this :
google.charts.load('current',
callback: drawCharts,
packages: ['corechart']
);
I changed it to this :
google.load("visualization", "1", packages:["corechart"]);
google.setOnLoadCallback(drawCharts);
It shouldnt consider as answer since its not successful in some of the pdf s.
google.charts.loadwill wait for the page to load by default, and can be used in place ofdocument.ready-- although it still works,google.loadfrom thejsapilibrary is old and should no longer be used, see the release notes for more info...
– WhiteHat
Mar 12 at 11:16
add a comment |
It works for some of the pdf's after I changed the way google visualization is loading .
instead of loading the charts in document.ready() , as this :
google.charts.load('current',
callback: drawCharts,
packages: ['corechart']
);
I changed it to this :
google.load("visualization", "1", packages:["corechart"]);
google.setOnLoadCallback(drawCharts);
It shouldnt consider as answer since its not successful in some of the pdf s.
google.charts.loadwill wait for the page to load by default, and can be used in place ofdocument.ready-- although it still works,google.loadfrom thejsapilibrary is old and should no longer be used, see the release notes for more info...
– WhiteHat
Mar 12 at 11:16
add a comment |
It works for some of the pdf's after I changed the way google visualization is loading .
instead of loading the charts in document.ready() , as this :
google.charts.load('current',
callback: drawCharts,
packages: ['corechart']
);
I changed it to this :
google.load("visualization", "1", packages:["corechart"]);
google.setOnLoadCallback(drawCharts);
It shouldnt consider as answer since its not successful in some of the pdf s.
It works for some of the pdf's after I changed the way google visualization is loading .
instead of loading the charts in document.ready() , as this :
google.charts.load('current',
callback: drawCharts,
packages: ['corechart']
);
I changed it to this :
google.load("visualization", "1", packages:["corechart"]);
google.setOnLoadCallback(drawCharts);
It shouldnt consider as answer since its not successful in some of the pdf s.
edited Mar 20 at 5:16
answered Mar 12 at 3:06
Sara NSara N
440732
440732
google.charts.loadwill wait for the page to load by default, and can be used in place ofdocument.ready-- although it still works,google.loadfrom thejsapilibrary is old and should no longer be used, see the release notes for more info...
– WhiteHat
Mar 12 at 11:16
add a comment |
google.charts.loadwill wait for the page to load by default, and can be used in place ofdocument.ready-- although it still works,google.loadfrom thejsapilibrary is old and should no longer be used, see the release notes for more info...
– WhiteHat
Mar 12 at 11:16
google.charts.load will wait for the page to load by default, and can be used in place of document.ready -- although it still works, google.load from the jsapi library is old and should no longer be used, see the release notes for more info...– WhiteHat
Mar 12 at 11:16
google.charts.load will wait for the page to load by default, and can be used in place of document.ready -- although it still works, google.load from the jsapi library is old and should no longer be used, see the release notes for more info...– WhiteHat
Mar 12 at 11:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056512%2fgoogle-reports-are-not-shown-in-pdf-report-in-mvc-c-sharp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
the charts are loaded and drawn asynchronously, you will need to wait until their
'ready'event fires, before creating the pdf...– WhiteHat
Mar 8 at 12:09
@WhiteHat thanks for the reply.. but I can see them in the html file created .doesn't it mean they're loaded ?
– Sara N
Mar 11 at 23:28