我有問(wèn)題,我會(huì)用 php 生成 pdf 中的復(fù)選框,但是如果我重新檢查復(fù)選框狀態(tài),我找不到復(fù)選框。我試過(guò):TCPDF(生成)C#(閱讀,未找到復(fù)選框)Python(讀取,Pypdf2,未找到復(fù)選框)圖片:Acrobat Reader 打開 pdf 顯示復(fù)選框 ( https://prnt.sc/uqjny8 )Python 3.8 閱讀器輸出 ( https://prnt.sc/uqjp9o )C# 代碼輸出 ( https://prnt.sc/uqjpnw )文件:沒(méi)有復(fù)選框的簡(jiǎn)單 PDF ( http://www.africau.edu/images/default/sample.pdf )帶有復(fù)選框的 PDF ( https://easyupload.io/zjn85z )PHP 復(fù)選框生成代碼:$pdf = new \setasign\Fpdi\TcpdfFpdi('L', 'mm', 'A4');$pages = $pdf->setSourceFile('file://C:/Users/JonDoe/Desktop/sample.pdf');for ($i = 1; $i <= $pages; $i++){ $pdf->AddPage(); $page = $pdf->importPage($i); $pdf->useTemplate($page, 0, 0); $pdf->CheckBox('newsletter', 5, true, array(), array(), 'OK1', 600/5, 500/5, true);}$pdf->Output("file://C:/Users/JonDoe/Desktop/sample.pdf", 'F');讀者腳本:C#:using System;using iTextSharp.text.pdf;using System.Linq;namespace PDF_Checkbox{ class Program { static void Main(string[] args) { string path = "C:\\Users\\JonDoe\\Desktop\\sample"; PdfReader reader2 = new PdfReader(@"" + path + ".pdf"); var fieldList = GetFormFieldNamesWithValues(reader2); Console.WriteLine("============================================================"); Console.WriteLine("Fields: " + fieldList); Console.WriteLine("============================================================"); Console.ReadKey(); } private static string GetFormFieldNamesWithValues(PdfReader pdfReader) { return string.Join("\r\n", pdfReader.AcroFields.Fields.Select(x => x.Key + "=" + pdfReader.AcroFields.GetField(x.Key)).ToArray()); } }}Python 3.8:import PyPDF2 as pypdfpdfobject=open('sample.pdf','rb')pdf=pypdf.PdfFileReader(pdfobject)print(pdf.getFields())正如您所讀,我想查看生成的復(fù)選框狀態(tài),無(wú)論是 python 還是 c#、php 有誰(shuí)知道這個(gè)問(wèn)題的解決方案嗎?
1 回答

三國(guó)紛爭(zhēng)
TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊
您傳遞true
給$js
參數(shù),該參數(shù)不會(huì)真正將復(fù)選框添加到 PDF,但會(huì)包含 JavaScript,它將在打開時(shí)創(chuàng)建字段(通過(guò)能夠執(zhí)行 JavaScript 的查看器應(yīng)用程序)。
嘗試傳遞false
或保留參數(shù)(false
= 默認(rèn)值)。
添加回答
舉報(bào)
0/150
提交
取消