diff --git a/config/alfresco/content-services-context.xml b/config/alfresco/content-services-context.xml
index 16fa94920e..24a34ba4ac 100644
--- a/config/alfresco/content-services-context.xml
+++ b/config/alfresco/content-services-context.xml
@@ -204,6 +204,59 @@
+
+
+
+
+
+
+
+
+ application/pdf
+ image/jpeg
+
+
+ application/pdf
+ image/png
+
+
+ application/pdf
+ image/gif
+
+
+
+
+
+
+
+
+
+
+
+ image/png
+
+
+
+
+
+
+
+
+
+
+
+
+
+ application/pdf
+
+
+
PNG
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ protected void transformInternal(
+ ContentReader reader,
+ ContentWriter writer,
+ TransformationOptions options) throws Exception
+ {
+ RandomAccessFile raf;
+ try
+ {
+ File file = TempFileProvider.createTempFile("pdfToImage", ".pdf");
+ reader.getContent(file);
+
+ raf = new RandomAccessFile(file, "r");
+ FileChannel channel = raf.getChannel();
+
+ ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
+
+ PDFFile pdffile = new PDFFile(buf);
+ PDFPage page = pdffile.getPage(0);
+
+ //get the width and height for the doc at the default zoom
+ int width=(int)page.getBBox().getWidth();
+ int height=(int)page.getBBox().getHeight();
+
+ Rectangle rect = new Rectangle(0,0,width,height);
+ int rotation=page.getRotation();
+ Rectangle rect1=rect;
+ if (rotation==90 || rotation==270)
+ rect1=new Rectangle(0,0,rect.height,rect.width);
+
+ //generate the image
+ BufferedImage img = (BufferedImage)page.getImage(
+ rect.width, rect.height, //width & height
+ rect1, // clip rect
+ null, // null for the ImageObserver
+ true, // fill background with white
+ true // block until drawing is done
+ );
+
+ File outputFile = TempFileProvider.createTempFile("pdfToImageOutput", ".png");
+ ImageIO.write(img, "png", outputFile);
+
+ writer.putContent(outputFile);
+ }
+ catch (FileNotFoundException e1)
+ {
+ throw new AlfrescoRuntimeException("Unable to create image from pdf file.", e1);
+ }
+ catch (IOException e)
+ {
+ throw new AlfrescoRuntimeException("Unable to create image from pdf file.", e);
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/thumbnail/CreateThumbnailActionExecuter.java b/source/java/org/alfresco/repo/thumbnail/CreateThumbnailActionExecuter.java
index 0ce9795362..f8a72ccf5f 100644
--- a/source/java/org/alfresco/repo/thumbnail/CreateThumbnailActionExecuter.java
+++ b/source/java/org/alfresco/repo/thumbnail/CreateThumbnailActionExecuter.java
@@ -30,6 +30,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
+import org.alfresco.repo.node.NodeRefPropertyMethodInterceptor;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -37,6 +38,8 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
import org.alfresco.service.namespace.QName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Create thumbnail action executer.
@@ -47,6 +50,8 @@ import org.alfresco.service.namespace.QName;
*/
public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
{
+ private static Log logger = LogFactory.getLog(CreateThumbnailActionExecuter.class);
+
/** Thumbnail Service */
private ThumbnailService thumbnailService;
@@ -105,8 +110,15 @@ public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
contentProperty = ContentModel.PROP_CONTENT;
}
- // Create the thumbnail
- this.thumbnailService.createThumbnail(actionedUponNodeRef, contentProperty, details.getMimetype(), details.getTransformationOptions(), thumbnailName, null);
+ try
+ {
+ // Create the thumbnail
+ this.thumbnailService.createThumbnail(actionedUponNodeRef, contentProperty, details.getMimetype(), details.getTransformationOptions(), thumbnailName, null);
+ }
+ catch (Exception exception)
+ {
+ logger.info("Creation of thumbnail '" + details.getName() + "' failed");
+ }
}
}