当前位置: 首页>>代码示例>>Java>>正文


Java PdfConverter类代码示例

本文整理汇总了Java中org.apache.poi.xwpf.converter.pdf.PdfConverter的典型用法代码示例。如果您正苦于以下问题:Java PdfConverter类的具体用法?Java PdfConverter怎么用?Java PdfConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PdfConverter类属于org.apache.poi.xwpf.converter.pdf包,在下文中一共展示了PdfConverter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load docx with POI XWPFDocument
        XWPFDocument document = new XWPFDocument( Data.class.getResourceAsStream( "DocxBig.docx" ) );

        // 2) Convert POI XWPFDocument 2 PDF with iText
        File outFile = new File( "target/DocxBig.pdf" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        PdfOptions options = PdfOptions.create().fontEncoding( "windows-1250" );
        PdfConverter.getInstance().convert( document, out, options );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate DocxBig.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
开发者ID:DistX,项目名称:Learning,代码行数:25,代码来源:ConvertDocxBigToPDF.java

示例2: main

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load docx with POI XWPFDocument
        XWPFDocument document = new XWPFDocument( Data.class.getResourceAsStream( "DocxStructures.docx" ) );

        // 2) Convert POI XWPFDocument 2 PDF with iText
        File outFile = new File( "target/DocxStructures.pdf" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        PdfOptions options = null;// PDFViaITextOptions.create().fontEncoding( "windows-1250" );
        PdfConverter.getInstance().convert( document, out, options );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate DocxStructures.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
开发者ID:DistX,项目名称:Learning,代码行数:25,代码来源:ConvertDocxStructuresToPDF.java

示例3: main

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load docx with POI XWPFDocument
        XWPFDocument document = new XWPFDocument( Data.class.getResourceAsStream( "DocxLettreRelance.docx" ) );

        // 2) Convert POI XWPFDocument 2 PDF with iText
        File outFile = new File( "target/DocxLettreRelance.pdf" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        PdfOptions options = null;// PDFViaITextOptions.create().fontEncoding( "windows-1250" );
        PdfConverter.getInstance().convert( document, out, options );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate DocxLettreRelance.pdf with " + ( System.currentTimeMillis() - startTime )
        + " ms." );
}
 
开发者ID:DistX,项目名称:Learning,代码行数:26,代码来源:ConvertDocxLettreRelanceToPDF.java

示例4: convertPDF

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
@Override
public File convertPDF(File theFile, String md5UploadedFile) throws PDFConverterException {
	try {
		InputStream is = new FileInputStream(theFile);
		XWPFDocument document = new XWPFDocument(is);
		PdfOptions options = PdfOptions.create();
		String outFileName = this.getOutputFileName(md5UploadedFile);
		File outputFile = new File(Config.getString("application.staticFiles"), outFileName);
		FileOutputStream pdfStream = new FileOutputStream(outputFile);
		PdfConverter.getInstance().convert(document, pdfStream, options);
		pdfStream.close();
		return outputFile;
	} catch (Exception e) {
		log.error("Fail to create PDF in XDocReport Converter", e);
		throw new PDFConverterException("Fail to create PDF in XDocReport Converter", e);
	}
}
 
开发者ID:LeoFCardoso,项目名称:tudoToPDF,代码行数:18,代码来源:XDocReportConverter.java

示例5: main

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load docx with POI XWPFDocument
        XWPFDocument document = new XWPFDocument( Data.class.getResourceAsStream( "ooxml.docx" ) );

        // 2) Convert POI XWPFDocument 2 PDF with iText
        File outFile = new File( "target/ooxml.pdf" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        PdfOptions options = null;// PDFViaITextOptions.create().fontEncoding( "windows-1250" );
        PdfConverter.getInstance().convert( document, out, options );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate ooxml.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
开发者ID:DistX,项目名称:Learning,代码行数:25,代码来源:ConvertOoxmlToPDF.java

示例6: create

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
private static void create()
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load docx with POI XWPFDocument
        XWPFDocument document = new XWPFDocument( Data.class.getResourceAsStream( "DocxResume.docx" ) );

        // 2) Convert POI XWPFDocument 2 PDF with iText
        File outFile = new File( "target/DocxResume.pdf" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        PdfOptions options = null;// PDFViaITextOptions.create().fontEncoding( "windows-1250" );
        PdfConverter.getInstance().convert( document, out, options );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate DocxResume.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
开发者ID:DistX,项目名称:Learning,代码行数:25,代码来源:ConvertDocxResumeToPDF.java

示例7: getPDFByteArray

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
/**
 * Converts the document to a PDF-File and returns its Byte[]
 * 
 * @author Tim Kaler / Whitecoast Solutions AG 
 * @since 29.04.2015
 * @return the converted PDF file as byte array
 */
public byte[] getPDFByteArray(){
	try{
		PdfOptions options = PdfOptions.getDefault();

		ByteArrayOutputStream out = new ByteArrayOutputStream();
		PdfConverter.getInstance().convert(document, out, options);
		
		return out.toByteArray();
	}
	catch(Exception e){
		System.out.println("Error in getPDFByteArray: " + e.toString());
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:crash785,项目名称:PrintEngine,代码行数:23,代码来源:WordXHandler.java

示例8: toPdf

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
@Test
public final void toPdf() throws FileNotFoundException, IOException {
	File file = new File("C:\\Users\\KYJ\\Desktop\\학습\\Algorism.docx");
	XWPFDocument document = new XWPFDocument(new FileInputStream(file));

	File outFile = new File("Algorism.pdf");

	try (OutputStream out = new FileOutputStream(outFile)) {
		PdfOptions options = PdfOptions.getDefault();
		PdfConverter.getInstance().convert(document, out, options);
	}
	System.out.println("Sucess");


	FileUtil.openFile(outFile);


}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:19,代码来源:MSWordTest.java

示例9: convert

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
@Override
public void convert() throws Exception {
	loading();       
	

       XWPFDocument document = new XWPFDocument(inStream);

       PdfOptions options = PdfOptions.create();

       
       processing();
       PdfConverter.getInstance().convert(document, outStream, options);
       
       finished();
       
}
 
开发者ID:yeokm1,项目名称:docs-to-pdf-converter,代码行数:17,代码来源:DocxToPDFConverter.java

示例10: convert

import org.apache.poi.xwpf.converter.pdf.PdfConverter; //导入依赖的package包/类
/**
 * @작성자 : KYJ
 * @작성일 : 2017. 3. 3.
 * @param docxFile
 * @param outPdfFile
 * @throws FileNotFoundException
 * @throws IOException
 */
public static void convert(XWPFDocument document, File outPdfFile) throws FileNotFoundException, IOException {
	try (OutputStream out = new FileOutputStream(outPdfFile)) {
		PdfOptions options = PdfOptions.getDefault();
		PdfConverter.getInstance().convert(document, out, options);
	}
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:15,代码来源:PDFUtil.java


注:本文中的org.apache.poi.xwpf.converter.pdf.PdfConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。