无法使用iText将数据导入pdf复选框

时间:2019-02-20 07:41:44

标签: .net vb.net combobox itext itext7

我们在Vb .net中使用itext,是从excel电子表格中导入数据,并填充电子表格中的字段。除了复选框,我们得到了所有东西,我们不确定如何进行检查(它们是Yes / No)

互联网说要使用GetAppearanceState,但不能使用我们的代码,我们正在使用iTExt7

Private Sub ListFieldNames()

    src = "C:\GR_Templates\xxxForm.pdf"
    dest = "c:\GR_xxx\" & "-" & "-Return" & ".pdf"   '& docName &
    reader = New PdfReader(src)
    writer = New PdfWriter(dest)
    pdfDoc = New PdfDocument(reader, writer)
    form = Forms.PdfAcroForm.GetAcroForm(pdfDoc, True)

    fields = form.GetFormFields

End Sub 

其他代码

reader = New PdfReader(src)
reader.SetUnethicalReading(True)

writer = New PdfWriter(dest)
pdfDoc = New PdfDocument(reader, writer)
form = Forms.PdfAcroForm.GetAcroForm(pdfDoc, True)

fields = form.GetFormFields

Dim toSet As PdfFormField = Nothing
For ncol = 0 To dGridView.ColumnCount - 1

    For Each kvp As KeyValuePair(Of String, PdfFormField) In fields

        v1 = kvp.Key
        If v1 = (headerList(ncol + 1)) Then
            If dGridView(nCol, nRow).Value Is System.DBNull.Value Then
                dGridView(nCol, nRow).Value = ""
            End If
            nVal = dGridView(ncol, nRow).Value

            fields.TryGetValue(v1, toSet)

            toSet.SetValue(nVal)
            If IsNumeric(nVal) And chkSARS.Checked = False Then
                toSet.SetJustification(PdfFormField.ALIGN_RIGHT)
            End If

        End If

    Next

Next ncol

pdfDoc.Close()

0 个答案:

没有答案