Dear iText Mailing List Support:

 

iTextSharp.dll Version: 5.5.6.0

Adobe Reader DC Version: 2015.008.20082

Adobe Acrobat Pro Version: 8.x

Acroform

 

I'm getting unwanted results in Adobe Reader when generating or regenerating
a multi-selection list box in an Acroform PDF document. The resulting PDF
views correctly in Adobe Acrobat 8, but not in Adobe Reader DC. 

 

Problem: When viewing the modified PDF in Adobe Reader DC, the non-selected
display items at the beginning of the list box that are previous to the
first selection are hidden. For example: "One","Two","Three","Four","Five"
are list items; and "Two" and "Four" are selected; then previous items such
as "One" are not visible in the top of the list box. And the first item
displayed in the list box starts with the first selection, in this case
"Two". (See Adobe Reader DC Screenshot)

 

FYI: Using Adobe Reader DC, when I select different field selections in the
list box, and then double click outside the list box, the list box field
reverts back to normal appearance with all the items shown.

 

I can't reproduce this issue when opening the modified PDF in Adobe Acrobat
Professional 8 and all the field items are visible and correctly selected.

 

 

Is this an Adobe Reader DC issue or an iTextSharp issue?

 

Thank you for all your hard work!

 

 

Modified Acroform Document with issue:

http://www.nk-inc.com/listbox-error.pdf

 

Adobe Reader DC Screenshot:

http://www.nk-inc.com/listbox-error-reader.gif

 

Acrobat Screenshot (no error):

http://www.nk-inc.com/listbox-error-acrobat.gif

 

VB.NET (v3.5 - Windows Application) CODE:

Imports iTextSharp.text.pdf

Imports iTextSharp.text

Imports System.IO

Public Class listboxTest

    Private Sub RunTest()

        Dim cList As New listboxTest()

        Dim fn As String = Application.StartupPath.ToString.TrimEnd("\") &
"\listbox-error.pdf"

        Dim b() As Byte = cList.addListBox(System.IO.File.ReadAllBytes(fn),
New iTextSharp.text.Rectangle(231.67, 108.0, 395.67, 197.0), "ListBox1",
"ListBox1", 1)

        File.WriteAllBytes(fn, b)

        Process.Start(fn)

    End Sub

    Public Function addListBox(ByVal pdfBytes() As Byte, ByVal newRect As
Rectangle, ByVal newFldName As String, ByVal oldfldname As String, ByVal pg
As Integer) As Byte()

        Dim pdfReaderDoc As New PdfReader(pdfBytes)

        Dim m As New System.IO.MemoryStream

        With New PdfStamper(pdfReaderDoc, m)

            Dim frmField As iTextSharp.text.pdf.TextField

            frmField = New iTextSharp.text.pdf.TextField(.Writer, newRect,
newFldName)

            frmField.TextColor = BaseColor.BLACK

            frmField.BackgroundColor = BaseColor.WHITE

            frmField.BorderColor = BaseColor.BLACK

            frmField.FieldName = newFldName

            frmField.Alignment = 0

            frmField.BorderStyle = 1

            frmField.BorderWidth = 1.0F

            frmField.Visibility = TextField.VISIBLE

            frmField.Rotation = 0

            frmField.Box = newRect

            Dim opt As New PdfArray

            Dim ComboBox_ItemDisplay As New List(Of String)

            ComboBox_ItemDisplay.Add("One")

            ComboBox_ItemDisplay.Add("Two")

            ComboBox_ItemDisplay.Add("Three")

            ComboBox_ItemDisplay.Add("Four")

            ComboBox_ItemDisplay.Add("Five")

            Dim ComboBox_ItemValue As New List(Of String)

            ComboBox_ItemValue.Add("1X")

            ComboBox_ItemValue.Add("2X")

            ComboBox_ItemValue.Add("3X")

            ComboBox_ItemValue.Add("4X")

            ComboBox_ItemValue.Add("5X")

            frmField.Options += iTextSharp.text.pdf.TextField.MULTISELECT

            Dim selIndex As New List(Of Integer)

            Dim selValues As New List(Of String)

            selIndex.Add(CInt(1))

            selIndex.Add(CInt(3))

            frmField.Choices = ComboBox_ItemDisplay.ToArray

            frmField.ChoiceExports = ComboBox_ItemValue.ToArray

            Dim selIndex2 As New List(Of Integer)

            selIndex2.AddRange(selIndex.ToArray)

            frmField.ChoiceSelections = selIndex2

            Dim fld As PdfFormField = frmField.GetListField

            If Not String.IsNullOrEmpty(oldfldname & "") Then

                .AcroFields.RemoveField(oldfldname, pg)

            End If

            .AddAnnotation(fld, pg)

            .Writer.CloseStream = False

            .Close()

            If m.CanSeek Then

                m.Position = 0

            End If

            Dim b() As Byte = m.ToArray

            m.Close()

            m.Dispose()

            pdfReaderDoc.Close()

            Return b

        End With

    End Function

End Class

 

 

 

 

 

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to