从pdf itextsharp中提取字段

时间:2014-10-20 14:58:28

标签: vb.net pdf itextsharp

我有这个Crystal Reports pdf导出。这有多个页面,每个页面都是一个候选者。我需要从每个页面将此报告破解为单个pdf。在该页面上有两个字段(候选和名称),它们是新pdf文件名的一部分。如何从pdf中获取字段值。字段列表为空,count为零。为了更清楚:文件名必须从每页上两个字段的字段值中删除。

Using reader As PdfReader = New PdfReader(report.ExportToStream(ExportFormatType.PortableDocFormat)) ', filename)) 'pdfTemplatePath)
        Dim copy As PdfCopy
        Dim kandidaatnummer As String
        Dim naam As String
        For i As Integer = 1 To reader.NumberOfPages
            ' Filter the dataset for the candidate.
            dataSet.Tables("ReportData").DefaultView.RowFilter = String.Format("Kandidaatnummer = '{0}'", processedCandidates(i - 1))
            ' Create a new dataset for the candidate.
            Dim ds As New DataSet()
            ds.Tables.Add(dataSet.Tables("ReportData").DefaultView.ToTable("ReportData"))
            Dim d1 As Document = New Document()

            Dim newFilename As String = String.Format("{0}{1}", tempFolder, FileNameHelper.GetFileName(ds.Tables("ReportData"), "pdf", "DeelRapportage", ReportType.DeelrapportageSubrapporten))
            copy = New PdfSmartCopy(CType(d1, Document), New FileStream(newFilename, FileMode.Create))
            d1.Open()
            copy.AddPage(copy.GetImportedPage(reader, i)) ' reader.NumberOfPages - i + 1))

            d1.Close()
        Next
    End Using

0 个答案:

没有答案