org.odftoolkit.odfdom.doc.OdfTextDocument Java Examples

The following examples show how to use org.odftoolkit.odfdom.doc.OdfTextDocument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConvertODTStructuresToXHTML.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document = OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTStructures.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTStructures.htm" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        XHTMLConverter.getInstance().convert( document, out, null );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate ODTStructures.htm with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #2
Source File: ConvertODTResumeToXHTML.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document = OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTResume.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTResume.htm" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        XHTMLConverter.getInstance().convert( document, out, null );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate ODTResume.htm with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #3
Source File: ConvertODTBigToXHTML.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document = OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTBig.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTBig.htm" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        XHTMLConverter.getInstance().convert( document, out, null );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate ODTBig.htm with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #4
Source File: ConvertODTLettreRelanceToXHTML.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document =
            OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTLettreRelance.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTLettreRelance.htm" );
        outFile.getParentFile().mkdirs();

        OutputStream out = new FileOutputStream( outFile );
        XHTMLConverter.getInstance().convert( document, out, null );
    }
    catch ( Throwable e )
    {
        e.printStackTrace();
    }

    System.out.println( "Generate ODTLettreRelance.htm with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #5
Source File: ConvertODTLettreRelanceToPDF.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document =
            OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTLettreRelance.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTLettreRelance.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 ODTLettreRelance.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #6
Source File: ConvertODTResumeToPDF.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document = OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTResume.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTResume.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 ODTResume.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #7
Source File: ConvertODTBigToPDF.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document = OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTBig.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTBig.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 ODTBig.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #8
Source File: ConvertODTStructuresToPDF.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
{
    long startTime = System.currentTimeMillis();

    try
    {
        // 1) Load odt with ODFDOM
        OdfTextDocument document =
            OdfTextDocument.loadDocument( Data.class.getResourceAsStream( "ODTStructures.odt" ) );

        // 2) Convert ODFDOM OdfTextDocument 2 PDF with iText
        File outFile = new File( "target/ODTStructures.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 ODTStructures.pdf with " + ( System.currentTimeMillis() - startTime ) + " ms." );
}
 
Example #9
Source File: OOUtils.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate sample odt 
 */
public static void generateSample(int paragraphs, OutputStream os) throws Exception {
	LoremIpsum li = new LoremIpsum();
	OdfTextDocument odt = OdfTextDocument.newTextDocument();

	for (int i = 0; i < paragraphs; i++) {
		odt.newParagraph(li.getParagraphs());
		odt.newParagraph();
	}

	odt.save(os);
}
 
Example #10
Source File: OdtToPDF.java    From docs-to-pdf-converter with MIT License 4 votes vote down vote up
@Override
public void convert() throws Exception {
	loading();       


	OdfTextDocument document = OdfTextDocument.loadDocument(inStream);

	PdfOptions options = PdfOptions.create();

	
	processing();
	PdfConverter.getInstance().convert(document, outStream, options);

	finished();


}