added pdf implementation demo files
This commit is contained in:
41
PdfParameter.java
Normal file
41
PdfParameter.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.example.reporting.services.impl.pdf;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import com.example.reporting.dto.database.ReportDto;
|
||||
|
||||
/**
|
||||
* Interface for PDF Parameter
|
||||
*/
|
||||
interface PdfParameter {
|
||||
|
||||
/**
|
||||
* Returns the filename for the content disposition header.
|
||||
*
|
||||
* @param dto The ReportDto object to extract the filename from.
|
||||
* @return The filename for the content disposition header.
|
||||
*/
|
||||
public abstract String getContentDispositionFilename(ReportDto dto);
|
||||
|
||||
/**
|
||||
* Returns the HttpHeaders for the PDF response.
|
||||
*
|
||||
* @return The HttpHeaders for the PDF response.
|
||||
*/
|
||||
public abstract HttpHeaders headers();
|
||||
|
||||
/**
|
||||
* Returns the HttpHeaders for the PDF response.
|
||||
*
|
||||
* @param dto The ReportDto object to extract the headers from.
|
||||
* @return The HttpHeaders for the PDF response.
|
||||
*/
|
||||
public default HttpHeaders headers(ReportDto dto) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
||||
headers.setContentDispositionFormData("attachment", getContentDispositionFilename(dto));
|
||||
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user