我目前正在使用apache poi工作Java项目.现在,在我的项目中,我想将doc文件转换为pdf文件.转换成功完成但我只获得pdf中的文本而不是任何文本样式或文本颜色.我的pdf文件看起来像黑白.虽然我的doc文件是彩色的,并且具有不同的文本样式.
这是我的代码,
POIFSFileSystem fs = null;
Document document = new Document();
try {
System.out.println("Starting the test");
fs = new POIFSFileSystem(new FileInputStream("/document/test2.doc"));
HWPFDocument doc = new HWPFDocument(fs);
WordExtractor we = new WordExtractor(doc);
OutputStream file = new FileOutputStream(new File("/document/test.pdf"));
PdfWriter writer = PdfWriter.getInstance(document, file);
Range range = doc.getRange();
document.open();
writer.setPageEmpty(true);
document.newPage();
writer.setPageEmpty(true);
String[] paragraphs = we.getParagraphText();
for (int i = 0; i < paragraphs.length; i++) {
org.apache.poi.hwpf.usermodel.Paragraph pr = range.getParagraph(i);
// CharacterRun run = pr.getCharacterRun(i);
// run.setBold(true);
// run.setCapitalized(true);
// run.setItalic(true); …Run Code Online (Sandbox Code Playgroud) 是否有关于 Postgresql 每秒可以执行的最大事务数的详细记录(事务(开始-----结束)
谢谢,
我试图从谷歌阅读器api中检索一个选定的项目.是否有我可以通过ID获取项目的api调用,或者我是否必须访问该项目Feed并从那里获取它?
在jQuery中有一个beforeScroll事件吗?或者可以复制这种类型的事件?
我们有一个场景,我们需要在带溢出的div之前执行一个事件:滚动滚动.使用.scroll事件的问题是,在div滚动之后而不是之前引发了这个问题.
我有一个asp.net/C#应用程序,它使用subversion进行源代码控制.
我的应用程序会自动增加每个构建的AssembleVersion和AssemblyFileVersion,它就像魅力一样,并在站点的管理端显示构建号.
我们在部署时会跟踪AssembleVersion和AssemblyFileVersion,但是,当出现问题并且我们需要回滚到某个版本时,我们不知道在subversion中要定位哪个版本.
我的想法很少:
任何帮助和建议将不胜感激
更新: 选项"1"实际上是一个愚蠢的想法,因为这意味着每次构建时,所有文件都将被标记为已更新,当我提交时,每个文件都将被更新
我有一个域模型类型。它的众多属性之一需要 ITranslationService 来提供将其返回值转换为适当语言的能力。
我是否应该将 ITranslationService 注入域模型类型的构造函数中(因此必须在实例化类型的任何地方进行更改,并且在通过 NhIbernate 检索时必须关注初始化),即使它被类型的一小部分使用(一个许多属性);或者我可以使用另一种功能模式吗?
有没有人有相关的经验可以分享?
我很难理解unionC中的使用.我在这里读了很多关于这个主题的帖子.但是,union当使用结构可以实现同样的事情时,他们都没有解释为什么是首选.
引用K&R
作为可能在编译器符号表管理器中找到的示例,假设常量可以是int,float或字符指针.特定常量的值必须存储在适当类型的变量中,但如果值占用相同的存储量并且存储在同一位置(无论其类型如何),则最方便表管理.这是一个联合的目的,一个变量可以合法地保存几种类型中的任何一种.语法基于结构:
union u_tag {
int ival;
float fval;
char *sval;
} u;
Run Code Online (Sandbox Code Playgroud)
用法将是
if (utype == INT)
printf("%d\n", u.ival);
if (utype == FLOAT)
printf("%f\n", u.fval);
if (utype == STRING)
printf("%s\n", u.sval);
else
printf("bad type %d in utype\n", utype);
Run Code Online (Sandbox Code Playgroud)
使用结构可以实现相同的功能.就像是,
struct u_tag {
utype_t utype;
int ival;
float fval;
char *sval;
} u;
if (u.utype == INT)
printf("%d\n", u.ival);
if (u.utype == FLOAT)
printf("%f\n", u.fval);
if (u.utype == STRING)
printf("%s\n", u.sval);
else
printf("bad type %d …Run Code Online (Sandbox Code Playgroud) 我正在定制一个.csproj项目,在主构建之前运行一些自定义任务.但是,我根本无法执行任务.
我取消注释文件中的<Target Name="BeforeBuild" />元素.csproj并添加了一个简单的Message任务,但是当我构建时,消息没有出现在我的输出中,所以看起来任务没有运行.所以这个片段不输出消息;
清单1:没有消息出现
<Target Name="BeforeBuild">
<Message Text="About to build ORM layer" Importance="normal" />
</Target>
Run Code Online (Sandbox Code Playgroud)
但是,如果我搞砸了一些属性,我可能会.csproj完全无法执行;
清单2:MSBuild配置错误
<Target Name="BeforeBuild">
<Message Text="About to build ORM layer" XXImportance="normal" />
</Target>
Run Code Online (Sandbox Code Playgroud)
注意XXImportance属性.我得到的构建错误是
My.csproj(83,46): error MSB4064: The "XXImportance" parameter is not supported by the "Message" task. Verify the parameter exists on the task, and it is a settable public instance property.
Run Code Online (Sandbox Code Playgroud)
这表明正在解析XML,Message已找到该类,并且该类正在反映可用属性.
为什么这个任务不会执行?
我正在使用3.5框架.
更新1:在@Martin的建议下,我试图在控制台上运行MSBuild,并得到了这个错误;
c:\path\to\my.csproj(74,11): error MSB4019: The imported …Run Code Online (Sandbox Code Playgroud)