// You may also change texts, positions and more by editing directly the method // generatePrinterFriendlyVersion() below. // #################################################################################################### // GET: PrinterFriendlyPadesRestPki?userfile={id} public ActionResult Index(string userfile) { // Locate document and read content from storage. Our action only works if the a valid fileId is // given. byte[] fileContent; try { fileContent = StorageMock.Read(userfile); } catch (FileNotFoundException) { return(HttpNotFound()); } // Check if doc already has a verification code registered on storage. var verificationCode = StorageMock.GetVerificationCode(userfile); if (verificationCode == null) { // If not, generate a code an register it. verificationCode = Util.GenerateVerificationCode(); StorageMock.SetVerificationCode(userfile, verificationCode); } // Generate the printer-friendly version. var pfvContent = generatePrinterFriendlyVersion(fileContent, verificationCode); // Return printer-friendly version as a downloadable file. return(File(pfvContent, "application/pdf", "printer-friendly.pdf")); }