Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, July 14, 2017 2:06 PM
Using a version from my test server. when I do a window.print(), that is linked to a button on the form, on my machine, it is opening up a print dialog. Ideally I just want this to create and open a PDF file. Now I have to specify the PDF Adobe print driver and print to a file. On our production server, the current process when the <Print> button is clicked, the windows.print() prompts the user to Open or Save a PDF. There must be some difference in the code.
Thanks!
All replies (5)
Friday, July 14, 2017 3:04 PM
window.print(), is a command to the browser to print the page. like picking file->print. if clicking the server button opens a save dialog, then it just a link to a request that return a pdf document.
<a href="/some url that return a pdf">print</a>
most like its server code that builds a report and returns a pdf file.
Friday, July 14, 2017 5:11 PM
Thanks for the reply,
I am having a difficult time finding the link. The onclick event for the button is onclick = "windows.print()", and that's it. Searching the entire solution, I see no reference to PDF or Adobe, etc
It is hidden somewhere...
Friday, July 14, 2017 5:48 PM
You can open a pdf with
<a href="#" onclick="window.open('MyPDF.pdf', '_blank', 'fullscreen=yes'); return false;">MyPDF</a>
<a href="#" onclick="window.open('file:///D:/Examples/file2.html')">CLICK ME</a>
Friday, July 14, 2017 7:49 PM
- Thanks for the reply.
I traced the code and it seems that the version of the code is not the exact as the on that is running in our current production environment. (Bad outsource project.) I was able figure out what code needs to run instead of what is there. However, now my question is:
For this report there is a .cshtml
- @myModel.Models.myTrendReport @{
- Viewbag.Title = "My Trend Report"
- @Section ViewScripts {script type = "text/javascript"
- There are two functions for that are mapped to buttons or hyperlinks on the page. The one function prints the report calling a Reporting Services URL. This is the function that I am replacing the window.print().
- Alter the last function code there is the </script> Then the first <div> starts.
- In the <div> section it is referencing a Model.Item ie @Model.Category.ID
- I need to be able to access this ID in the function and concatenate it at the end of the Reporting Services URL.
Function PrintReport() {
const reporturl= 'http://myULR/ReportServer?/ReportName:Format=PDF&UserID=';
var fullReportUrl =reporturl + @Model.Category.ID; << This is the value I need.....>>>>
var newWindow = window.open(fullReportUrl, 'Trend Report', 'height=400,width=600');
newWindow.focus();
return true;
}
Thanks for the help.
Monday, July 17, 2017 6:06 AM
Hi aspdev0978,
aspdev0978
var fullReportUrl =reporturl + @Model.Category.ID; << This is the value I need.....>>>>
Please use double quotes "" to wrap the @Model.Category.ID in above code to make it correct.
var fullReportUrl =reporturl + "@Model.Category.ID"; << This is the value I need.....>>>>
Best Regards,
Jean