`
sillycat
  • 浏览: 2555254 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Transfer Doc to Pdf on Ubuntu System

阅读更多
Transfer Doc to Pdf on Ubuntu System

1. Command
Using command line to transfer doc to pdf
>unoconv -f pdf sprint9_Additional_Information.doc

When I am executing this command with none-root user. I got this error messages:
Error: Unable to connect or start own listener. Aborting.

So, I su to root user, it is ok. It is said that it can also transfer other formats. But I do not have
chance to have a try.
unoconv -f doc other-document.odt
unoconv -f jpg some-image.png
unoconv -f xsl some-spreadsheet.csv

We can use command to see all the supporting format.
>unoconv --show

2. Start the openoffice service and execute in Java class
start the service
>soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

we can get the opensource jar packages here
http://www.artofsolving.com/opensource/jodconverter
http://sourceforge.net/projects/jodconverter/files/

The Java class will be as follow:
package com.chinacreator.test;



import java.io.File;

import java.net.ConnectException;



import com.artofsolving.jodconverter.DocumentConverter;

import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;

import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;

import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;



public class JOD4DocToPDF {



public void docToPdf(File inputFile, File outputFile) {

long start = System.currentTimeMillis();

// connect to an OpenOffice.org instance running on port 8100

OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);

try {

connection.connect();

DocumentConverter converter = new OpenOfficeDocumentConverter(

connection);

converter.convert(inputFile, outputFile);

} catch (ConnectException e) {

e.printStackTrace();

} finally {

// close the connection

if (connection != null) {

connection.disconnect();

connection = null;

}

}

long end = System.currentTimeMillis();

System.out.println("converted from " + inputFile.getName() + " to "

+ outputFile.getName() + " time:" + (end - start) + " ms.");

}



class TestThread extends java.lang.Thread {

public File inputFile;

public File outputFile;



public void run() {

JOD4DocToPDF job = new JOD4DocToPDF();

job.docToPdf(inputFile, outputFile);

System.out.println(outputFile.getName() + " converting start.");

}

}



public void test() {

TestThread t1 = new TestThread();

t1.inputFile = new File("/var/tmp/c1.doc");

t1.outputFile = new File("/var/tmp/c1.pdf");



TestThread t2 = new TestThread();

t2.inputFile = new File("/var/tmp/c2.doc");

t2.outputFile = new File("/var/tmp/c2.pdf");



t2.start();

t1.start();

}



public static void main(String[] args) throws Exception {

JOD4DocToPDF p = new JOD4DocToPDF();

p.test();

}

}

There is some problem on ubuntu, maybe it is right on windows.

references:
http://ubuntuwriter.blogspot.com/2008/12/pdf.html
http://www.iteye.com/topic/352103
分享到:
评论
1 楼 jhlovesky 2012-05-09  
Lz...我在转化的时候出现如下错误:
命令:

unoconv -f pdf -p 2000  -o /opt/a.pdf  /opt/b.doc

错误信息:


Failed to connect to /opt/openoffice.org3/program/soffice.bin (pid=10757) in 6 seconds.

Connector : couldn't connect to socket (Success)

Error: Unable to connect or start own listener. Aborting.


什么弄?

相关推荐

    word will transfer doc into PDF doc,

    标题中的“word will transfer doc into PDF doc”表明我们要讨论的是Word文档转换成PDF文档的过程。在IT领域,这种转换是常见的需求,因为不同的文件格式在兼容性、打印效果和安全性方面各有优势。Word(.doc或....

    A Comprehensive Survey on Transfer Learning.pdf

    Abstract—Transfer learning aims at improving the performance of target learners on target domains by transferring the knowledge contained in different but related source domains. In this way, the ...

    A survey on transfer learniing.pdf

    迁移学习综述文章,香港科技大学杨强写的对迁移学习的历史、分类、遇到的挑战都做了很详尽的解释,值得细读

    An introduction to domain adaptation and transfer learning.pdf

    迁移学习(Transfer Learning)是机器学习的一个子领域,它指的是将从一个领域(通常是源域)学到的知识应用到另一个领域(通常是目标域)。迁移学习特别适用于目标域的训练样本数量较少的情况,它旨在通过迁移知识...

    wireless power transfer system无线电能传输系统

    ZHEN NING LOW的博士论文《High efficiency loosely coupled wireless power transfer system via magnetic induction》深入探讨了基于磁感应的高效松耦合无线电力传输系统的设计与优化。 #### 论文概述 该论文...

    Hands-On Transfer Learning with Python

    firstly, we focus on detailed coverage of deep learning (DL) and transfer learning, comparing and contrasting the two with easy-to-follow concepts and examples. The second area of focus is real-world...

    (原文+译文)A Survey on Transfer Learning_Pan and Yang_2010.pdf

    A Survey on Transfer Learning迁移学习综述,香港科技大学杨强教授团队于2010年10月发表在IEEE Transactions on Knowledge and Data Engineering, VOL.22, NO.10 关键词:迁移学习;综述;机器学习;数据挖掘 1....

    A Survey on Transfer Learning_withMarginNotes.pdf

    A Survey on Transfer Learning_withMarginNotes.pdf

    Introduction to MTP Media Transfer Protocol.pdf

    《Introduction to MTP: Media Transfer Protocol》由Steve Kolokowsky和Trevor Davis撰写,该文档介绍了MTP(Media Transfer Protocol)媒体传输协议的相关概念和技术细节。随着数字音频和视频内容的普及,如何在...

    一个很实用的,可以把word转pdf的工具-A very useful tool for pdf to word transfer

    在IT行业中,转换文档格式是一项常见的任务,尤其是在处理Word文档(.doc或.docx)与PDF文件之间。本文将深入探讨“Word转PDF”的过程,以及如何利用工具进行高效的转换。 首先,理解Word文档和PDF文件的区别至关...

    Heat_Transfer__Teapot.pdf

    在给定文件《Heat_Transfer__Teapot.pdf》中,以一个茶壶为研究对象,利用ABAQUS软件进行热分析,涵盖了热传导、热对流和热辐射三种传热方式。接下来,将详细解释这些传热方式,并说明在ABAQUS软件中的建模过程。 ...

    Learning_to_Transfer.pdf

    迁移学习需要解决的核心问题包括:1)决定迁移什么(what to transfer),即确定从源领域到目标领域传递的知识类型;2)决定如何迁移(how to transfer),即选择合适的迁移学习算法来传递知识。 3. 现有迁移学习...

    Heat and Mass Transfer.PDF

    Heat and Mass Transfer 传热传质的英文论文

    Hands On Transfer Learning with Py Implement Advanced DL and NN Models Using T,K

    firstly, we focus on detailed coverage of deep learning (DL) and transfer learning, comparing and contrasting the two with easy-to-follow concepts and examples. The second area of focus is real-world...

    Person Transfer GAN to Bridge Domain Gap for Person Re-Identification论文代码

    这是CVPR2018论文Person Transfer GAN to Bridge Domain Gap for Person Re-Identification的代码,是用python书写的,内含模型,主要模块,实验结果等。

    Hands On Transfer Learning with Python

    《Hands On Transfer Learning with Python》是一本专注于使用Python语言实现高级深度学习和神经网络模型的实用手册,以TensorFlow和Keras作为主要的深度学习库进行实践。该书内容涵盖了迁移学习的应用,旨在帮助...

    A Survey on Transfer Learnin Sinno Jialin Pan and Qiang Yang pdf

    《迁移学习:一份综述》是由辛诺·贾林·潘(Sinno Jialin Pan)和杨强(Qiang Yang)共同撰写的学术论文,该文深入探讨了迁移学习这一重要的人工智能领域。迁移学习是机器学习的一个分支,其核心思想是利用已在一个...

    麻省理工传热学教材:A Heat Transfer.pdf

    ### 麻省理工传热学教材:A Heat Transfer.pdf #### 重要知识点解析 **一、教材概览** 《A Heat Transfer Textbook》是由John H. Lienhard IV与John H. Lienhard V共同编写的第三版传热学教材。该书由Phlogiston ...

    AndroidFileTransfer.dmg

    Drag Android File Transfer to Applications. Use the USB cable that came with your Android device and connect it to your Mac. Double click Android File Transfer. Browse the files and folders on your ...

Global site tag (gtag.js) - Google Analytics