Sample code · C#
using System; using System.IO; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using SelectPdf.Universal; namespace SelectPdf.Samples.Pages { public class PdfToPowerPointModel : PageModel { public void OnGet() { TxtPageRanges = ""; ChkTables = true; ChkImages = true; ChkHeadersAndFooters = true; ChkLinks = true; } // An uploaded pdf, or nothing - the shipped files/presentation.pdf is converted then. [BindProperty] public IFormFile FilePdf { get; set; } [BindProperty] public string TxtPageRanges { get; set; } [BindProperty] public bool ChkTables { get; set; } [BindProperty] public bool ChkImages { get; set; } [BindProperty] public bool ChkHeadersAndFooters { get; set; } [BindProperty] public bool ChkLinks { get; set; } public IActionResult OnPost() { // instantiate a pdf to powerpoint converter object PdfToPowerPoint converter = new PdfToPowerPoint(); // set converter options: the pages converted, a slide each (empty for all), tables as // PowerPoint tables, the pictures, the page headers and footers and the links converter.Options.PageRanges = TxtPageRanges ?? string.Empty; converter.Options.Tables = ChkTables; converter.Options.Images = ChkImages; converter.Options.HeadersAndFooters = ChkHeadersAndFooters; converter.Options.Links = ChkLinks; // convert the uploaded pdf, or the sample one shipped with the application byte[] presentation; if (FilePdf != null && FilePdf.Length > 0) { using (Stream uploaded = FilePdf.OpenReadStream()) { presentation = converter.ConvertStream(uploaded); } } else { string pdfFile = Path.Combine(Startup.ServerPath, "wwwroot", "files", "presentation.pdf"); presentation = converter.ConvertFile(pdfFile); } // return the converted presentation FileResult fileResult = new FileContentResult(presentation, "application/vnd.openxmlformats-officedocument.presentationml.presentation"); fileResult.FileDownloadName = "Presentation.pptx"; return fileResult; } } }