public void toPdf() throws IOException {
		try {
			document.open();

			// il serait possible d'ouvrir la boîte de dialogue Imprimer de Adobe Reader
			//		      if (writer instanceof PdfWriter) {
			//		        ((PdfWriter) writer).addJavaScript("this.print(true);", false);
			//		      }

			pdfCoreReport.toPdf();
		} catch (final DocumentException e) {
			throw createIOException(e);
		}

		document.close();
	}
@Test
	public void testToPdf() throws Exception {
		final Counter sqlCounter = new Counter("sql", "db.png");
		// counterName doit être http, sql ou ejb pour que les libellés de graph soient trouvés dans les traductions
		final Counter counter = new Counter("http", "db.png", sqlCounter);
		final Counter errorCounter = new Counter(Counter.ERROR_COUNTER_NAME, null);
		final Counter jobCounter = TestHtmlReport.getJobCounter();
		final List<Counter> counters = List.of(counter, sqlCounter, errorCounter, jobCounter);
		counter.addRequest("test1", 0, 0, 0, false, 1000);
		counter.addRequest("test2", 1000, 500, 500, false, 1000);
		counter.addRequest("test3", 10000, 500, 500, true, 10000);
		final Collector collector = new Collector("test", counters);
		final JavaInformations javaInformations = new JavaInformations(null, true);
		final List<JavaInformations> javaInformationsList = Collections
				.singletonList(javaInformations);
		counter.addRequest("test1", 0, 0, 0, false, 1000);
		collector.collectWithoutErrors(javaInformationsList);
		counter.clear();
		collector.collectWithoutErrors(javaInformationsList);
		toPdf(collector, true, javaInformationsList, null);

		final JRobin jrobin = collector.getCounterJRobins().iterator().next();
		final byte[] graph = jrobin.graph(Period.JOUR.getRange(), 50, 50);
		final Map<String, byte[]> graphs = new HashMap<>();
		graphs.put("1", graph);
		graphs.put("2", graph);
		graphs.put("3", graph);
		graphs.put("4", graph);

		toPdf(collector, true, javaInformationsList, graphs);

		// pour les PDFs suivants, inutile de regénérer toutes les images,
		// ce qui prendrait beaucoup de temps, donc on utilise preInitGraphs
		final Map<String, byte[]> emptyGraphs = Collections.emptyMap();
		counter.bindContext("test 1", "complete test 1", null, -1, -1);
		sqlCounter.bindContext("sql1", "sql 1", null, -1, -1);
		sqlCounter.addRequest("sql1", 100, 100, 100, false, -1);
		counter.addRequest("test 1", 0, 0, 0, false, 1000);
		counter.addRequest("test2", 1000, 500, 500, false, 1000);
		counter.addRequest(buildLongRequestName(), 10000, 5000, 5000, true, 10000);
		collector.collectWithoutErrors(javaInformationsList);
		toPdf(collector, true, javaInformationsList, emptyGraphs);

		toPdf(collector, false, javaInformationsList, emptyGraphs);

		// errorCounter
		errorCounter.addRequestForSystemError("error", -1, -1, -1, null);
		errorCounter.addRequestForSystemError("error2", -1, -1, -1, "ma stack-trace");
		toPdf(collector, false, javaInformationsList, emptyGraphs);

		rootContexts(counter, collector, javaInformations);

		cache(collector);

		job(collector);

		Utils.setProperty(Parameter.NO_DATABASE, Boolean.TRUE.toString());
		toPdf(collector, false, javaInformationsList, emptyGraphs);
		Utils.setProperty(Parameter.NO_DATABASE, Boolean.FALSE.toString());

		I18N.bindLocale(Locale.CHINA);
		try {
			toPdf(collector, false, javaInformationsList, emptyGraphs);
		} finally {
			I18N.unbindLocale();
		}
	}