|
Rank: Member Groups: Member
Joined: 11/13/2013 Posts: 11
|
Hello,
Here is the context: I have a parent page containing some UserControl in which there is Telerik grids. These grids contain text box when the user is on the web page. When they click the PDF button, I would like all these text boxes to be simple label text.
My thought would be to have the Telerik grid in edit mode when the users are going through the web page and in simple rendering mode when they click the PDF button. In this scenario, I would turn on and off the edit mode of the grid according to the page being converted as PDF or not. So the question is: is there any way to have a flag in the code like if(converting to PDF) Telerik grid in regular rending mode else Telerik grid in edit mode
A work around would be to create labels for every text box and play with HtmlToPdf.Options.InvisibleElementIds. Just the first option seems more comfortable and direct.
Thank you Grégory
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Yes. See here for more details: http://www.essentialobjects.com/doc/4/htmltopdf/eo_js.aspxThe first section "Checking Whether Inside HTML to PDF Converter" describes how to do this. Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/13/2013 Posts: 11
|
thank you for your answer.
I would like to have the same option but for the code behind in C#. All I saw was only in Javascript.
Gregory
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
No. There is no such options on the server side. What you can do is to put such code in your "triggering action". For example, if you use ASPXToPDF and has an "Export To PDF" button, then you would just set your Grid to regular rendering mode inside that button's click handler. If you use ConvertUrl, you can add a query string argument and then check that argument in your Page_Load to check the argument and perform similar logic.
Thanks
|
|
Rank: Member Groups: Member
Joined: 11/13/2013 Posts: 11
|
Thank you for the idea. It is probably the good way to go. Nevertheless I am having difficulties to realize it.
My page is structured with a masterpage and a user control which includes the telerik grid and a user control with the button to click to start ASPXToPDF. In the masterPage, I have a public property bool OnExportingPDF In the UserControl with button for PDF, I have in the method onButtonClick ( ... master.OnExportingPDF = true; ... ) In the ASPX page I have a BaseMaster master = this.Master as BaseMaster; if(master.OnExportingPDF ) label.text = "true"; else label.text = "false"
When loading the page, the value is false which is normal. When clicking on the pdf button, the Pdf export has false instead of true.
I am probably missing a step or having the code in a wrong execution order. Would you have an explanation for this one?
Thank you very much
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Try to get everything working property on the screen first. For example, if in your "Export PDF" button you call RenderAsPDF, then comment that line out (leaving other code intact). If the result is correct on the screen when you do so, then you can uncomment RenderAsPDF and the result PDF file should be correct. If the result is not correct on the screen, then you need to fix that first. You can try to think ASPXToPDF as an "output redirector". So first you would always try to get the correct result on screen. Afterwards you simply put RenderAsPDF in and the exact same HTML output that was sent to your browser will now be sent to the HTML to PDF converter. As such as long as the HTML output is correct, the PDF result should be correct, and if the HTML output is incorrect, you will be able to see it on screen if you comment RenderAsPDF out.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/13/2013 Posts: 11
|
Hi,
Thank you for the last answer. Commenting RenderAsPDF has been a nice trick to debug my issue.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Glad to hear that you got it working! Please feel free to let us know if there is anything else.
Thanks!
|
|