gpt4 book ai didi

android - 发现多个文件的操作系统独立路径为 'com/itextpdf/io/font/cmap_info.txt'

转载 作者:行者123 更新时间:2023-11-29 02:27:22 30 4
gpt4 key购买 nike

这是我的代码:

 public  void CreateDirectory() throws FileNotFoundException {
File pdfFolder = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOCUMENTS), "pdfdemo");
if (!pdfFolder.exists()) {
pdfFolder.mkdir();
}


//Create time stamp
Date date = new Date() ;
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(date);

File myFile = new File(pdfFolder + timeStamp + ".pdf");

OutputStream output = new FileOutputStream(myFile);

//Initialize PDF writer
PdfWriter writer = new PdfWriter(myFile.getPath());

//Initialize PDF document
PdfDocument pdf = new PdfDocument(writer);

// Initialize document
Document document = new Document(pdf);

//Add paragraph to the document

document.add(new Paragraph("Hello World!"));

document.close();
}

在 build.gradle 中:

    dependencies {

implementation 'com.itextpdf:itext7-core:7.0.2'

}

但是当我尝试运行该程序时,它给了我这个错误:

发现不止一个文件具有独立于操作系统的路径 'com/itextpdf/io/font/cmap_info.txt'

我应该做什么?

最佳答案

build.gradle 中的下面代码为我修复了它

packagingOptions {
exclude 'com/itextpdf/io/font/cmap_info.txt'
exclude 'com/itextpdf/io/font/cmap/*'
}

关于android - 发现多个文件的操作系统独立路径为 'com/itextpdf/io/font/cmap_info.txt',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51456316/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com