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.

Wed Mar 20, 2019 7:15 am

HI,

Can I output selected sheets in workbook to pdf?
or Output each sheet to pdf and merge into one?

Thanks

abc_123_abc
 
Posts: 5
Joined: Wed Mar 20, 2019 1:41 am

Wed Mar 20, 2019 9:01 am

Hi,

Thank you for contacting us.
Sorry there is no directly way to convert selected sheets to PDF, you could respectively convert some worksheets to PDFs, and then merge them into one. Please note that this method uses both the functions of Spire.XLS and Spire.PDF. You'd better download our Spire.Office Platinum (DLL Only) Version:4.3.1 and reference the corresponding dlls (Spire.XLS.dll, Spire.Pdf.dll, Spire.Common.dll, Spire.License.dll) into your project. If there is any question, please feel free to write back.
Sample code is given as below.
Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile("Book.xlsx");

Stream stream1=new MemoryStream();
Stream stream2 = new MemoryStream();

//The worksheet named sheet1
workbook.Worksheets["sheet1"].SaveToPdfStream(stream1);
//The worksheet named sheet3
workbook.Worksheets["sheet3"].SaveToPdfStream(stream2);

//Merge the saved streams
Stream[] allStream = new Stream[] { stream1, stream2 };
PdfDocumentBase pdf = PdfDocument.MergeFiles(allStream);
pdf.Save("result.pdf");

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Wed Mar 20, 2019 2:12 pm

Hi Nina,

Thanks for reply, it really helps.

abc_123_abc
 
Posts: 5
Joined: Wed Mar 20, 2019 1:41 am

Thu Mar 21, 2019 1:21 am

Hi,

Thanks for your feedback.
If there is anything we can do for you in the future, please do not hesitate to contact us.
Wish you a wonderful day!

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF

cron