ASPOSE.PDF 在打印PDF的时候 出现水印 而且内容变得很糊 怎么解决? 我购买了全套license

package com.project.baoxin.config.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

public class PdfUtil {
static boolean result = false;

public static boolean getLicense() {

	try {
		if (result)
			return true;
		InputStream strLicense = PdfUtil.class.getClassLoader().getResourceAsStream("License.xml");

		strLicense = PdfUtil.class.getClassLoader().getResourceAsStream("License.xml");
		com.aspose.cells.License aposeCell = new com.aspose.cells.License();
		aposeCell.setLicense(strLicense);
		

		result = true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
	return result;
}

public static String fileToPdf(String filePath, String pdfPath) {
	// 确保folder是存在的
	if (pdfPath.contains(File.separator)) {
		String folder = pdfPath.substring(0, pdfPath.lastIndexOf(File.separator));

// FileUtil.createFolder(folder, true);
File dir = new File(folder);
dir.mkdir();
}
File ftmp = new File(pdfPath);
if (!ftmp.exists() || ftmp.length() == 0) {
PdfUtil.excel2pdf(filePath, pdfPath);
}
return “”;
}

/**
 * @param excelPath 需要被转换的excel全路径带文件名
 * @param pdfPath   转换之后pdf的全路径带文件名
 */
private static void excel2pdf(String excelPath, String pdfPath) {
	if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
		return;
	}
	try {
		com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(excelPath);// 原始excel路径
		FileOutputStream fileOS = new FileOutputStream(new File(pdfPath));
		wb.save(fileOS, com.aspose.cells.SaveFormat.PDF);
		fileOS.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
}

}
上面是我读取license用的代码 我的pdf是没有带水印的;
public boolean printPdf(String filePath, PrintService printService) {
try {
PdfViewer viewer = new PdfViewer();
viewer.bindPdf(filePath);
viewer.setAutoResize(true); // Print the file with adjusted size
viewer.setAutoRotate(true); // Print the file with adjusted rotation
viewer.setPrintPageDialog(false); // Do not produce the page number dialog when printing
PdfPrinterSettings printerSettings = new PdfPrinterSettings();
PrintPageSettings pageSettings = new PrintPageSettings();

		printerSettings.setPrinterName("RICOH P 201W");

		viewer.printDocumentWithSettings(pageSettings, printerSettings);
		viewer.close();
		return true;

	}catch (Exception e) {
		log.error("执行pdf打印异常:{}", JSON.toJSONString(e));
		return false;
	}
}

这是我的打印代码 打印带水印而且很糊

@PonyWhite

在打印 PDF 时出现水印并且内容模糊的问题,可能是由于以下几个原因导致的:

  1. 许可证未正确应用:确保您在打印之前已经成功应用了许可证。虽然您提到 PDF 没有水印,但在打印时可能仍然会出现问题。

  2. 打印机设置:检查打印机的设置,确保选择了正确的打印质量和纸张类型。有时,低质量的打印设置会导致输出模糊。

  3. PDF 文件的分辨率:确保生成的 PDF 文件具有足够的分辨率。您可以在保存 PDF 时设置更高的分辨率,以确保打印质量。

  4. 使用的打印库:您使用的 PdfViewer 类可能在处理打印时存在问题。考虑使用其他打印方法或库,看看是否能改善打印效果。

为了解决这个问题,您可以按照以下步骤操作:

  1. 验证许可证:确保许可证文件的路径正确,并且在打印之前成功加载。

  2. 检查打印机设置:在打印机属性中选择高质量打印选项。

  3. 调整 PDF 保存选项:在保存 PDF 时,使用更高的分辨率。例如:

    PdfSaveOptions saveOptions = new PdfSaveOptions();
    saveOptions.setQuality(100); // 设置高质量
    workbook.save(fileOS, saveOptions);
    
  4. 尝试不同的打印方法:如果问题仍然存在,考虑使用其他打印库或方法来打印 PDF。

请按照上述步骤进行操作,以解决打印时出现的水印和模糊问题。如果您有其他问题或需要进一步的帮助,请随时告诉我!我将竭诚为您提供支持。