コード例 #1
0
ファイル: PDFTypeInformation.py プロジェクト: jgpjuniorj/j
 def generateERP5FormCSS():
     parsed_scribus = self._getParsedScribusFile()
     import_pdf_file = StringIO.StringIO(
         self.getDefaultPdfFormValue().getData())
     pdf_parser = PDFParser(import_pdf_file)
     import_scribus_file = StringIO.StringIO(
         self.getDefaultScribusFormValue().getData())
     scribus_parser = ScribusParser(import_scribus_file)
     page_gap = scribus_parser.getPageGap()
     scribus_width = scribus_parser.getPageWidth()
     scribus_height = scribus_parser.getPageHeight()
     space_between_pages = 20  # XXX - hardcoded
     image0 = self.getERP5FormImage(0)
     properties_css_dict = getPropertiesCSSDict(
         parsed_scribus, page_gap, image0.getWidth(),
         image0.getHeight(), scribus_width, scribus_height,
         space_between_pages,
         self.getPortalObject().portal_preferences)
     # declaring object that holds the CSS data
     css_file_name = "%s_css.css" % self.getId().replace(' ', '')
     css_file_content = generateCSSOutputContent(properties_css_dict)
     css_file = DTMLDocument(css_file_content, __name__=css_file_name)
     import_scribus_file.close()
     import_pdf_file.close()
     return css_file
コード例 #2
0
ファイル: PDFTypeInformation.py プロジェクト: MarkTang/erp5
 def generateERP5FormCSS():
   parsed_scribus = self._getParsedScribusFile()
   import_pdf_file = StringIO.StringIO(self.getDefaultPdfFormValue().getData())
   pdf_parser = PDFParser(import_pdf_file)
   import_scribus_file = StringIO.StringIO(self.getDefaultScribusFormValue().getData())
   scribus_parser = ScribusParser(import_scribus_file)
   page_gap = scribus_parser.getPageGap()
   scribus_width = scribus_parser.getPageWidth()
   scribus_height = scribus_parser.getPageHeight()
   space_between_pages = 20 # XXX - hardcoded
   image0 = self.getERP5FormImage(0)
   properties_css_dict=getPropertiesCSSDict(parsed_scribus,
                                           page_gap,
                                           image0.getWidth(),
                                           image0.getHeight(),
                                           scribus_width,
                                           scribus_height,
                                           space_between_pages,
                                           self.getPortalObject().portal_preferences)
   # declaring object that holds the CSS data
   css_file_name = "%s_css.css" % self.getId().replace(' ','')
   css_file_content = generateCSSOutputContent(properties_css_dict)
   css_file = DTMLDocument(css_file_content, __name__ = css_file_name)
   import_scribus_file.close()
   import_pdf_file.close()
   return css_file
コード例 #3
0
ファイル: PDFTypeInformation.py プロジェクト: jgpjuniorj/j
 def getPDFForm(self):
     """
   Returns an PDF Form instance (stored in RAM)
 """
     if self.getDefaultScribusFormValue() is None:
         return
     portal_type_name = self.getId().replace(' ', '')
     pdf_form_name = '%s_view%sAsPdf' % (portal_type_name, portal_type_name)
     pdf_file = StringIO.StringIO(self.getDefaultPdfFormValue().getData())
     pdf_form = PDFForm(pdf_form_name, portal_type_name, pdf_file)
     pdf_form.manage_upload(pdf_file)
     import_scribus_file = StringIO.StringIO(
         self.getDefaultScribusFormValue().getData())
     scribus_parser = ScribusParser(import_scribus_file)
     erp5_properties = scribus_parser.getERP5PropertyDict()
     def_usePropertySheet = 0
     my_prefix = 'my_'
     prefix_len = len(my_prefix)
     pages = range(len(erp5_properties))
     for page in pages:
         page_content = erp5_properties[page]
         for cell_name, field_dict in page_content:
             # current object is PDF Form
             if cell_name[:prefix_len] == my_prefix:
                 cell_process_name_list = []
                 suffix = cell_name[prefix_len:].split('_')[-1]
                 # If properties field are filled in scribus, get Type form
                 # global_properties. Else, guess Type by suffix id (eg: List, Date,...)
                 list_field_type_list = (
                     'ListField',
                     'MultiListField',
                     'LinesField',
                 )
                 date_field_type_list = ('DateTimeField', )
                 suffix_mapping = {
                     'List': list_field_type_list,
                     'Date': date_field_type_list
                 }
                 field_type = field_dict.get(
                     'erp_type',
                     suffix_mapping.get(suffix, [''])[0])
                 if def_usePropertySheet:
                     # generating PropertySheet and Document, no need to use them to
                     # get field data
                     if field_type in list_field_type_list:
                         TALES = "python: %s " % ', '.join(
                             "here.get%s()" %
                             convertToUpperCase(cell_name[prefix_len:]))
                     elif field_type in date_field_type_list:
                         attributes_dict = field_dict['attributes']
                         # assign the property input_order
                         input_order = attributes_dict['input_order']
                         input_order = input_order.replace('y', 'Y')
                         # make the Tales according to the cases
                         date_pattern = '/'.join(
                             ['%%%s' % s for s in list(input_order)])
                         if not (attributes_dict['date_only']):
                             date_pattern += ' %H:%M'
                         TALES = "python: here.get%s() is not None and here.get%s().strftime('%s') or ''"\
                           % (convertToUpperCase(cell_name[prefix_len:]),
                             convertToUpperCase(cell_name[prefix_len:]),
                             date_pattern)
                     else:
                         TALES = "python: here.get%s()" %\
                                           convertToUpperCase(cell_name[prefix_len:])
                 else:
                     if field_type in list_field_type_list:
                         TALES = "python: %s" % ', '.join(
                             "here.getProperty('%s')" %
                             cell_name[prefix_len:])
                     elif field_type in date_field_type_list:
                         attributes_dict = field_dict['attributes']
                         # assign the property input_order
                         input_order = attributes_dict['input_order']
                         input_order = input_order.replace('y', 'Y')
                         # make the Tales according to the cases
                         date_pattern = '/'.join(
                             ['%%%s' % s for s in list(input_order)])
                         if not (attributes_dict['date_only']):
                             date_pattern += ' %H:%M'
                         TALES = "python: here.getProperty('%s') is not None and here.getProperty('%s').strftime('%s') or ''"\
                               % (cell_name[prefix_len:],
                                   cell_name[prefix_len:],
                                   date_pattern)
                     else:
                         TALES = "python: here.getProperty('%s')" % cell_name[
                             prefix_len:]
                 pdf_form.setCellTALES(cell_name, TALES)
     import_scribus_file.close()
     pdf_file.close()
     self.REQUEST.RESPONSE.setHeader('Content-Type', 'application/pdf')
     return pdf_form
