<commit_before>package com.jmss.infra;

import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerHelper;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public final class PdfReport {
    private static final Logger LOG = Logger.getLogger(PdfReport.class.getName());

    private final File output;

    public PdfReport(File output) {
        this.output = output;
    }

    // TODO add Exception(???) to method signature
    // TODO rethink whether content should be save or ctor param?
    public void save(String content) {
        LOG.info(String.format("Storing PDF into '%s'...", output.getAbsolutePath()));

        try (OutputStream os = new FileOutputStream(output)) {
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, os);
            InputStream is = new ByteArrayInputStream(content.getBytes());

            document.open();
            XMLWorkerHelper.getInstance().parseXHtml(writer, document, is, getStylesStream());
            document.close();
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "Error while PDF file generation", e);
        }
    }

    private InputStream getStylesStream() {
        // TODO move to some common constants area???
        return PdfReport.class.getResourceAsStream("/reports/styles.css");
    }
}
<commit_msg>update java version on CI<commit_after>package com.jmss.infra;

import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerHelper;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

// TODO styles.css doesn't have correct font for Linux
public final class PdfReport {
    private static final Logger LOG = Logger.getLogger(PdfReport.class.getName());

    private final File output;

    public PdfReport(File output) {
        this.output = output;
    }

    // TODO add Exception(???) to method signature
    // TODO rethink whether content should be save or ctor param?
    public void save(String content) {
        LOG.info(String.format("Storing PDF into '%s'...", output.getAbsolutePath()));

        try (OutputStream os = new FileOutputStream(output)) {
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, os);
            InputStream is = new ByteArrayInputStream(content.getBytes());

            document.open();
            XMLWorkerHelper.getInstance().parseXHtml(writer, document, is, getStylesStream());
            document.close();
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "Error while PDF file generation", e);
        }
    }

    private InputStream getStylesStream() {
        // TODO move to some common constants area???
        return PdfReport.class.getResourceAsStream("/reports/styles.css");
    }
}

{'fraction_non_alphanumeric': 0.11039182282793868, 'fraction_numerical': 0.0, 'mean_word_length': 2.9515477792732168, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2483677', 'n_tokens_mistral': 804, 'n_tokens_neox': 783, 'n_words': 218}