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

Maintain gridlines when exporting to PDF

I am using aspnet webforms and rendering an Excel document in the Spreadsheet control (works awesome !)

When I export to PDF (SaveAsPDF) I loose all my gridlines.
Is there a style setting or property I need to set to maintain my gridlines?

Thanks-
Don


3 Replies

SI Silambarasan I Syncfusion Team April 18, 2017 12:23 PM UTC

Hi Don Mason, 
 
Thank you for using Syncfusion products. 
 
We have checked your requirement “Need to set to maintain my gridlines on PDF exporting” and it has been achieved as a workaround solution.  Please refer the following code example. 
 
ASPX 
 
<ej:Spreadsheet ID="Spreadsheet1" OnServerPdfExporting="Spreadsheet1_ServerPdfExporting" runat="server"> 
    //... 
</ej:Spreadsheet> 
 
 
ASPX.CS 
 
using Syncfusion.Pdf; 
using Syncfusion.ExcelToPdfConverter; 
//... 
protected void Spreadsheet1_ServerPdfExporting(object sender, Syncfusion.JavaScript.Web.SpreadsheetEventArgs e) 
{ 
    var args = e.Arguments; 
    //Convert Spreadsheet data as Stream 
    Stream streamData = Spreadsheet.Save(args["sheetModel"].ToString(), args["sheetData"].ToString(), ExportFormat.XLSX, ExcelVersion.Excel2013); 
    streamData.Position = 0; //Reset reader position 
 
    ExcelToPdfConverter converter = new ExcelToPdfConverter(streamData); 
    PdfDocument pdfDocument = new PdfDocument(); 
    Syncfusion.ExcelToPdfConverter.ExcelToPdfConverterSettings settings = new Syncfusion.ExcelToPdfConverter.ExcelToPdfConverterSettings(); 
    settings.DisplayGridLines = GridLinesDisplayStyle.Visible; //Setting option to visible Gridlines 
    pdfDocument = converter.Convert(settings); 
    pdfDocument.Save("Sample.pdf", Response, HttpReadType.Save); 
    pdfDocument.Close(); 
    converter.Dispose(); 
} 
 
 
For your convenience, we have prepared a sample to demonstrate this and the same can be downloaded from the below link. 
 
Could you please check the above sample and let us know whether is this fulfilling your requirement, if not please share us more information regarding this so that we can analyze based on that and provide you a better solution. The information provided would be great help for us to proceed further. 
 
 
Regards, 
Silambarasan 



DM Don Mason April 18, 2017 05:05 PM UTC

Perfect!
works awesome.

Thank You



SI Silambarasan I Syncfusion Team April 19, 2017 04:14 AM UTC

Hi Don Mason, 
 
Thanks for your update. 
 
We are happy to hear that your requirement has been achieved.  Kindly get back to us if you need further assistance.  We will be happy to help you out. 
 
Regards,  
Silambarasan

Loader.
Live Chat Icon For mobile
Up arrow icon