// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/PdfReport.java
// public class PdfReport implements AutoCloseable {
//     private static final Logger LOG = getLogger(PdfReport.class);
// 
//     private final String fileName;
//     private final DocumentWithResources documentWithResources;
// 
//     public PdfReport(String fileName, DocumentWithResources documentWithResources) {
//         this.fileName = fileName;
//         this.documentWithResources = documentWithResources;
//     }
// 
//     public String getFileName() {
//         return fileName;
//     }
// 
//     /**
//      * Prefer using saveAndClose whenever possible.
//      * Alternatively call close() yourself to close any tracked resource dependencies.
//      */
//     public PDDocument getDocument() {
//         return documentWithResources.getDocument();
//     }
// 
//     public void saveAndClose(OutputStream outputStream) throws IOException {
//         documentWithResources.saveAndClose(outputStream);
//     }
// 
//     @Override
//     public void close() {
//         documentWithResources.close();
//     }
// 
// }
// 
// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/PdfReportPrinter.java
// public interface PdfReportPrinter<T> {
//     void print(PdfReport report, T destination) throws IOException;
// }
// 
// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/impl/PdfReportFilePrinter.java
// public final class PdfReportFilePrinter implements PdfReportPrinter<File> {
// 
//     public void print(PdfReport report, File directory) throws IOException {
//         if (!directory.isDirectory()) {
//             throw new IllegalArgumentException(directory + " is no directory ");
//         }
//         File outputFile = new File(directory, report.getFileName());
//         report.saveAndClose(new BufferedOutputStream(new FileOutputStream(outputFile)));
//         report.close();
//     }
// 
// }
// 
// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/impl/PdfReportHttpResponsePrinter.java
// public final class PdfReportHttpResponsePrinter implements PdfReportPrinter<HttpServletResponse> {
// 
//     public void print(PdfReport report, HttpServletResponse response) throws IOException {
//         response.setContentType("application/pdf");
//         response.setHeader("Content-disposition", "attachment; filename=" + report.getFileName());
// 
//         report.saveAndClose(response.getOutputStream());
//         response.getOutputStream().close();
//     }
// 
// }


import cc.catalysts.boot.report.pdf.PdfReport;
import cc.catalysts.boot.report.pdf.PdfReportPrinter;
import cc.catalysts.boot.report.pdf.impl.PdfReportFilePrinter;
import cc.catalysts.boot.report.pdf.impl.PdfReportHttpResponsePrinter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
package cc.catalysts.boot.report.pdf.config;



/**
 * @author Klaus Lehner
 */
@Configuration
@ComponentScan(basePackageClasses = PdfReport.class)
@EnableConfigurationProperties(value = DefaultPdfStyleSheet.class)
public class PdfReportAutoConfiguration {

    @Bean
    PdfReportPrinter<File> fileReportPrinter() {
        return new PdfReportFilePrinter();
    }


    @Configuration
    @ConditionalOnClass(HttpServletResponse.class)
    static class ServletConfiguration {
// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/PdfReport.java
// public class PdfReport implements AutoCloseable {
//     private static final Logger LOG = getLogger(PdfReport.class);
// 
//     private final String fileName;
//     private final DocumentWithResources documentWithResources;
// 
//     public PdfReport(String fileName, DocumentWithResources documentWithResources) {
//         this.fileName = fileName;
//         this.documentWithResources = documentWithResources;
//     }
// 
//     public String getFileName() {
//         return fileName;
//     }
// 
//     /**
//      * Prefer using saveAndClose whenever possible.
//      * Alternatively call close() yourself to close any tracked resource dependencies.
//      */
//     public PDDocument getDocument() {
//         return documentWithResources.getDocument();
//     }
// 
//     public void saveAndClose(OutputStream outputStream) throws IOException {
//         documentWithResources.saveAndClose(outputStream);
//     }
// 
//     @Override
//     public void close() {
//         documentWithResources.close();
//     }
// 
// }
// 
// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/PdfReportPrinter.java
// public interface PdfReportPrinter<T> {
//     void print(PdfReport report, T destination) throws IOException;
// }
// 
// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/impl/PdfReportFilePrinter.java
// public final class PdfReportFilePrinter implements PdfReportPrinter<File> {
// 
//     public void print(PdfReport report, File directory) throws IOException {
//         if (!directory.isDirectory()) {
//             throw new IllegalArgumentException(directory + " is no directory ");
//         }
//         File outputFile = new File(directory, report.getFileName());
//         report.saveAndClose(new BufferedOutputStream(new FileOutputStream(outputFile)));
//         report.close();
//     }
// 
// }
// 
// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/impl/PdfReportHttpResponsePrinter.java
// public final class PdfReportHttpResponsePrinter implements PdfReportPrinter<HttpServletResponse> {
// 
//     public void print(PdfReport report, HttpServletResponse response) throws IOException {
//         response.setContentType("application/pdf");
//         response.setHeader("Content-disposition", "attachment; filename=" + report.getFileName());
// 
//         report.saveAndClose(response.getOutputStream());
//         response.getOutputStream().close();
//     }
// 
// }


// Path: cat-boot-report-pdf/src/main/java/cc/catalysts/boot/report/pdf/config/PdfReportAutoConfiguration.java
import cc.catalysts.boot.report.pdf.PdfReport;
import cc.catalysts.boot.report.pdf.PdfReportPrinter;
import cc.catalysts.boot.report.pdf.impl.PdfReportFilePrinter;
import cc.catalysts.boot.report.pdf.impl.PdfReportHttpResponsePrinter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletResponse;
import java.io.File;

package cc.catalysts.boot.report.pdf.config;



/**
 * @author Klaus Lehner
 */
@Configuration
@ComponentScan(basePackageClasses = PdfReport.class)
@EnableConfigurationProperties(value = DefaultPdfStyleSheet.class)
public class PdfReportAutoConfiguration {

    @Bean
    PdfReportPrinter<File> fileReportPrinter() {
        return new PdfReportFilePrinter();
    }


    @Configuration
    @ConditionalOnClass(HttpServletResponse.class)
    static class ServletConfiguration {
        @Bean