def load(self, filename, da): # Check if file exists if not os.path.isfile(filename): print_to_console("\nFile \"%s\" not found." % filename ) else: # Make working copy of PDF so it stays available h, self.pdftmp = tempfile.mkstemp() shutil.copy(filename, self.pdftmp) os.close(h) print_to_console("\nLoading image: \"%s\"" % filename) self.bbox = ghostscript.get_bbox(self.pdftmp) #pdf = pyPdf.PdfFileReader(file(self.pdftmp)) #self.mbox = pdf.getPage(0).mediaBox #print self.mbox #pwidth = float(self.mbox[2] - self.mbox[0]) / 72.0 * 25.4 #pheight = float(self.mbox[3] - self.mbox[1]) / 72.0 * 25.4 #print_to_console("\nImage size: %.2f mm x %.2f mm" % (pwidth, pheight)) Gtk.Widget.queue_draw(da)
output[px // 8] = output[px // 8] | (128 >> (px % 8)) return output bbox = None if args.bbox: try: bbox = [ float(s) for s in args.bbox.split(",")] if not len(bbox) == 4: raise ValueError except ValueError: print "Bounding box format: <x0>,<y0>,<x1>,<y1>" sys.exit(1) if bbox == None: bbox = ghostscript.get_bbox(args.fname) if args.n_scans: n_scans = int(args.n_scans) else: n_scans = 84 if args.left_margin: left_margin = float(args.left_margin) else: left_margin = 5. right_margin = 0. top_margin = 0. bottom_margin = 0.
return output bbox = None if args.bbox: try: bbox = [float(s) for s in args.bbox.split(",")] if not len(bbox) == 4: raise ValueError except ValueError: print "Bounding box format: <x0>,<y0>,<x1>,<y1>" sys.exit(1) if bbox == None: bbox = ghostscript.get_bbox(args.fname) if args.n_scans: n_scans = int(args.n_scans) else: n_scans = 84 if args.left_margin: left_margin = float(args.left_margin) else: left_margin = 5. right_margin = 0. top_margin = 0. bottom_margin = 0.