| 
					
				 | 
			
			
				@@ -194,16 +194,15 @@ class Convert(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return False 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	def command(self, info): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		File.mkdir(info['path']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		convert = 'cd ' + info['path'] + ' && ' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if info['ext'] != '.pdf': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if 'pdf' not in info['ext']: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			#convert = convert + 'libreoffice  --invisible --convert-to pdf ' + info['local'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			convert = convert + 'soffice --headless --invisible --convert-to pdf ' + info['local'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			convert = convert + ' && ' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			info['pdf'] = info['local'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		convert = convert + 'pdf2htmlEX --zoom 1 --use-cropbox 0 --no-drm 1 --split-pages 1 ' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		convert = convert + 'pdf2htmlEX --zoom 1 --hdpi 100 --vdpi 100 --use-cropbox 0 --no-drm 1 --split-pages 1 ' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		convert = convert + '--embed-css 0  --embed-javascript 0 --embed-image 0 --embed-font 1 --process-outline 0 ' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		convert = convert + '--embed-external-font 0 --dest-dir '+info['path']+' --page-filename %d.page ' + info['pdf'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -244,12 +243,25 @@ class Convert(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if not File.exists(info['html']): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			#if info: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				File.mkdir(info['path']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if 'txt' in info['ext']: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					import chardet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					file_path = info['local'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					with open(file_path, 'rb') as fp: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						file_data = fp.read() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						result = chardet.detect(file_data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						fp.close() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if result['encoding'] != 'utf-8': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							file_content = file_data.decode(result['encoding']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							f = open(file_path, 'w') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							f.write(file_content) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							f.close() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				handle = self.command(info) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				Shell.popen(handle) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if File.exists(info['html']): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					# 截屏 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					self.cut(info) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					# 处理图片 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					self.pic(info) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					#self.string_switch(info['html'], "taste", "tasting") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					# 获取有多少页 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					page = self.total(info['path']) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -301,9 +313,22 @@ class Convert(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Demeter.curl(api, param, 'post') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	def cut(self, info): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	def pic(self, info): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		from pdf2jpg import pdf2jpg 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		from wand.image import Image 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		width = 800 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		# 对生成的图片进行缩放 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		files = File.getFiles(info['path']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if files: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for file in files: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if 'jpg' in file or 'png' in file: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					file = info['path'] + file 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					with Image(filename=file) as img: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						target_width, target_height = self.getSize(width, img.width, img.height) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						img.sample(target_width, target_height) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						img.save(filename=file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		# 生成图片 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		dest = info['html'] + '.photo' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		result = pdf2jpg.convert_pdf2jpg(info['pdf'], dest, pages="0,1") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -316,9 +341,9 @@ class Convert(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				dest = info['html'] + '.jpg_' + i + '.jpg' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			command = 'mv '+source+' ' + dest 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Shell.popen(command) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			target_width = 300 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			with Image(filename=dest) as img: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				target_width, target_height = self.getSize(target_width, img.width, img.height) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				target_width, target_height = self.getSize(width, img.width, img.height) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				img.sample(target_width, target_height) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				img.save(filename=dest) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			i = i+1 
			 |