for web api I am returing the pdf as :-Wie öffne ich ein pdf in reactjs?
[EnableCors("*", "*", "*")]
[HttpGet]
public byte[] GetReportData()
{
string filePath = "D:\\Decoding.pdf";
byte[] bytes = File.ReadAllBytes(filePath);
return bytes;
}
ich die Methode in meinem Handeln und Minderer als Aufruf: -
Aktion: -
export function LoadReportData() {
return (dispatch) => {
dispatch({
type: REQUEST_REPORT,//defining the name of the action to identify in the reducer
});
fetch(APIPATH+'Requisition/GetReportData')//calling the service
.then((response) => response.json())
.then((report) => dispatch(receiveReport(report)));//passing the data to other actions
}
}
//this method use to pass the data coming for the lab test result to the component
export function receiveReport(report) {
return {
type:RECEIVE_REPORT,//defining the name of the action to identify in the reducer
report:report//passing the data to reducer
};
}
Reduzierungen: -
case 'RECEIVE_REPORT':
return Object.assign({}, state, {
report: action.report,
loadingReport: false,
});
case 'REQUEST_REPORT':
return Object.assign({}, state, {
loadingReport: true
});
nun der Bericht kommt als Byte, als ich von der Web-API übergeben wurde. Nun meine Anforderung ist, wie kann ich diese PDF-Datei, die als Byte-Array kommt aus der Web-API in meiner Komponente oder der nächsten Registerkarte des Browsers anzeigen. Hinweis: Bericht über die Byte-Array
@Vadim Ich habe es versucht, aber "Uncaught ReferenceError: PDFJS ist nicht definiert" kommt als Fehler – jack123