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 thumbnailIndex)
059                    throws Exception {
060    
061                    return getPDFProcessor().getThumbnailAsStream(
062                            fileVersion, thumbnailIndex);
063            }
064    
065            public static long getThumbnailFileSize(
066                            FileVersion fileVersion, int thumbnailIndex)
067                    throws Exception {
068    
069                    return getPDFProcessor().getThumbnailFileSize(
070                            fileVersion, thumbnailIndex);
071            }
072    
073            public static boolean hasImages(FileVersion fileVersion) {
074                    return getPDFProcessor().hasImages(fileVersion);
075            }
076    
077            public static boolean isDocumentSupported(FileVersion fileVersion) {
078                    return getPDFProcessor().isDocumentSupported(fileVersion);
079            }
080    
081            public static boolean isDocumentSupported(String mimeType) {
082                    return getPDFProcessor().isDocumentSupported(mimeType);
083            }
084    
085            public static boolean isImageMagickEnabled() throws Exception {
086                    return getPDFProcessor().isImageMagickEnabled();
087            }
088    
089            public static boolean isSupported(String mimeType) {
090                    return getPDFProcessor().isSupported(mimeType);
091            }
092    
093            public static void reset() throws Exception {
094                    getPDFProcessor().reset();
095            }
096    
097            public static void trigger(FileVersion fileVersion) {
098                    getPDFProcessor().trigger(fileVersion);
099            }
100    
101            public void setPDFProcessor(PDFProcessor pdfProcessor) {
102                    _pdfProcessor = pdfProcessor;
103            }
104    
105            private static PDFProcessor _pdfProcessor;
106    
107    }