首先,我知道这里有一个类似的问题,但它并没有回答我的疑问。我有一个配置了 SSL 的 FTPS 服务器 (vsftpd)。
我已经生成了适当的密钥:
openssl req -x509 -nodes -days 1825 -newkey rsa:2048 \
-keyout private/vsftpd.key \
-out certs/vsftpd.crt
Run Code Online (Sandbox Code Playgroud)
并在服务器中配置了相应的conf文件。
现在,在使用 Apache commons net 的 Java 客户端代码中,我可以通过 SSL 与服务器进行通信,如下所示:
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
public class CommonsNetFTPSTest {
public static void main(String[] args) throws Exception {
System.setProperty("javax.net.debug", "ssl");
String server = "XXX.XXX.XXX.XXX";
String username = "USER_TEST";
String password = "ABCD1234";
String remoteFile = "/Data/Input/PH240819";
String localFile = …Run Code Online (Sandbox Code Playgroud) 我正在使用 .html 方法将 html 转换为 pdf,如下所示:
doc.html(content, {
callback: () => {
resolve(doc);
},
html2canvas: {
scale,
logging: true,
letterRendering: 1,
allowTaint: true,
useCORS: true,
},
dompurify,
margin: 0,
fontFaces,
});
Run Code Online (Sandbox Code Playgroud)
fontFaces 被定义为一个数组或像这样的对象(使用谷歌字体):
{
family: 'Balsamiq-Sans', weight: 'normal', stretch: 'normal',
src: [{ url: 'http://fonts.gstatic.com/s/balsamiqsans/v3/P5sEzZiAbNrN8SB3lQQX7Pnc8dkdIYdNHzs.ttf', format: 'truetype' }],
}
Run Code Online (Sandbox Code Playgroud)
在我想要渲染的html元素中,添加一个css fontFamily属性就足以设置字体
<span style={{ fontFamily: 'Balsamiq-Sans', ... }}>Almost before we knew it, we had left the ground </span>
Run Code Online (Sandbox Code Playgroud)
它实际上有效,因为它使用正确的 balsamiq sans 字体来呈现给定的文本,但间距看起来错误。
这是 balsamiq sans 的 HTML 页面中输入的样子
就像单词之间的间距减少了一样,谷歌字体中的很多字体都会发生这种情况(但其中一些字体工作得很好,比如 …
我正在使用zip4j 1.3.1压缩我的应用程序中的文件.现在我正在尝试重命名zip文件,而不必重命名文件本身.似乎有一种方法,但它不起作用.
我的代码看起来像:
public static void zipFile(File dstPath, File srcFile, String optionalName) throws ZipException {
ZipFile zipFile = new ZipFile(dstPath);
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_MAXIMUM);
parameters.setEncryptFiles(true);
parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
parameters.setPassword(RutasDAO.getPassZip());
//here I'm setting the name in the zip, but it's not working
parameters.setFileNameInZip(optionalName);
zipFile.addFile(srcFile, parameters);
}
Run Code Online (Sandbox Code Playgroud)
zip中的文件与我在srcFile中传递的文件具有相同的名称.也许还没有实施?你知道任何替代方法,方法或图书馆吗?
谢谢.
编辑:我想出了一个解决方案,创建一个具有所需名称的新文件,然后将其用作源文件:
File renamedFile = new File(tmpDirectory + optionalFileName);
copyFile(srcFile, renamedFile);
Run Code Online (Sandbox Code Playgroud)