iText";未找到PDF标题签名";使用谷歌文档pdf

iText";未找到PDF标题签名";使用谷歌文档pdf,pdf,itext,google-docs,drive,Pdf,Itext,Google Docs,Drive,我们已经使用iText一年多了,现在可以生成带有自定义页眉和页脚的Google文档(在驱动器上)的pdf 为此,我们在谷歌文档的pdf中阅读如下: URL url = DriveController.getUrlFromFile(fileId); if(url != null) { PdfReader reader = new PdfReader(url); int n = reader.getNumberOfPages(); PdfImportedPage page;

我们已经使用iText一年多了,现在可以生成带有自定义页眉和页脚的Google文档(在驱动器上)的pdf

为此,我们在谷歌文档的pdf中阅读如下:

URL url =  DriveController.getUrlFromFile(fileId);
if(url != null) {
    PdfReader reader = new PdfReader(url);
    int n = reader.getNumberOfPages();
    PdfImportedPage page;
    ....

public static URL getUrlFromFile(String fileId) {
    fileId = "1macLOQW0YG9KMq0iTiMkMbs4-be07fNWtWAksVkjVvk";
    Drive service = null;
    try {

        service = DriveDirectoryServiceManager.getDriveService(SERVICE_ACCOUNT);
        File file = service.files().get(fileId).execute();
        try {
            if (file.getExportLinks() != null) {
                return new URL(file.getExportLinks().get("application/pdf"));
                .....
自3月23日起,iText在此行抛出“
com.itextpdf.text.exceptions.InvalidPdfException:PDF标题签名未找到。
”:

PdfReader reader = new PdfReader(url);
没有代码更改,而bizar的问题是,当您在浏览器中手动浏览pdf时,pdf的URL似乎返回了一个非常好的pdf

当我检查URL返回的内容的内容输入流时,我可以看到它以“%PDF-1.5”开头,这似乎很好,而且返回的URL的标题也很好:

{
cache-control=[private, max-age=0],
content-type=[application/pdf; charset=utf-8],
date=[Mon, 27 Mar 2017 09:23:24 GMT],
expires=[Mon, 27 Mar 2017 09:23:24 GMT],
x-robots-tag=[noindex, nofollow, nosnippet],
content-disposition=[attachment;filename="BUCK-PP-6L-RO-HNDL-209-211-QDS-GLOB-PMS0001.pdf"],
transfer-encoding=[chunked],
p3p=[CP="This is not a P3P policy! See https://support.google.com/accounts/answer/151657?hl=en for more info.", CP="This is not a P3P policy! See https://support.google.com/accounts/answer/151657?hl=en for more info."],
x-content-type-options=[nosniff],
x-frame-options=[SAMEORIGIN],
x-xss-protection=[1; mode=block],
server=[GSE],
set-cookie=[NID=99=m3XiYqz60y3VfDLAXLLcMnakRT7TbAYOqFABcvJIuRM8hs8zo9yfylmcnPY4y0bTv-j2RjVf4QTj7dC7TKTE-Mvg1lZlpGQJl0Q1EmbfjYHZtx8RqYLjtbNMIc18Ac6J;Domain=.google.com;Path=/;Expires=Tue, 26-Sep-2017 09:23:24 GMT;HttpOnly, NID=99=FO3FQ6tVAsgeq2_GbdJlOSCVegOfqgou2uR_uc_tIkeXhUbXVnrgHrV9SJIz01-IhlE5SmUf5caLYhN1rlnVo0ROcYlzozBwCESPOWOEHnFZhHl3Nv99q7MCiUu-AUro;Domain=.google.com;Path=/;Expires=Tue, 26-Sep-2017 09:23:24 GMT;HttpOnly],
alt-svc=[quic=":443"; ma=2592000; v="37,36,35"]
}
如果有人知道为什么iText不将其识别为pdf,欢迎提供任何帮助


您使用哪个版本的iText
com.itextpdf.text.*
表示它可能是5.x.x,但具体是哪个版本?您编写的代码没有进行任何更改。你使用Maven吗?你在POM文件中放了哪个iText版本?我们使用gradle:我们使用的版本是5.5.6(编译'com.itextpdf:itextpdf:5.5.6')好的。你能试试5.5.11吗?虽然说实话,我并不期望有什么不同。出于调试目的,能否在使用iText处理pdf之前将其保存到文件中?我的下一步将要求您共享pdf,但您可能不想将其放在公共internet上。您能检查一下贵公司是否与iText签订了支持合同吗?然后我们可以将该pdf视为机密数据,并在我们的内部支持系统中跟踪该问题。我可以看到它以%pdf-1.5开头,这似乎很好-您确定它真的是以该开头的,还是前面可能有一些空白字符?