2009-06-04 70 views
0

我需要做的是查询iTextSharp AcroField以检查它是否旋转,如果是,则捕获旋转的值。如何使用iTextSharp获取文本字段旋转

所以,如果我有以下字段:

Dim af As iTextSharp.text.pdf.AcroFields = stamper.AcroFields 
Dim afi As iTextSharp.text.pdf.AcroFields.Item 

afi = af.GetFieldItem("fieldName") 

什么我需要做的就是特定领域的旋转(度)?

回答

0

一旦你的AcroField.Item如上图所示,你可以得到场旋转度,像这样:

Dim widgetDict As PdfDictionary = Nothing 
Dim mkDict As PdfDictionary = Nothing 
Dim rNum As PdfNumber = Nothing 

widgetDict = afi.widgets(0) 
If Not widgetDict Is Nothing Then 
    mkDict = widgetDict.GetAsDict(PdfName.MK) 
    If Not mkDict Is Nothing Then 
     rNum = mkDict.GetAsNumber(PdfName.R) 
     If Not rNum Is Nothing Then 
      Return rNum.DoubleValue  
     End If 
    End If 
End If 
Return 0 

请记住,这仅仅是AcroField的旋转。你还必须检查是否:

  • 页面本身也转动(PDFReader.GetPageRotation(您做生意))
  • 领域旋转是相对于页面(iTextSharp.text.pdf.PdfFormField。 FLAGS_NOROTATE)