所以这是我的问题:
我目前正在开发一个将文档归档为 PDF/A-1 的 java 应用程序。我正在使用 PdfBox 生成 pdf,但由于字体的原因,我无法生成有效的 PDF/A-1 pdf。字体嵌入在 pdf 文件中,但该网站:https://www.pdf-online.com/osa/validate.aspx 告诉我这不是有效的 PDF/A,因为:
The key Encoding has a value Identity-H which is prohibited.
我在互联网上查看了这个 Identity-H 编码是什么,它似乎是字体的编码方式,就像 ansi 编码一样。
我已经尝试过使用不同的字体,如 Helvetica 或 arial unicode Ms 但没有任何效果,总是有这种 Identity-H 编码。我对编码中的所有这些混乱感到有点迷茫,所以如果有人可以解释一下会很棒的。这也是我编写的在 pdf 中嵌入字体的代码:
2 3 4 5 6 7 8 | PDFont font = PDType0Font.load(doc, getClass().getClassLoader().getResourceAsStream(fontfile), true); if (!font.isEmbedded()) { throw new IllegalStateException("PDF/A compliance requires that all fonts used for" +" text rendering in rendering modes other than rendering mode 3 are embedded."); } |
感谢您的帮助:)
问题已解决:
我使用了 apache 的示例:CreatePDFA(我不知道为什么它会起作用,而不是我的代码):examples/src/main/java/org/apache/pdfbox/examples 中的示例
我添加以符合 PDF/A-3 要求:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | PDMarkInfo mark = new PDMarkInfo(); // new PDMarkInfo(page.getCOSObject()); PDStructureTreeRoot treeRoot = new PDStructureTreeRoot(); doc.getDocumentCatalog().setMarkInfo(mark); doc.getDocumentCatalog().setStructureTreeRoot(treeRoot); doc.getDocumentCatalog().getMarkInfo().setMarked(true); PDDocumentInformation info = doc.getDocumentInformation(); info.setCreationDate(date); info.setModificationDate(date); info.setAuthor("KairosPDF"); info.setProducer("KairosPDF"); info.setCreator("KairosPDF"); info.setTitle("Generated PDf"); info.setSubject("PDF/A3-A"); |
这是我将文件嵌入到 pdf 的代码:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | private final PDEmbeddedFilesNameTreeNode efTree = new PDEmbeddedFilesNameTreeNode(); private final PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog()); private final Map<String, PDComplexFileSpecification> efMap = new HashMap<>(); public void addFile(PDDocument doc, File child) throws IOException { File file = new File(child.getPath()); Calendar date = Calendar.getInstance(); //first create the file specification, which holds the embedded file PDComplexFileSpecification fs = new PDComplexFileSpecification(); fs.setFileUnicode(child.getName()); fs.setFile(child.getName()); InputStream is = new FileInputStream(file); PDEmbeddedFile ef = new PDEmbeddedFile(doc, is); //Setting ef.setSubtype("application/octet-stream"); ef.setSize((int) file.length() + 1); ef.setCreationDate(date); ef.setModDate(date); COSDictionary dictionary = fs.getCOSObject(); dictionary.setItem(COSName.getPDFName("AFRelationship"), COSName.getPDFName("Data")); fs.setEmbeddedFile(ef); efMap.put(child.getName(), fs); efTree.setNames(efMap); names.setEmbeddedFiles(efTree); doc.getDocumentCatalog().setNames(names); is.close(); } |
剩下的唯一问题是验证中的这个错误:
File specification 'Test.txt' not associated with an object.
希望对大家有所帮助。
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
我正在使用ruby1.9解析以下带有MacRoman字符的csv文件#encoding:ISO-8859-1#csv_parse.csvName,main-dialogue"Marceu","Giveittohimóhe,hiswife."我做了以下解析。require'csv'input_string=File.read("../csv_parse.rb").force_encoding("ISO-8859-1").encode("UTF-8")#=>"Name,main-dialogue\r\n\"Marceu\",\"Giveittohim\x97he,hiswife.\"\
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
我需要一个表,其中行实际上是2行表,一个嵌套表是..我怎样才能在Prawn中做到这一点?也许我需要延期..但哪一个? 最佳答案 现在支持子表:Prawn::Document.generate("subtable.pdf")do|pdf|subtable=pdf.make_table([["sub"],["table"]])pdf.table([[subtable,"original"]])end 关于ruby-on-rails-PrawnPDF:Ineedtogeneratenested
我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha