edit
This commit is contained in:
@@ -195,6 +195,11 @@
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.luhuiguo</groupId>
|
||||
<artifactId>aspose-pdf</artifactId>
|
||||
<version>23.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.singularsys</groupId>
|
||||
<artifactId>jep</artifactId>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package lingtao.net.util;
|
||||
|
||||
import com.aspose.pdf.Document;
|
||||
import com.aspose.pdf.optimization.OptimizationOptions;
|
||||
import lingtao.net.bean.Product;
|
||||
|
||||
import java.io.File;
|
||||
@@ -390,34 +392,30 @@ public class AStickersPrice {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String path = "Z:\\设计文件共享中心\\已下单\\2019\\1月\\年后出货\\不干胶\\dy\\已拼";
|
||||
Path startPath = Paths.get(path);
|
||||
try {
|
||||
Files.walk(startPath).filter(Files::isRegularFile).forEach(System.out::println);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String source = "C:\\Users\\231010\\Downloads\\蓝朝旺.pdf";
|
||||
String target = "C:\\Users\\231010\\Downloads\\蓝朝旺1.pdf";
|
||||
optimize(source, target);
|
||||
}
|
||||
|
||||
public static String midStrEx(String source, String startStr, String endStr) {
|
||||
String result = "";
|
||||
int startIndex, endIndex;
|
||||
try {
|
||||
startIndex = source.indexOf(startStr);
|
||||
if (startIndex == -1) {
|
||||
|
||||
return result;
|
||||
}
|
||||
String tmpStr = source.substring(startIndex + startStr.length());
|
||||
endIndex = tmpStr.indexOf(endStr);
|
||||
if (endIndex == -1) {
|
||||
return result;
|
||||
}
|
||||
result = tmpStr.substring(0, endIndex);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("MidStrEx Err: " + ex.getMessage());
|
||||
}
|
||||
return result;
|
||||
public static void optimize(String source, String target) {
|
||||
Document doc = new Document(source);
|
||||
//设置压缩属性
|
||||
OptimizationOptions opt = new OptimizationOptions();
|
||||
//删除PDF不必要的对象
|
||||
opt.setRemoveUnusedObjects(true);
|
||||
//链接重复流
|
||||
opt.setLinkDuplcateStreams(false);
|
||||
//删除未使用的流
|
||||
opt.setRemoveUnusedStreams(false);
|
||||
//删除不必要的字体
|
||||
opt.setUnembedFonts(true);
|
||||
//压缩PDF中的图片
|
||||
opt.getImageCompressionOptions().setCompressImages(true);
|
||||
//图片压缩比, 0 到100可选,越低压缩比越大
|
||||
opt.getImageCompressionOptions().setImageQuality(100);
|
||||
doc.optimizeResources(opt);
|
||||
//优化web的PDF文档
|
||||
doc.optimize();
|
||||
doc.save(target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package lingtao.net.util;
|
||||
|
||||
import com.aspose.pdf.Document;
|
||||
import com.aspose.pdf.optimization.OptimizationOptions;
|
||||
import lingtao.net.bean.Product;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -73,7 +75,7 @@ public class ZsPrice {
|
||||
if (dto.getP() == 1) {
|
||||
desFee = 0.6 * (number - 1);
|
||||
} else {
|
||||
desFee = 10* (number - 1);
|
||||
desFee = 10 * (number - 1);
|
||||
// if (number == 2) {
|
||||
// desFee = 5.75;
|
||||
// }
|
||||
@@ -112,6 +114,9 @@ public class ZsPrice {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public int[] twoSum(int[] nums, int target) {
|
||||
|
||||
List<Integer> list = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user