001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.util;
016    
017    import com.liferay.portal.kernel.repository.model.FileVersion;
018    
019    import java.io.InputStream;
020    
021    /**
022     * @author Sergio González
023     */
024    public class PDFProcessorUtil {
025    
026            public static void generateImages(FileVersion fileVersion)
027                    throws Exception {
028    
029                    getPDFProcessor().generateImages(fileVersion);
030            }
031    
032            public static String getGlobalSearchPath() throws Exception {
033                    return getPDFProcessor().getGlobalSearchPath();
034            }
035    
036            public static PDFProcessor getPDFProcessor() {
037                    return _pdfProcessor;
038            }
039    
040            public static InputStream getPreviewAsStream(
041                            FileVersion fileVersion, int index)
042                    throws Exception {
043    
044                    return getPDFProcessor().getPreviewAsStream(fileVersion, index);
045            }
046    
047            public static int getPreviewFileCount(FileVersion fileVersion) {
048                    return getPDFProcessor().getPreviewFileCount(fileVersion);
049            }
050    
051            public static long getPreviewFileSize(FileVersion fileVersion, int index)
052                    throws Exception {
053    
054                    return getPDFProcessor().getPreviewFileSize(fileVersion, index);
055            }
056    
057            public static InputStream getThumbnailAsStream(
058                            FileVersion fileVersion, int index)
059                    throws Exception {
060    
061                    return getPDFProcessor().getThumbnailAsStream(fileVersion, index);
062            }
063    
064            public static long getThumbnailFileSize(FileVersion fileVersion, int index)
065                    throws Exception {
066    
067                    return getPDFProcessor().getThumbnailFileSize(fileVersion, index);
068            }
069    
070            public static boolean hasImages(FileVersion fileVersion) {
071                    return getPDFProcessor().hasImages(fileVersion);
072            }
073    
074            public static boolean isDocumentSupported(FileVersion fileVersion) {
075                    return getPDFProcessor().isDocumentSupported(fileVersion);
076            }
077    
078            public static boolean isDocumentSupported(String mimeType) {
079                    return getPDFProcessor().isDocumentSupported(mimeType);
080            }
081    
082            public static boolean isImageMagickEnabled() throws Exception {
083                    return getPDFProcessor().isImageMagickEnabled();
084            }
085    
086            public static boolean isSupported(String mimeType) {
087                    return getPDFProcessor().isSupported(mimeType);
088            }
089    
090            public static void reset() throws Exception {
091                    getPDFProcessor().reset();
092            }
093    
094            public static void trigger(FileVersion fileVersion) {
095                    getPDFProcessor().trigger(fileVersion);
096            }
097    
098            public void setPDFProcessor(PDFProcessor pdfProcessor) {
099                    _pdfProcessor = pdfProcessor;
100            }
101    
102            private static PDFProcessor _pdfProcessor;
103    
104    }