##############################################################################
#
# Copyright (c) 2002 Ingeniweb SARL
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################

"""
AttachmentField product
"""

import AttachmentHandler

import os
import os.path
import string
import re
import sys


if sys.platform == "win32":
    program = "pdftotext.exe"
else:
    program = "pdftotext"


class PDFAttachment(AttachmentHandler.AbstractHandler):
    """
    PDF attachment file abstraction
    """
    icon_file = "pdf.gif"
    small_icon_file = "pdf_small.gif"
    content_types = ('application/pdf', )
    converter_type = "PDF"

    index_path = program
    index_arguments = r"%s -enc UTF-8 -"
    index_encoding = "utf8"
    
    preview_path = program
    preview_arguments = r"%s -enc UTF-8 -layout -"
    preview_format = "text"
    preview_encoding = "utf8"


AttachmentHandler.registerHandler(PDFAttachment)
