This is a migrated thread and some comments may be shown as answers.

How to Output PDF like a Merge Document

4 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 29 Sep 2010, 10:36 PM
I studied the sample code and the zip file in the forum but I have not found one similar to what I am trying to do.  

Basically, I need to write a simple web page which will work to generate a document file like  a merged document.  Because this project will be used to add to an old web software project, so the new feature will be like a URL and it will get some needed information from a simple data source, i.e. a text file, and produce output to a PDF file.    

For example, the document must output a PDF file with my name and  my children's name, date of birth and gender.   The document must have a few paragraphs of text there.    

So, my question/purpose in concept is as follow:

1.  I would like to have this Telerik web page basically get the basic information from, say, a text file or XML file and merge into an some  text like some plain paragraph..   And there will be just one big button on the top "Print PDF".      If the button is pressed, the content will be output to PDF file via the browser.

2. Most the code example generates output of data grid such as the Sushi example but my content is not just a grid, i.e. some random text and my name and the names of the children, with some paragraph before and after the data (children name) grid. I don't necessarily use the SQL Server but the intention is to use this web page as a "PDF generator".  

Could anybody show me the way on this.  

Thanks.

Tony

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 Oct 2010, 11:40 AM
Hello Tony,

As we do not have a separate PDF-exporting component you will have to use the built-in RadGrid export for that purpose. You can handle the PdfExporting event and replace the generated HTML with your own code just before it is converted to PDF.
protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e)
{
    e.RawHTML = "<p style='color: red; font-weight: bold; font-size: 16pt;'>Header Text</p>";
    e.RawHTML += "<table style='width:70mm'><colgroup><col/><col/></colgroup><tr><td>Cell1</td><td>Cell2</td></tr></table>";
}

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tony
Top achievements
Rank 1
answered on 08 Oct 2010, 09:39 PM
Daniel,

I am applying your suggestion to produce an overwrite on RadGrid1_PdfExporting. And I use the your forum's FormatGridDemo C# example. I place this code inside the default.aspx.cs section. However, I am not able to see that this code getting implemented in its output.   Perhaps I need a little more instruction on how to place this code to handle this event.  In face I am a VB code but that should not matter.  

Again, can you clearly show me how to inject this code into the FormatGridDemo example.

Thank you.

Tony




0
Tony
Top achievements
Rank 1
answered on 08 Oct 2010, 10:04 PM
Ok, I found the answer on this question.  Basically, I have to specify OnPdfExporting like OnPdfExporting="RadGrid_PdfExporting" in the Telerik Radgrid section of the aspx file. 

Now, my question is back again that I do not have a grid to show my data but the data fields look like 

name: [user name]
city: [city]
state: [state]

etc.

Question 1: How do I effectively construct a good looking HTML section of my data display and also print it out to the PDF easily?  

Question 2: And how to I inject my data fields like session variable into the raw HTML area?  

Tony  





0
Daniel
Telerik team
answered on 14 Oct 2010, 02:27 PM
Hello Tony,

The aforementioned code-library project (FormatGridDemo) is submitted by a customer. If you have any questions related to this demo you can post them directly in the code-library thread.

Onto your questions - if you prefer not to build the HTML manually, you can create a modified version of the ASP.NET Table which renders colgroup/col elements. Please examine the attached demo for more information.

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Tony
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Tony
Top achievements
Rank 1
Share this question
or