//Target directory for Webhelp points to ${basepath}/target/docbkx/webhelp. So get parent.
File baseDir = getTargetDirectory().getParentFile();
//The point FO/PDF file output to be generated at ${basepath}/target/docbkx/autopdf.
File targetDir = new File(baseDir.getAbsolutePath(), "autopdf");
//Create a new instance of PDFBuilder class and set config variables.
PDFBuilder pdfBuilder = new PDFBuilder();
pdfBuilder.setProject(getMavenProject());
pdfBuilder.setSourceDirectory(getSourceDirectory());
pdfBuilder.setAutopdfTargetDirectory(targetDir);
pdfBuilder.setCoverColor(coverColor);
pdfBuilder.setPageWidth(pageWidth);
pdfBuilder.setPageHeight(pageHeight);
pdfBuilder.setOmitCover(omitCover);
pdfBuilder.setDoubleSided(doubleSided);
pdfBuilder.setCoverLogoPath(coverLogoPath);
pdfBuilder.setSecondaryCoverLogoPath(secondaryCoverLogoPath);
pdfBuilder.setCoverLogoLeft(coverLogoLeft);
pdfBuilder.setCoverLogoTop(coverLogoTop);
pdfBuilder.setCoverUrl(coverUrl);
pdfBuilder.setPdfFilenameBase(pdfFilenameBase);
pdfBuilder.setBranding(branding);
pdfBuilder.setBuiltForOpenStack(builtForOpenStack);
pdfBuilder.setSecurity(security);
pdfBuilder.setDraftStatus(draftStatus);
pdfBuilder.setStatusBarText(statusBarText);
pdfBuilder.setBodyFont(bodyFont);
pdfBuilder.setMonospaceFont(monospaceFont);
pdfBuilder.setLocalFontPath(localFontPath);
pdfBuilder.setTrimWadlUriCount(trimWadlUriCount);
pdfBuilder.setComputeWadlPathFromDocbookPath(computeWadlPathFromDocbookPath);
pdfBuilder.setInputFilename(inputFilename);
pdfBuilder.setEntities(getEntities());
pdfBuilder.setChapterAutolabel(getProperty("chapterAutolabel"));
pdfBuilder.setAppendixAutolabel(getProperty("appendixAutolabel"));
pdfBuilder.setSectionAutolabel(getProperty("sectionAutolabel"));
pdfBuilder.setSectionLabelIncludesComponentLabel(getProperty("sectionLabelIncludesComponentLabel"));
pdfBuilder.setFormalProcedures(getProperty("formalProcedures"));
pdfBuilder.setGenerateToc(getProperty("generateToc"));
pdfBuilder.setTocMaxDepth(getProperty("tocMaxDepth"));
pdfBuilder.setTocSectionDepth(getProperty("tocSectionDepth"));
pdfBuilder.setGlossaryCollection(getProperty("glossaryCollection"));
File srcFilename = new File(this.projectBuildDirectory, "docbkx/"+sourceFile.getName());
if(srcFilename.exists()) {
if (getLog().isDebugEnabled()) {
getLog().debug("***********************"+ srcFilename);
}
pdfBuilder.setSourceFilePath(srcFilename);
} else {
if (getLog().isDebugEnabled()) {
getLog().debug("***********************"+ getSourceDirectory()+File.separator+inputFilename);
}
pdfBuilder.setSourceFilePath(new File(getSourceDirectory(), inputFilename));
}
pdfBuilder.setProjectBuildDirectory(baseDir);
//setup fonts and images
pdfBuilder.preProcess();
//process input docbook to create FO file
File foFile = pdfBuilder.processSources(map);
//transform FO file to PDF
File pdfFile = pdfBuilder.postProcessResult(foFile);
//move PDF to where the webhelp stuff is for this docbook.
if(pdfFile!=null) {
File targetDirForPdf = ((File)map.get("targetHtmlContentDir")).getParentFile();
if(!targetDirForPdf.exists()) {
com.rackspace.cloud.api.docs.FileUtils.mkdir(targetDirForPdf);
}
boolean moved = pdfBuilder.movePdfToWebhelpDir(pdfFile, targetDirForPdf);
if(moved && getLog().isDebugEnabled()) {
getLog().info("Successfully moved auto-generated PDF file to Webhelp target directory!");
} else if(getLog().isDebugEnabled()) {
getLog().error("Unable to move auto-generated PDF file to Webhelp target directory!");
}