我正在成功合并PDF文档; 现在因为我试图在没有选择PDF文档的情况下实现错误处理,它在关闭文档时会抛出错误:文档没有页面
如果在"foreach" - 循环中没有添加PDF文档,我仍然需要关闭文件!?或不?如果你打开一个物体,那么它在某个时刻就会被关闭.那么如果没有添加页面,如何正确转义?
private void MergePDFs()
{
DataSourceSelectArguments args = new DataSourceSelectArguments();
DataView view = (DataView)SourceCertCockpit.Select(args);
System.Data.DataTable table = view.ToTable();
List<PdfReader> readerList = new List<PdfReader>();
iTextSharp.text.Document document = new iTextSharp.text.Document();
PdfCopy copy = new PdfCopy(document, Response.OutputStream);
document.Open();
int index = 0;
foreach (DataRow myRow in table.Rows)
{
if (ListadoCertificadosCockpit.Rows[index].Cells[14].Text == "0")
{
PdfReader Reader = new PdfReader(Convert.ToString(myRow[0]));
Chapter Chapter = new Chapter(Convert.ToString(Convert.ToInt32(myRow[1])), 0);
Chapter.NumberDepth = 0;
iTextSharp.text.Section Section = Chapter.AddSection(Convert.ToString(myRow[10]), 0);
Section.NumberDepth = 0;
iTextSharp.text.Section SubSection = …Run Code Online (Sandbox Code Playgroud) 我有一个gridview,每行都有一个复选框.进入编辑模式时,可以选中/取消选中复选框; 但我不希望复选框在任何其他模式下可编辑.用户很容易被复选框搞糊涂,这些复选框不能反映保存在数据库中的实际值.
<asp:CheckBox id="checkboxCustomerRequired" runat="server" Checked='<%# Bind("CustomerRequired") %>' Enabled="false" CssClass="Check"/>
Run Code Online (Sandbox Code Playgroud)
我尝试过的可能的解决方法:
1)设置enabled = false
我使用的是 iTextSharp 版本 4.1.6.0,我的代码抛出“PdfReader 未使用所有者密码打开”异常。奇怪的是,我可以打开所有单个 PDF 文件,但合并它们时却失败了。我正在尝试遵循其他线程:
PdfReader.unethicalreading = true;
Run Code Online (Sandbox Code Playgroud)
但这个参数不被接受,我得到:
'PDFReader' does not contain a definition for 'unethicalreading'
Run Code Online (Sandbox Code Playgroud)
马丁