try
{
OutputStream os = new FileOutputStream(outputFile);
try
{
ITextRenderer renderer = new ITextRenderer();
MissingResourceLoggingUserAgent uac = new MissingResourceLoggingUserAgent(renderer.getSharedContext().getUserAgentCallback());
renderer.getSharedContext().setUserAgentCallback(uac);
if (title != null)
renderer.getOutputDevice().setMetadata("title", title);
if (author != null)
renderer.getOutputDevice().setMetadata("author", author);
if (subject != null)
renderer.getOutputDevice().setMetadata("subject", subject);
if (keywords != null)
renderer.getOutputDevice().setMetadata("keywords", keywords);
if (htmlFiles == null || htmlFiles.isEmpty())
htmlFiles = toFileList(htmlFileSets);
if (htmlFiles.isEmpty())
throw new MojoExecutionException("No HTML files found");
boolean initial = true;
for (File htmlFile : htmlFiles)
{
getLog().info("Converting HTML " + htmlFile.getAbsolutePath());
Document doc = readInputFileAsDocument(htmlFile);
renderer.setDocument(doc, htmlFile.toURI().toString());
renderer.layout();
if (initial)
{
renderer.createPDF(os, false);
initial = false;
}
else
renderer.writeNextDocument();
}
renderer.finishPDF();
for (RelativeUri missingImageUri : uac.getMissingImageUris())
{
getLog().warn("Missing image: " + missingImageUri.getUri() + " (from " + missingImageUri.getBase() + ")");
}