Class StampManager


  • public class StampManager
    extends Object
    Manager for stamp images
    Since:
    7.3
    Author:
    Marco Meschieri - LogicalDOC
    • Constructor Detail

      • StampManager

        public StampManager()
    • Method Detail

      • getStampBytes

        public byte[] getStampBytes​(long stampId)
                             throws Exception
        Retrieves the unencrypted stream of the stamp image
        Parameters:
        stampId - ID of the stamp
        Returns:
        content of the stamp
        Throws:
        Exception - a generic error
      • delete

        public void delete​(long stampId)
                    throws IOException
        Deletes the given stamp and all related resources
        Parameters:
        stampId - identifier of the stamp
        Throws:
        IOException - cannot delete the stamp file
      • applyStamp

        public void applyStamp​(long docId,
                               Stamp stamp,
                               com.logicaldoc.core.document.DocumentHistory transaction)
                        throws Exception
        Throws:
        Exception
      • applyStamp

        public void applyStamp​(long docId,
                               long stampId,
                               com.logicaldoc.core.document.DocumentHistory transaction)
                        throws Exception
        Throws:
        Exception
      • getPagesFromExpression

        public static Integer[] getPagesFromExpression​(String expression)
      • applyStampHTMLToPages

        public void applyStampHTMLToPages​(File stampedDocFile,
                                          Stamp stamp,
                                          com.logicaldoc.core.document.Document doc,
                                          com.logicaldoc.core.security.User user,
                                          Integer[] pages)
                                   throws IOException
        Throws:
        IOException
      • applyStampBarcodeToPages

        public void applyStampBarcodeToPages​(File stampedDocFile,
                                             Stamp stamp,
                                             com.logicaldoc.core.document.Document doc,
                                             com.logicaldoc.core.security.User user,
                                             Integer[] pages)
                                      throws IOException
        Throws:
        IOException
      • applyStampTextToPages

        public static void applyStampTextToPages​(File doc,
                                                 String exprX,
                                                 String exprY,
                                                 String exprW,
                                                 int rotation,
                                                 int opacity,
                                                 String text,
                                                 String color,
                                                 int fontSize,
                                                 String fontPath,
                                                 com.logicaldoc.core.document.Document document,
                                                 com.logicaldoc.core.security.User user,
                                                 Integer[] pages)
                                          throws IOException
        Draw a text to the specified coordinates onto a single page
        Parameters:
        doc - file of the document
        exprX - X coordinate on the page where the left bottom corner of the text should be located. Regard that 0 is the left bottom of the pdf page
        exprY - Y coordinate on the page where the left bottom corner of the text should be located
        exprW - Width of the text
        rotation - Rotation expressed in degrees
        opacity - Opacity (0=transparent 1=opaque)
        text - Text that is written to the PDF
        color - HTML color for the text
        fontSize - The font size
        fontPath - the path of the font's file(leave empty to use the system helvetica font)
        document - The pdf document representation
        pages - Array of pages numbers to process
        user - The current user
        Throws:
        IOException - error printing the stamp inside the file
      • processText

        public static String processText​(String text,
                                         com.logicaldoc.core.document.Document doc,
                                         com.logicaldoc.core.security.User user)
        Processes the text to be rendered using the automation. Available variables are:
        1. DATE
        2. TIMESTAMP
        3. CURRENT_DATE
        4. document
        5. extended attributes
        6. user
        Parameters:
        text - The expression to process(you can use the macros)
        doc - The document to process
        user - The current user
        Returns:
        The processed text
      • processExpression

        public static int processExpression​(String expression,
                                            long tenantId,
                                            int pageWidth,
                                            int pageHeight,
                                            int imageWidth,
                                            int imageHeight)
        Processes the expression for X or Y positioning. Available variables are:
        1. PAGE_WIDTH
        2. PAGE_HEIGHT
        3. PAGE_CENTER
        4. PAGE_MIDDLE
        5. IMAGE_WIDTH
        6. IMAGE_HEIGHT
        Parameters:
        expression - The expression to process(you can use the macros)
        tenantId - identifier of the tenant
        pageWidth - width of the page
        pageHeight - height of the page
        imageWidth - width of the image
        imageHeight - height of the image
        Returns:
        The coordinate
      • applyStampImageToPages

        public static void applyStampImageToPages​(long tenantId,
                                                  File doc,
                                                  String exprX,
                                                  String exprY,
                                                  String exprW,
                                                  String exprH,
                                                  int rotation,
                                                  int opacity,
                                                  File stamp,
                                                  Integer[] pages)
                                           throws IOException
        Draw an image to the specified coordinates onto a single page
        Parameters:
        tenantId - Identifier of the tenant
        doc - PDF file the image should be written to
        exprX - X coordinate on the page where the left bottom corner of the image should be located. Regard that 0 is the left bottom of the pdf page
        exprY - Y coordinate on the page where the left bottom corner of the image should be located.
        exprW - Optional width of the stamp
        exprH - Optional height of the stamp
        rotation - Rotation expressed in degrees
        opacity - Opacity (0=transparent 1=opaque)
        stamp - File path of the image that is written to the PDF
        pages - Array of pages numbers to process
        Throws:
        IOException - cannot apply the stamp inside the file
      • getStampsFolder

        public File getStampsFolder()
      • setStampsFolder

        public void setStampsFolder​(File stampsFolder)
      • getDocDao

        public com.logicaldoc.core.document.dao.DocumentDAO getDocDao()
      • setDocDao

        public void setDocDao​(com.logicaldoc.core.document.dao.DocumentDAO docDao)
      • getStampDao

        public StampDAO getStampDao()
      • setStampDao

        public void setStampDao​(StampDAO stampDao)
      • getStorer

        public com.logicaldoc.core.store.Storer getStorer()
      • setStorer

        public void setStorer​(com.logicaldoc.core.store.Storer storer)
      • getManager

        public com.logicaldoc.core.document.DocumentManager getManager()
      • setManager

        public void setManager​(com.logicaldoc.core.document.DocumentManager manager)
      • getConverterManager

        public com.logicaldoc.core.conversion.FormatConverterManager getConverterManager()
      • setConverterManager

        public void setConverterManager​(com.logicaldoc.core.conversion.FormatConverterManager converterManager)
      • setConfig

        public void setConfig​(com.logicaldoc.util.config.ContextProperties config)