function PDFCallback(event) % PDFCallback - Callback called by a MatlabServer object for generating a % pdf document as response % % CALL: % PDFCallback(event) % % INPUT: % event: <modelit.webserver.HttpExchange> % with the request data and methods to generate a response. % % OUTPUT: % No output % % EXAMPLE: % server = modelit.web.server.Server(8081, @PDFCallback).start() % % % Open a webbrowser and type: http://localhost:8081 in the address bar % % Now a pdf appears in the browser. % Copyright 2006-2023 Modelit, www.modelit.nl % Generate the response response = readBytesFromFile('install.pdf'); %this file needs ##readBytesFromFile## % Set the MIME type % See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types % And allow Cross Origin Resource Sharing event.addResponseHeader('Content-Type', 'application/pdf',... 'Access-Control-Allow-Origin', '*'); % Send the response back to the client, with statuscode 200 (OK) % See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status event.send(200, response);