Ejemplo n.º 1
0
def save_selection_as_ps(context):
	seldoc = selection_as_document(context.document)
	if seldoc is not None:
		filename = get_ps_filename(context)
		if filename:
			bbox = seldoc.BoundingRect(visible = 0, printable = 1)
			ps_dev = PostScriptDevice(filename, as_eps = 1,
										bounding_box = tuple(bbox),
										document = seldoc)
			seldoc.Draw(ps_dev)
			ps_dev.Close()
    align_distance = 6
    align_length = 12
    grow = align_length + align_distance
    llx, lly, urx, ury = doc_bbox
    ps_bbox = (llx - grow, lly - grow, urx + grow, ury + grow)
    for color in colors:
        separator = CreateSeparation(color)
        try:
            # do this in a try-finall to make sure the document colors
            # get restored even if something goes wrong
            doc.WalkHierarchy(separator.change_color)
            filename = basename + '-' + hexcolor(color) + '.ps'
            ps_dev = PostScriptDevice(filename,
                                      as_eps=1,
                                      bounding_box=ps_bbox,
                                      For=system.get_real_username(),
                                      CreationDate=system.current_date(),
                                      Title=os.path.basename(filename),
                                      document=doc)
            doc.Draw(ps_dev)
            draw_alignment_marks(ps_dev, doc_bbox, align_length,
                                 align_distance)
            ps_dev.Close()
        finally:
            separator.undo_changes()


import app.Scripting
app.Scripting.AddFunction('simple_separation',
                          _("Simple Separation"),
                          simple_separation,
Ejemplo n.º 3
0
def make_ps(document):
    file = tempfile.mktemp('.ps')
    device = PostScriptDevice(file, as_eps=0, document=document)
    document.Draw(device)
    device.Close()
    return file