Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Nov 18, 2016 3:11 pm

Hello,

First, please let me say how thrilled I am to have found you guys! I looked for a long time for a way to easily convert an excel document to a pdf. Thank you for making such a great product!

I am having a bit of trouble in converting an excel worksheet to a PDF document. Some of the content is being clipped because it doesn't fit in the page. Is there a way that I can shrink the size of the Excel worksheet content so that it will fit inside the PDF document? This is the code I am using:

Code: Select all
var result = GenerateBOMReport(Model, bom, path, true);

Workbook workbook = new Workbook();
workbook.LoadFromStream(result);

PdfConverter pdfConverter = new PdfConverter(workbook);
PdfDocument pdfDocument = new PdfDocument();

pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;

PdfConverterSettings settings = new PdfConverterSettings();
settings.TemplateDocument = pdfDocument;
pdfDocument = pdfConverter.Convert(settings);

pdfDocument.SaveToFile(@"..\..\docs\result.pdf");


Also, I am being told that this line is obsolete:

Code: Select all
pdfDocument = pdfConverter.Convert(settings);


But I'm not sure how else to do it.

Thanks!

ccrookston
 
Posts: 1
Joined: Fri Nov 18, 2016 2:59 pm

Mon Nov 21, 2016 3:07 am

Dear ccrookston,

Sorry for late reply as weekend and thanks for your interests in our product.
Please try to use following code.
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"F:\testing\xls test form\sample document\9136.xlsx");
            workbook.ConverterSetting.SheetFitToPage = true;
            workbook.SaveToFile("9136.pdf", FileFormat.PDF);

If there is still issue, please provide us sample file so that we can investigate it on our side.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Nov 23, 2016 8:03 am

Dear ccrookston,

Did you test the code ? Did it help you solve the issue ?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF