如何使用Apache Tika获取PDF格式的元素样式信息?(How to get style information of elements in PDF using Apache Tika?)
我正在玩Apache Tika从PDF文件中提取文本。 我想知道如何使用Apache Tika获取字体大小,文本颜色,特定文本(几个单词)是否为斜体,粗体等样式信息?
是否有可能获得此类信息?
另外我想如果有可能使用Apache Tika获取表信息? 表格的开头,第一行的开头,第一个单元格等信息。
I am playing around with Apache Tika to extract text from PDF files. I would like to know how to get style information like font size, text color, whether specific piece of text (few words) are in Italics, Bold, etc. using Apache Tika?
Is it even possible to get this type of information?
Also I would like to if it is possible to get table information using Apache Tika? Information like start of table, start of first row, first cell, etc.
原文:
最满意答案
不要将文本区域添加到框架中。
this.add(input);
相反,您需要将包含文本区域的JScrollPane添加到框架中:
this.add(new JScrollPane(input));
Don't add the text area to the frame.
this.add(input);
Instead you need to add a JScrollPane containing the text area to the frame:
this.add(new JScrollPane(input));
相关问答
更多-
JScrollPane中的Janel上的JTextArea不能正确调整大小(JTextArea on JPanel inside JScrollPane does not resize properly)[2023-04-21]
好的,所以问题是JPanel不喜欢嵌入到JScrollPane中。 为了使组件能够“与JScrollPane一起玩”,它需要实现Scrollable。 如果您只是将JTextArea添加到JScrollPane中,它将按您的需要完全工作。 您不需要使用JPanel来保存所有的JTextAreas,您需要创建一个扩展JPanel并实现Scrollable的小型自定义类。 我已经重新编写了你的例子并粘贴到这里: http : //pastebin.com/q9x4fv3H,这样你就可以看到所有的代码。 Scro ... -
最有可能的问题是由于右侧面板上使用的BoxLayout 。 从类javadoc复制粘贴: BoxLayout尝试以其首选宽度(水平布局)或高度(垂直布局)排列组件。 对于水平布局,如果不是所有组件都具有相同的高度,BoxLayout会尝试使所有组件与最高组件一样高。 如果对于特定组件不可能,则BoxLayout根据组件的Y对齐垂直对齐该组件。 默认情况下,组件的Y对齐为0.5,这意味着组件的垂直中心应与具有0.5 Y对齐的其他组件的垂直中心具有相同的Y坐标。 类似地,对于垂直布局,BoxLayout尝试使列 ...
-
除非我调整窗口大小,否则为什么我不能输入JTextArea?(Why can't I type in a JTextArea unless I resize the window?)[2022-04-30]
public class Note扩展JFrame { private static final long serialVersionUID = 1L; public Note() { createContent(); // add this line into your code. int x = 400; int y = 300; this.setSize(new Dimension(x, y)); this.setTitle("Post-It Note"); ... -
我相信这是因为你将你的权重设置为0(GridBagConstraints构造函数的第6个参数)。 如果您希望组件垂直增长,则需要增加此值。 If I use a BorderLayout around my elements, it works. Pete, MrWiggles, Thank you for your help!!
-
单行JTextArea(Single line JTextArea)[2022-04-16]
但我只能接受一行输入 单行文本区域显示了如何执行此操作。 相关代码是 textArea.getDocument().putProperty("filterNewlines", Boolean.TRUE); but I can only accept one line of input Single Line Text Area shows how you can do this. The relevant code is textArea.getDocument().putProperty("filter ... -
自动调整大小的JTextArea(Auto-Resizing JTextArea)[2022-08-28]
实际上, JTextArea总是具有正确的大小,因此所有文本行都可见。 您遇到的情况可能是您将文本区域包装在JScrollPane 。 只需省略滚动窗格并将文本区域作为容器的直接子元素。 另一种解决方案是侦听文本区域的事件大小并相应地调整滚动窗格大小。 这样,您可以增长到一定的大小,然后开始显示滚动条(例如,当有人将500KB的文本粘贴到文本区域时)。 Actually, the JTextArea always has the correct size so all lines of text are v ... -
JTextArea的大小(The size of a JTextArea)[2022-11-22]
在JTextArea的父容器中(在图形中表示为Panel 1),调用函数: panel1.setLayout(new BorderLayout()); 供参考,请参阅此文档页面: https://docs.oracle.com/javase/7/docs/api/java/awt/BorderLayout.html 由于panel1中只有一个子节点,因此panel1的BorderLayout布局管理器将默认拉伸文本区域以使用父容器中的所有可用空间。 您可能想要删除指定TextArea大小的构造函数参数。 ... -
JScrollPane可以调整较小的尺寸,但JTextArea不能(JScrollPane can resize smaller, but JTextArea does not)[2022-05-25]
JTextArea应该直接放置到JScrollPane ,只要这是你试图滚动的组件。 如果还有其他项需要滚动(因此也是中间JPanel ),那么您可能需要考虑让JPanel实现Scrollable以便JScrollPane知道如何处理它。 JTextArea实现了Scrollable ,这就是为什么它可以与JScrollPane一起使用。 JTextArea should be placed directly into the JScrollPane, as long as that is the comp ... -
您正在目睹的问题是GridBagLayout试图处理它无法遵守组件的preferredSize的情况,它将恢复使用组件minimumSize而不是...... 您可以使用GridBagConstraints#weightx属性强制组件始终填充其列宽... c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.weightx = 1.0; cont ...
-
不要将文本区域添加到框架中。 this.add(input); 相反,您需要将包含文本区域的JScrollPane添加到框架中: this.add(new JScrollPane(input)); Don't add the text area to the frame. this.add(input); Instead you need to add a JScrollPane containing the text area to the frame: this.add(new JScrol ...