我需要解析包含表格数据的PDF文件.我正在使用PDFBox提取文件文本以便稍后解析结果(String).问题是文本提取不像我预期的表格数据那样工作.例如,我有一个包含这样的表的文件(7列:前两个总是有数据,只有一个Complexity列有数据,只有一个Financing列有数据):
+----------------------------------------------------------------+
| AIH | Value | Complexity | Financing |
| | | Medium | High | Not applicable | MAC/Other | FAE |
+----------------------------------------------------------------+
| xyz | 12.43 | 12.34 | | | 12.34 | |
+----------------------------------------------------------------+
| abc | 1.56 | | 1.56 | | | 1.56|
+----------------------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)
然后我使用PDFBox:
PDDocument document = PDDocument.load(pathToFile);
PDFTextStripper s = new PDFTextStripper();
String content = s.getText(document);
Run Code Online (Sandbox Code Playgroud)
这两行数据将被提取如下:
xyz 12.43 12.4312.43
abc 1.56 1.561.56
Run Code Online (Sandbox Code Playgroud)
最后两个数字之间没有空格,但这不是最大的问题.问题是我不知道最后两个数字是什么意思:中,高,不适用?MAC /其他,FAE?我没有数字和列之间的关系.
我不需要使用PDFBox库,因此使用另一个库的解决方案很好.我想要的是能够解析文件并知道每个解析的数字意味着什么.
我在尝试使用React创建一个复选框来选择和取消选择其他单独的复选框(选择/取消选择全部)时遇到了一些问题.我已经阅读了http://facebook.github.io/react/docs/forms.html,发现受控和非受控 <input> s 之间存在差异.我的测试代码如下:
var Test = React.createClass({
getInitialState: function() {
return {
data: [
{ id: 1, selected: false },
{ id: 2, selected: false },
{ id: 3, selected: false },
{ id: 4, selected: false }
]
};
},
render: function() {
var checks = this.state.data.map(function(d) {
return (
<div>
<input type="checkbox" data-id={d.id} checked={d.selected} onChange={this.__changeSelection} />
{d.id}
<br />
</div>
);
});
return (
<form>
<input type="checkbox" ref="globalSelector" onChange={this.__changeAllChecks} />Global …Run Code Online (Sandbox Code Playgroud) 使用时,使用默认值声明可选查询参数的正确方法是什么compojure-api?
我的一个路由元素如下(阅读本文后):
(GET "/:id/descendants" [id]
:return [d/CategoryTreeElement]
:path-params [id :- Long]
:query-params [context-type :- d/ContextType
levels :- Integer
{tenant :- d/Tenant :DEF_TENANT}
{show-future :- Boolean false}
{show-expired :- Boolean false}
{show-suppressed :- Boolean false}
:summary "Fetch category descendants"
(ok ...))
Run Code Online (Sandbox Code Playgroud)
首先,布尔参数定义为其他(例如show-future Boolean),但生成的Swagger UI将它们显示为组合框,其true值为默认值.在当前形式中,UI显示没有选择选项的组合框.租户也是如此.
一方面问题:当我使用Swagger生成的UI发送请求并返回错误时:"levels": "(not (instance? java.lang.Integer \"2\"))".这是为什么?是不是库应该强制/转换字符串值到API声明的指定类型?
提前致谢.
尝试在我的应用程序中配置Struts 2文件上传拦截器时遇到两个问题.我想更改参数maximumSize(默认值为2 MB,我需要它为5 MB)和消息资源struts.messages.error.file.too.large(应用程序区域设置为pt_BR,因此消息是葡萄牙语,而不是英语).
应用程序当前配置如下:
struts.properties
struts.locale=pt_BR
struts.custom.i18n.resources=MessageResources
Run Code Online (Sandbox Code Playgroud)
在struts.xml
<package name="default" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="login" class="br.com.probank.interceptor.LoginInterceptor"/>
<interceptor-stack name="defaultLoginStack">
<interceptor-ref name="login" />
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="defaultLoginStack" />
...
</package>
...
<package name="proposta" namespace="/proposta" extends="default">
<action name="salvarAnexoProposta" method="salvarAnexoProposta" class="br.com.probank.action.AnexoPropostaAction">
<interceptor-ref name="defaultLoginStack">
<param name="fileUpload.maximumSize">5242880</param>
</interceptor-ref>
<result name="success">/jsp/listagemAnexosPropostaForm.jsp</result>
<result name="input">/jsp/crudAnexoPropostaForm.jsp</result>
<result name="error">/jsp/error.jsp</result>
<result name="redirect" type="redirect">${redirectLink}</result>
</action>
</package>
Run Code Online (Sandbox Code Playgroud)
MessageResources.properties
...
struts.messages.error.file.too.large=O tamanho do arquivo...
Run Code Online (Sandbox Code Playgroud)
我的Action实现和我的JSP代码没有什么特别之处.他们按照http://struts.apache.org/2.1.6/docs/file-upload-interceptor.html上的示例进行操作.当我尝试上传超过5 MB的文件时,应用程序会显示消息"请求被拒绝,因为其大小(6229458)超过了配置的最大值(2097152)" - 默认的文件上载消息,其默认值为maximumSize.
我尝试将消息资源struts.messages.error.file.too.large放在struts-messages.properties中,但之后消息没有改变.配置文件上传拦截器的正确方法是什么?我正在使用Struts 2 2.1.7.提前致谢.
configuration struts2 file-upload interceptor interceptorstack
我试图为我的问题找到解决办法,但到目前为止我的努力都是徒劳的.:-(
我使用Visual Studio 2010,.NET Framework 4,C#,Entity Framework 5.0,MySQL 5.5以及相应的.NET连接器(6.5.4版)创建了一个Web项目.我正在使用代码优先实现实体和O/R映射.
我面临的问题是我无法执行看似简单的迁移.这是我的实体类:
public class Usuario
{
public int Id { get; set; }
[Required]
[StringLength(100)]
public string NomeCompleto { get; set; }
[Required]
[StringLength(100)]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
[Required]
[StringLength(30)]
public string Login { get; set; }
[Required]
[StringLength(64)]
public string Senha { get; set; }
[Required]
public bool Ativo { get; set; }
//[Timestamp]
[ConcurrencyCheck]
public int Versao { get; set; }
}
public class Perfil
{ …Run Code Online (Sandbox Code Playgroud) 在使用Entity Framework Code First Migrations时,我和我的团队在尝试保持我们的开发(很快,客户端的生产)数据库与我们的模型同步时遇到了很多问题.
当由于DropForeignKey()方法调用错误而不得不手动编辑迁移代码时,问题似乎开始发生.(我的项目是使用MySQL 5.5,MySQL Connector 6.6.2,EF 4.3.)有问题的命令:
DropForeignKey("Recebimento", "ComponenteFabricante_Id", "CompFab");
Run Code Online (Sandbox Code Playgroud)
改为:
DropForeignKey("Recebimento", "FK_RecebimentoMaterial_CompFab_ComponenteFabricante_Id");
Run Code Online (Sandbox Code Playgroud)
从那时起,每当我尝试时Update-Databse,即使我知道我已经拥有反映当前模型映射的所有迁移代码,也会显示以下消息:"无法更新数据库以匹配当前模型,因为存在待定更改并且自动迁移已禁用.将挂起的模型更改写入基于代码的迁移或启用自动迁移.将DbMigrationsConfiguration.AutomaticMigrationsEnabled设置为true以启用自动迁移.您可以使用Add-Migration命令将挂起的模型更改写入代码 - 基于迁移."
我不想用变化AutomaticMigrationEnabled来true,所以我跑Add-Migration Test看到的是被创造的.创建的文件包含已经应用(通过以前的迁移)到数据库的命令.如果我尝试运行上次迁移,Update-Database则会失败(类似"已存在列"或"表已存在",这是正确的错误消息,因为迁移具有重复的代码).
我怀疑问题与表格__migrationhistory保存在模型列上的值(迁移所应用的模型的二进制表示)有关 - 可能由于进行了手动校正,该值不是正确的值.
如何才能手动编辑迁移代码并使其正常工作?使用Entity Framework Code First迁移时的最佳做法是什么?
有没有办法让Spring Roo和JPA 2.0元模型生成器一起工作?
我有一个Spring Roo项目并使用Eclipse作为IDE.我能够在构建/编译过程中配置Eclipse项目和maven pom.xml以使用JPA 2.0元模型生成器.问题是,生成器不会为Roo实体生成元模型类(即,使用@Roo*注释进行注释的域类).
我"手动"创建了一个实体,并确认生成器已正确配置.我怀疑Roo实体的生成器失败,因为它不了解AspectJ IDT类.有没有办法让发电机为Roo实体工作?
哦,在我忘记之前,这些是我的配置:
hibernate-jpa-2.0-api-1.0.0.Final.jar和hibernate-jpamodelgen-1.1.0.Final.jarorg.hibernate:hibernate-jpamodelgen:1.1.0.Final为依赖项org.codehaus.mojo:build-helper-maven-plugin:1.5为包含src/generated/java为maven源文件夹org.bsc.maven:maven-processor-plugin为运行org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor并将生成的代码放置在src/generated/java如有必要,我可以提供更多细节.提前致谢.
我找不到使 @section 和 @RenderSection() 使用多级布局的方法。在我的项目中,我定义了布局的层次结构:
〜/ Views / Shared / _Layout.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta ... />
<meta ... />
<link href="..." rel="stylesheet" type="text/css" />
<link href="..." rel="stylesheet" type="text/css" />
@RenderSection("Stylesheet", false)
</head>
<body>
<!-- lots of markup -->
@RenderBody()
<!-- more markup -->
<script src="..." type="text/javascript" />
<script src="..." type="text/javascript" />
@RenderSection("JavaScript", false)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
~/Views/Shared/_BaseLayout.cshtml(没有 JavaScript 或样式表部分的定义):
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<!-- lots of markup -->
@RenderBody()
Run Code Online (Sandbox Code Playgroud)
~/Views/Shared/_CreateEditLayout.cshtml(同样,没有 JavaScript 或样式表的定义):
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<!-- …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Clojure的core.async库来消耗/处理文件中的行。当我的代码执行时,IOException: Stream closed抛出异常。下面是一个REPL会话,它重现了与我的代码相同的问题:
(require '[clojure.core.async :as async])
(require '[clojure.java.io :as io])
; my real code is a bit more involved with calls to drop, map, filter
; following line-seq
(def lines
(with-open [reader (io/reader "my-file.txt")]
(line-seq reader)))
(def ch
(let [c (async/chan)]
(async/go
(doseq [ln lines]
(async/>! c ln))
(async/close! c))
c))
; line that causes the error
; java.io.IOException: Stream closed
(async/<!! ch)
Run Code Online (Sandbox Code Playgroud)
由于这是我第一次做这样的事情(异步+文件),所以也许我对它应该如何工作有一些误解。有人可以澄清将文件行发送到通道管道的正确方法是什么吗?
谢谢!
clojure ×2
compojure ×1
core.async ×1
eclipse ×1
facebook ×1
file-upload ×1
interceptor ×1
java ×1
javascript ×1
jpa ×1
layout ×1
metamodel ×1
mysql ×1
parsing ×1
pdf ×1
pdfbox ×1
reactjs ×1
spring-roo ×1
struts2 ×1
tabular ×1