Jump to content

Export aller Bilder eines Reports in einen frei wählbaren Ordner


Recommended Posts

Hallo zusammen, im "alten" Forum existierte ein script, um alle Bilder eines Reports in einen frei wählbaren Ordner zu exportieren. Hat das noch jemand zur Hand?

Es ist sehr zeitaufwendig, jedes Bild einzeln zu exportieren.

Vielen Dank im Voraus.

This script will export all the images in your report pages to a directory you select

# -*- coding: utf-8 -*-

import os
import gom


dialog=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \
'<title>Export to folder:</title>' \
'<control id="OkCancel"/>' \
'<size height="100" width="200"/>' \
'<content columns="1" rows="1">' \
'<widget type="input::file" row="0" rowspan="1" column="0" columnspan="1">' \
'<name>folder</name>' \
'<type>directory</type>' \
'<title>choose folder:</title>' \
'<default></default>' \
'<limited>false</limited>' \
'<file_types/>' \
'<file_types_default></file_types_default>' \
'</widget>' \
'</content>' \
'</dialog>')


export_folder = dialog.folder.replace('/', os.sep)

for report in sorted(gom.app.project.reports):
	
	for element in report.pages[0].elements:
		
		if element.type == 'figure_snapshot_frame':
			
			i = 1
			
			while True:
				
				if os.path.exists(os.path.join(export_folder, '{} {}.png'.format(report.name, i))):
					
					i += 1
				else:
					
					break
			
			gom.script.report.export_report_image_as_png(images=element, file=os.path.join(export_folder, '{} {}.png'.format(report.name, i)), use_original_size=True, disable_transparency=True)

 

×
×
  • Create New...