Код: Выделить всё
@Service
public class TaggedPdfReaderToolone extends TaggedPdfReaderTool {
@Autowired
ViewTagUtils viewTagUtils;
protected int order;
/**
* Constructs a {@link TaggedPdfReaderTool} via a given {@link PdfDocument}.
*
* @param document the document to read tag structure from
*/
public TaggedPdfReaderToolone(PdfDocument document) {
super(document);
}
@Override
public TaggedPdfReaderToolone setRootTag(String rootTagName) {
this.rootTag = rootTagName;
order =0;
return this;
}
@Override
@Async
public void convertToXml(OutputStream os)
throws IOException {
convertToXml(os, "UTF-8");
}
@Override
@Async
public void convertToXml(OutputStream os, String charset)
throws IOException {
out = new OutputStreamWriter(os, Charset.forName(charset));
if (rootTag != null) {
out.write("" + System.lineSeparator());
}
// get the StructTreeRoot from the document
PdfStructTreeRoot structTreeRoot = document.getStructTreeRoot();
if (structTreeRoot == null)
throw new PdfException(KernelExceptionMessageConstant.DOCUMENT_DOES_NOT_CONTAIN_STRUCT_TREE_ROOT);
// Inspect the child or children of the StructTreeRoot
inspectKids(structTreeRoot.getKids());
out.write(" ");
if (rootTag != null) {
out.write("");
}
out.flush();
out.close();
}
Код: Выделить всё
@Slf4j
@Service
public class Viewtag {
@Autowired
ViewTagUtils viewTagUtils;
public void gettagcontent(String taggedPdf, String xmlfilepath) throws IOException {
log.info("Viewing tagged page content started "+ taggedPdf);
PdfReader reader = new PdfReader(taggedPdf);
// log.info("Before file load.");
//filePathBean.setFilePath(taggedPdf);
PdfDocument doc = new PdfDocument(reader);
log.info("After file load.");
viewTagUtils.setPagNumber(0);
if (doc.isTagged()) {
log.info("view tagged content called");
log.info(xmlfilepath);
FileOutputStream xmlOut = new FileOutputStream(xmlfilepath);
// new TaggedPdfReaderTool(doc).setRootTag("root").convertToXml(xmlOut);
TaggedPdfReaderToolone taggedPdfReaderToolone = new
TaggedPdfReaderToolone(doc);
taggedPdfReaderToolone.setRootTag("root").convertToXml(xmlOut);
}else
log.info("PDF is not a tagged pdf.");
doc.close();
log.info("Viewing tagged page content completed "+ taggedPdf);
}
}
после обнаружения этой ошибки я выполнил настройку
как показано ниже,
р>
Код: Выделить всё
@Configuration
public class BeanCreation {
@Bean
public PdfDocument createPdfDocument(String filePath) throws IOException {
return new PdfDocument(new PdfReader(filePath));
}
}
Теперь я получаю сообщение об ошибке
рассмотрите возможность создания компонента java.lang.String в BeanCreation,
Примечание: – Проект, над которым я работаю, представляет собой сборку Gradel и нет XML-файла использование завершено.
Любые предложения по решению проблемы будут вам полезны
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/791 ... e-beans-in
Мобильная версия