'Set the page header caption and optional margin.
Args:
header:  Header string.
margin:  Header margin.
options: Header options, mainly for images.
Returns:
Nothing.'

def set_header(self, header='', options=None, margin=None):

    header_orig = header
    header = header.replace('&[Picture]', '&G')
    if (len(header) >= 255):
        warn('Header    string    must    be    less    than    255    characters')
        return
    if (options is not None):
        if (not isinstance(options, dict)):
            options = {'margin': options}
    else:
        options = {}
    if (margin is not None):
        options['margin'] = margin
    self.header_images = []
    if options.get('image_left'):
        self.header_images.append([options.get('image_left'), options.get('image_data_left'), 'LH'])
    if options.get('image_center'):
        self.header_images.append([options.get('image_center'), options.get('image_data_center'), 'CH'])
    if options.get('image_right'):
        self.header_images.append([options.get('image_right'), options.get('image_data_right'), 'RH'])
    placeholder_count = header.count('&G')
    image_count = len(self.header_images)
    if (placeholder_count != image_count):
        warn(("Number    of    header    images    (%s)    doesn't    match    placeholder    count    (%s)    in    string:    %s" % (image_count, placeholder_count, header_orig)))
        self.header_images = []
        return
    if ('align_with_margins' in options):
        self.header_footer_aligns = options['align_with_margins']
    if ('scale_with_doc' in options):
        self.header_footer_scales = options['scale_with_doc']
    self.header = header
    self.margin_header = options.get('margin', 0.3)
    self.header_footer_changed = True
    if image_count:
        self.has_header_vml = True
