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

Converting Excel to PDF erases some fields

Hello All,

Recently stumbled accross Syncfucion and so far it's been working pretty nice.
For a small personal project I need to edit an Excel file, and save it as PDF.
The editing part works flawlessly, however when I save it as a PDF, 2 cells don't show in the PDF.

I've attached the Excel in question.
My C# code is as follows.

                            //Open the Excel document to Convert
                            ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

                            ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();
                            // Layout the page using FitAllColumnsOnOnePage options.
                            settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;


                            //Initialize PDF document
                            PdfDocument pdfDocument = new PdfDocument();

                            //Convert Excel document into PDF document
                            pdfDocument = converter.Convert(settings);

PDF looks like the image below. The 2 cells in E39,E40 with 'Subtext1' and 'Subtext2' are missing.

Anyone has an idea as to why this happens?

-Simon

Attachment: Output_af8f67c9.rar

3 Replies

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team October 11, 2019 12:49 AM UTC

Hi Simon, 
  
Greetings from Syncfusion. 
  
Print area is set in the Excel document which you have shared us and hence the content in the print area alone will converted to PDF. This is the behavior of Microsoft Excel. We suggest you to clear the print area before converting the Excel to PDF document to get all the fields. 
 
Please refer the below code snippet to clear the Excel print area in XlsIO. 
  
Code Snippet:  
  
//Clear the print area 
workbook.Worksheets[0].PageSetup.PrintArea = string.Empty; 
  
Regards, 
Keerthi.


SI Simon October 11, 2019 06:06 AM UTC

Hello Keerthi,

I can't believed i've missed something as simple as that!
It works, thanks a million!

Kind regards,

Simon


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team October 14, 2019 08:57 AM UTC

Hi Simon, 

We are glad that the issue is resolved at your end. 

Regards, 
Keerthi. 


Loader.
Live Chat Icon For mobile
Up arrow icon