added pdf implementation demo files

This commit is contained in:
2025-09-12 01:24:24 +02:00
commit a28f3dcfdc
3 changed files with 519 additions and 0 deletions

41
PdfParameter.java Normal file
View 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;
}
}