コード例 #4
0
ファイル: PDFTypeInformation.py プロジェクト: jgpjuniorj/j
 def generateParsedScribus():
     import_scribus_file = StringIO.StringIO(scribus_form.getData())
     scribus_parser = ScribusParser(import_scribus_file)
     import_scribus_file.close()
     return scribus_parser.getERP5PropertyDict()
コード例 #5
0
ファイル: PDFTypeInformation.py プロジェクト: MarkTang/erp5
 def getPDFForm(self):
   """
     Returns an PDF Form instance (stored in RAM)
   """
   if self.getDefaultScribusFormValue() is None:
     return
   portal_type_name = self.getId().replace(' ','')
   pdf_form_name ='%s_view%sAsPdf' % (portal_type_name, portal_type_name)
   pdf_file = StringIO.StringIO(self.getDefaultPdfFormValue().getData())
   pdf_form = PDFForm(pdf_form_name, portal_type_name, pdf_file)
   pdf_form.manage_upload(pdf_file)
   import_scribus_file = StringIO.StringIO(self.getDefaultScribusFormValue().getData())
   scribus_parser = ScribusParser(import_scribus_file)
   erp5_properties = scribus_parser.getERP5PropertyDict()
   def_usePropertySheet = 0
   my_prefix = 'my_'
   prefix_len = len(my_prefix)
   pages = range(len(erp5_properties))
   for page in pages:
     page_content =  erp5_properties[page]
     for cell_name, field_dict in page_content:
     # current object is PDF Form
       if cell_name[:prefix_len] == my_prefix:
         cell_process_name_list = []
         suffix = cell_name[prefix_len:].split('_')[-1]
         # If properties field are filled in scribus, get Type form
         # global_properties. Else, guess Type by suffix id (eg: List, Date,...)
         list_field_type_list = ('ListField', 'MultiListField', 'LinesField',)
         date_field_type_list = ('DateTimeField',)
         suffix_mapping = {'List' : list_field_type_list,
                           'Date' : date_field_type_list}
         field_type = field_dict.get('erp_type', suffix_mapping.get(suffix, [''])[0])
         if def_usePropertySheet:
           # generating PropertySheet and Document, no need to use them to
           # get field data
           if field_type in list_field_type_list:
             TALES = "python: %s " % ', '.join(
             "here.get%s()" % convertToUpperCase(cell_name[prefix_len:]))
           elif field_type in date_field_type_list:
             attributes_dict = field_dict['attributes']
             # assign the property input_order
             input_order = attributes_dict['input_order']
             input_order = input_order.replace('y', 'Y')
             # make the Tales according to the cases
             date_pattern = '/'.join(['%%%s' % s for s in list(input_order)])
             if not(attributes_dict['date_only']):
               date_pattern += ' %H:%M'
             TALES = "python: here.get%s() is not None and here.get%s().strftime('%s') or ''"\
               % (convertToUpperCase(cell_name[prefix_len:]),
                 convertToUpperCase(cell_name[prefix_len:]),
                 date_pattern)
           else:
             TALES = "python: here.get%s()" %\
                               convertToUpperCase(cell_name[prefix_len:])
         else:
           if field_type in list_field_type_list:
             TALES = "python: %s" % ', '.join(
                   "here.getProperty('%s')" % cell_name[prefix_len:])
           elif field_type in date_field_type_list:
             attributes_dict = field_dict['attributes']
             # assign the property input_order
             input_order = attributes_dict['input_order']
             input_order = input_order.replace('y', 'Y')
             # make the Tales according to the cases
             date_pattern = '/'.join(['%%%s' % s for s in list(input_order)])
             if not(attributes_dict['date_only']):
               date_pattern += ' %H:%M'
             TALES = "python: here.getProperty('%s') is not None and here.getProperty('%s').strftime('%s') or ''"\
                   % (cell_name[prefix_len:],
                       cell_name[prefix_len:],
                       date_pattern)
           else:
             TALES = "python: here.getProperty('%s')" % cell_name[prefix_len:]
         pdf_form.setCellTALES(cell_name, TALES)
   import_scribus_file.close()
   pdf_file.close()
   self.REQUEST.RESPONSE.setHeader('Content-Type', 'application/pdf')
   return pdf_form
コード例 #6
0
ファイル: PDFTypeInformation.py プロジェクト: MarkTang/erp5
 def generateParsedScribus():
   import_scribus_file = StringIO.StringIO(scribus_form.getData())
   scribus_parser = ScribusParser(import_scribus_file)
   import_scribus_file.close()
   return scribus_parser.getERP5PropertyDict()