We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Exporting to PDF

Hello,

I tried to export a GGC to PDF following the example given in the installation directory, but the method given permit only to export the TableControl of the Main Table and not the Child Tables.
I would like to know if it was possible to have an export in Landscape format of all the Grid as in the Excel one.

Regards

8 Replies

SA Solai A L Syncfusion Team November 4, 2015 12:19 PM UTC

Hi Bertuzzi,


Thank you for using Syncfusion products.


Our GGC to pdf export supports child exporting. However it has limitation, the child grid width has been limited to parent grid width in the pdf page. Please refer to the attached pdf. By default, the page exports in the landscape only. We have already logged a feature report for this.

Sample:

http://www.syncfusion.com/downloads/support/forum/121015/ze/Sample(4)481698749

Thanks,

AL.Solai.


BM Bertuzzi Mario November 5, 2015 01:49 PM UTC

Hi,

Thanks for the quick answer, I would like to have if possible a sample code for the creator of the PDF attached in your previous message.
About the PDF export only in landscape I have to disagree, since the function export only in Portrait in my code.
Perhaps a sample code would be useful for both of my questions.

Regards



SA Solai A L Syncfusion Team November 6, 2015 06:40 AM UTC

Hi Bertuzzi,

Thank you for your update.

Please refer the below sample containing parent-child table and code example for reference. Please let us know if you have any concerns.

Code Example :

private void button1_Click(object sender, EventArgs e)

        {

            GridPDFConverter pdfConvertor = new GridPDFConverter();


                pdfConvertor.ShowHeader = true;


                pdfConvertor.Margins.All = 25;

                pdfConvertor.ExportToPdf("Sample.pdf", this.groupingGrid1.TableControl);

            //Launching the PDF file using the default Application.[Acrobat Reader]

            System.Diagnostics.Process.Start("Sample.pdf");

        }
Sample :
http://www.syncfusion.com/downloads/support/forum/121015/ze/CS-875020642

Thanks,
AL.Solai.



SA Solai A L Syncfusion Team November 6, 2015 10:09 AM UTC

Hi Bertuzzi,

Please ignore our previous update.

Please refer the below dashboard sample containing parent-child table loaded from Exapand.xml file and code example for reference. Please let us know if you have any concerns.


Code Example :

private void button1_Click(object sender, EventArgs e)

        {

            GridPDFConverter pdfConvertor = new GridPDFConverter();


                pdfConvertor.ShowHeader = true;


                pdfConvertor.Margins.All = 25;

                pdfConvertor.ExportToPdf("Sample.pdf"this.groupingGrid1.TableControl);

            //Launching the PDF file using the default Application.[Acrobat Reader]

            System.Diagnostics.Process.Start("Sample.pdf");

        }

Sample:
http://www.syncfusion.com/downloads/support/forum/121015/ze/CS-1748253704


Thanks,
AL.Solai.




BM Bertuzzi Mario November 10, 2015 09:11 AM UTC

Hi,

Sorry for the late reply, now the PDF print the child tables of my GGC, but still the print is in Portrait (Vertical A4), and the function automatically split the GGC in a certain number of page.
Since you answered me in the first post that the default page exports was in Landscape, I would like to know if there is a work around.

Regards


SA Solai A L Syncfusion Team November 11, 2015 10:30 AM UTC

Hi Bertuzzi,

Thank for your update.

Please find the attachment, the landscape is getting applied properly to the document. Since, the size of grid is more that the bounds of the file, it gets paginated(i.e., the extra part moves to the next page). If you check using a small grid, you can check the orientation clearly. Anyways, if you want to change the orientation, please use the below code.

Code Example :

Method1:


  GridPDFConverter pdfConvertor = new GridPDFConverter();

  PdfDocument pdfdoc = new PdfDocument();

  PdfLayoutFormat format = new PdfLayoutFormat();

  format.Layout = PdfLayoutType.OnePage;

  pdfdoc.PageSettings.Orientation = PdfPageOrientation.Landscape;

pdfConvertor.ExportToPdf(pdfdoc, this.groupingGrid1.TableControl);


Method2 :

pdfConvertor.Exporting += new GridPDFConverter.PDFExportingEventHandler(pdfConvertor_Exporting);

  void pdfConvertor_Exporting(object sender, PDFExportingEventArgs e)

   {

            e.PdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;

   }
Exported file :
http://www.syncfusion.com/downloads/support/forum/121015/ze/Sample1-1904972378

Thanks,
AL.Solai.



RU Ruben June 20, 2016 03:34 PM UTC

Hi,

 Is posible adjust the width of pdf to view all columns displayed in one page, in my grid the last colums show in other page. Or change the font size etc...

Thanks
 


PM Piruthiviraj Malaimelraj Syncfusion Team June 21, 2016 01:36 PM UTC

Hi Ruben, 

Thank you for using Syncfusion products. 

We don’t have direct support to adjust the page width while exporting  the grid to PDF. In order to resize the column width of the grid while exporting the PDF, Exporting event can be used. In that event , you can customize the page width by using any of the following methods, 
                                              1. Use Width property of PDFDocument  
                                              2. Set the Orientation property as Landscape.  
 
Please make use of below code and refer to the attached sample. 
 
Code snippet: 
 
void pdfConvertor_Exporting(object sender, PDFExportingEventArgs e) 
{ 
     //You can use any of the followings 
     e.PdfDocument.PageSettings.Width = this.gridGroupingControl1.TableModel.ColWidths.GetTotal(0, this.gridGroupingControl1.TableModel.ColCount); 
 
     e.PdfDocument.PageSettings.Orientation = Syncfusion.Pdf.PdfPageOrientation.Landscape;  
} 

Sample link:  

Regards, 
Piruthiviraj 


Loader.
Live Chat Icon For mobile
Up arrow icon