第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何正確加密合并的pdf文檔

如何正確加密合并的pdf文檔

動(dòng)漫人物 2022-07-06 19:17:28
我對(duì) pdfBox API 有疑問。我正在嘗試使用以下代碼加密合并的 pdfdocument:這是合并/創(chuàng)建文檔的功能    public static void fillMultipleReportsInOne(List<report> reports) throws IOException {        PDFMergerUtility PDFmerger = new PDFMergerUtility();         PDDocument resultPDF = new PDDocument();        for (report report : reports) {            try             {                PDDocument pdfDocument = PDDocument.load(new File(SRC + "test.pdf"));                // get the document catalog                PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();                // as there might not be an AcroForm entry a null check is necessary                setFormFields(acroForm, report.getName(), report.getArea(), report.getOperatingActivities(), report.getVocationlaSchool(), report.getWeeklyTopics());                // Save and close the filled out form.                PDFmerger.appendDocument(resultPDF, pdfDocument);        } catch (Exception e) {            e.printStackTrace();        }    }    encryptPDF(resultPDF, SRC + "merged.pdf");}這是加密的功能: public static PDDocument encryptPDF(PDDocument pddocumentToEncrypt, String SRC) {        // Define the length of the encryption key.        // Possible values are 40 or 128 (256 will be available in PDFBox 2.0).        int keyLength = 128;        AccessPermission ap = new AccessPermission();        // Disable printing, everything else is allowed        ap.setCanModifyAnnotations(false);        ap.setCanFillInForm(false);        ap.setCanModify(false);        // Owner password (to open the file with all permissions) is "12345"        // User password (to open the file but with restricted permissions, is empty here)         StandardProtectionPolicy spp = new StandardProtectionPolicy("12334", "", ap);        spp.setEncryptionKeyLength(keyLength);        spp.setPermissions(ap);我的結(jié)果如下所示:結(jié)果
查看完整描述

1 回答

?
FFIVE

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

打電話

pddocumentToEncrypt.getDocumentCatalog().getAcroForm().refreshAppearances();

為 2.0 版本修復(fù)了這個(gè)問題。setValue()當(dāng)設(shè)置 /NeedAppearances 時(shí),該版本不會(huì)在調(diào)用中設(shè)置外觀(即表單值的視覺表示) (請(qǐng)參閱 參考資料PDTerminalField.applyChange())。/NeedAppearances 設(shè)置(如果為真)意味著查看應(yīng)用程序應(yīng)該創(chuàng)建外觀,以便中間的處理應(yīng)用程序不需要這樣做;我懷疑其中一項(xiàng)或多項(xiàng)權(quán)限設(shè)置會(huì)阻止 Adobe Reader 在顯示時(shí)對(duì)其進(jìn)行更改。

另一種解決方案是致電

pdfDocument.getDocumentCatalog().getAcroForm().setNeedAppearances(false);

在設(shè)置表單值之前。

唯一未解之謎是為什么第一個(gè)值在合并文件中可見。


查看完整回答
反對(duì) 回復(fù) 2022-07-06
  • 1 回答
  • 0 關(guān)注
  • 263 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)