public IActionResult Convert() { const string fileType = "application/pdf"; const string fileName = "sample-xps.pdf"; string dataDir = Path.Combine(_appEnvironment.WebRootPath, "samples"); var xpsInputFile = Path.Combine(dataDir, "sample-new.xps"); // Initialize XPS input stream using MemoryStream pdfStream = new(); XpsDocument document = new(xpsInputFile); Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions options = new() { JpegQualityLevel = 100, ImageCompression = Aspose.Page.XPS.Presentation.Pdf.PdfImageCompression.Jpeg, TextCompression = Aspose.Page.XPS.Presentation.Pdf.PdfTextCompression.Flate }; // Create rendering device for PDF format Aspose.Page.XPS.Presentation.Pdf.PdfDevice device = new(pdfStream); document.Save(device, options); return File(pdfStream, fileType, fileName); }