Advertisement
andruhovski

Aspose.Page Demo

Feb 8th, 2024
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | Software | 0 0
  1. public IActionResult Convert()
  2. {
  3.     const string fileType = "application/pdf";
  4.     const string fileName = "sample-xps.pdf";
  5.  
  6.     string dataDir = Path.Combine(_appEnvironment.WebRootPath, "samples");
  7.     var xpsInputFile = Path.Combine(dataDir, "sample-new.xps");
  8.  
  9.     // Initialize XPS input stream
  10.     using MemoryStream pdfStream = new();
  11.     XpsDocument document = new(xpsInputFile);
  12.  
  13.     Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions options = new()
  14.     {
  15.         JpegQualityLevel = 100,
  16.         ImageCompression = Aspose.Page.XPS.Presentation.Pdf.PdfImageCompression.Jpeg,
  17.         TextCompression = Aspose.Page.XPS.Presentation.Pdf.PdfTextCompression.Flate
  18.     };
  19.  
  20.     // Create rendering device for PDF format
  21.     Aspose.Page.XPS.Presentation.Pdf.PdfDevice device = new(pdfStream);
  22.  
  23.     document.Save(device, options);
  24.     return File(pdfStream, fileType, fileName);
  25. }
Tags: pdf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement