问题
I'm trying to collect some metadata about pdf files on our server. I'd like to know whether or not they are a form, and if so, if they can be saved or must be printed. Does something like iTextSharp expose that kind of information?
Here's a code sample where I can
Private Sub GetPDFInfo(ByVal path As String)
If File.Exists(path) Then
Dim reader As New PdfReader(path)
'sample metadata exposed
Dim numberOfPages = reader.NumberOfPages
'what to call to get form info?
End If
End Sub
UPDATE
Here's what I mean by being able to save or not:


回答1:
The simplest way to check for a form would be to see if the PdfReader
's AcroForm
field is null:
Dim HasForm = reader.AcroForm IsNot Nothing
EDIT
I don't have Adobe Reader laying around but I think that message is generated when usage rights aren't enabled on a form. You should be able to use:
Dim CanUserSave = reader.HasUsageRights()
来源:https://stackoverflow.com/questions/19381957/programmatically-check-if-pdf-is-a-form-with-itextsharp