PDF FlattenFormFields not retaining Comb effect fields

Discussions about PDF management.
DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Tue Jul 08, 2014 12:03 pm

Hi there,

I'm currently evaluating GdPicture and find it very powerful and fast. I'm having a small problem with the FlattenFormFields method, however, which is removing Comb field formatting.

Here's a field config in Acrobat (CombFormat.png)
CombFormat.png
When the field value is populated using GdPicture, it looks fine (CombFormat.png)
FormFormat.png
FormFormat.png (1.1 KiB) Viewed 7593 times
And yet, when the FlattenFormFields method is called, the formatting is lost (FlatFormat.png)
FlatFormat.png
FlatFormat.png (1.39 KiB) Viewed 7593 times
I'm evaluating the very latest version of the toolkit (file versino 10.2.0.30), running on .NET 4.0.

Thanks in advance,

Dan

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by delbeke » Fri Jul 11, 2014 10:12 am

Hi DanZigga

I can not reproduce your problem.
Can you share your Pdf and the code you are using .

Jean-Luc

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by delbeke » Fri Jul 11, 2014 12:10 pm

Hi DanZigga

Problem reproduced! It come with the SetFormFieldValue function, not the with FlattenFormFields

I started investigations and warn you as soon as a fix will be avaible

Jean-Luc

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Fri Jul 11, 2014 12:11 pm

Hi Jean-Luc,

Thanks for the reply. I havea test PDF (CombForm.pdf) with 3 comb fields on it, however this forum won't let me post it - can I email it to you? Here's a reduced set of code which replicates the problem of a flattened PDF form is losing comb formatting.

An additional problem with the below is that the first field "TEXT1" isn't being populated since the GetFormFieldTitle method is returning a blank for that field.

Code: Select all

      
        Dim result As GdPicture10.GdPictureStatus = GdPicture10.GdPictureStatus.OK
        Dim flattenPDF As Boolean = True   'Set to true to see the problem
        Dim fileName As String = "C:\CombForm.PDF"

        If IO.File.Exists(fileName) Then
            registerGDP()  'licenseManager registerKey done here.
            result = gPDF.LoadFromFile(fileName, True)
            If result <> GdPicture10.GdPictureStatus.OK Then
                MsgBox("Load failed: " & gPDF.GetStat.ToString)
                Exit Sub
            End If
            For i = 1 To gPDF.GetFormFieldsCount
                Dim fieldIndex As Integer = gPDF.GetFormFieldID(i)
                Select Case gPDF.GetFormFieldTitle(fieldIndex).ToUpper
                    Case "TEXT1"
                        result = gPDF.SetFormFieldValue(fieldIndex, "AB123")
                    Case "TEXT2"
                        result = gPDF.SetFormFieldValue(fieldIndex, "CD456")
                    Case "TEXT3"
                        result = gPDF.SetFormFieldValue(fieldIndex, "EF789")
                End Select
                If result <> GdPicture10.GdPictureStatus.OK Then
                    MsgBox("Field value update failed: " & gPDF.GetStat.ToString)
                    Exit Sub
                End If
            Next
        End If

        If flattenPDF Then
            result = gPDF.FlattenFormFields()
            If result <> GdPicture10.GdPictureStatus.OK Then
                MsgBox("Flatten failed: " & gPDF.GetStat.ToString)
                Exit Sub
            End If
        End If

        Dim newFileName As String = IO.Path.GetDirectoryName(fileName) & "\" & IO.Path.GetFileNameWithoutExtension(fileName) & "_Merged" & IO.Path.GetExtension(fileName)
        result = gPDF.SaveToFile(newFileName)
        If result <> GdPicture10.GdPictureStatus.OK Then
            MsgBox("Save failed: " & gPDF.GetStat.ToString)
            Exit Sub
        End If
Thanks,

Dan

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Fri Jul 11, 2014 12:23 pm

Thanks for the update, Jean-Luc - I'm glad you've replicated the problem.

Just a note on my code above - there's possibly another slight problem with the GetFormFieldTitle method not returning one of the field names (the first field on the form?). If you could check this form me too please, that would be great.

Regards,

Dan

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by delbeke » Fri Jul 11, 2014 3:36 pm

Hi
The GetFormFieldID fuction is zero based

your code :
For i = 1 To gPDF.GetFormFieldsCount
Dim fieldIndex As Integer = gPDF.GetFormFieldID(i)
should be :
For i = 0 To gPDF.GetFormFieldsCount - 1
Dim fieldIndex As Integer = gPDF.GetFormFieldID(i)
see the link below.
https://www.gdpicture.com/guides/gdpicture/web ... eldID.html

Concerning the comb aspect, it is fixed. The next minor release will probably containt it.

Jean-Luc

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Fri Jul 11, 2014 6:12 pm

Fantastic. I hadn't spotted that the GetFormFieldID is zero-based - whoops.

Good news on the comb field fix. We'll test it with the next minor release.

Thanks,

Dan

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Fri Sep 05, 2014 5:02 pm

Hi there,

Next question (related to this...): How do I now CREATE a comb field using GDPicture? I have a flat PDF that I want to create text fields on, but want to create a comb field (rather than starting off with a PDF form that already has comb fields on it). Is that possible?

Thanks and best regards,

Dan

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by delbeke » Tue Sep 09, 2014 10:32 am

Hi DanZigga

Very sorry , there is actually no way to create such field with GdPicture.

Jean-Luc

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Wed Sep 10, 2014 9:28 am

Hi Jean-Luc,

Thanks for the response. That's unfortunately a show-stopper for us. Do you know of any workarounds, or do you have any plans to incorporate the ability to create Comb Fields in the near future? We're currently evaluating the software.

Thanks and best regards,

Dan

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by delbeke » Wed Sep 10, 2014 3:12 pm

Hi DanZigga

I am actually working to proide more functions to handle the form fields.
I an not able to say when this will be distributed, but it's on the way.
The method should be named like this

Public Function SetFormFieldComb( ByVal FieldID As Integer, ByVal UseComb As Boolean)

Jean-Luc

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Wed Sep 10, 2014 3:15 pm

Hi Jean-Luc,

That would be really great if that functionality is in place. I'm currently also a v11 beta tester, so would be happy to assist if you need some real-world tests.

Best regards,

Dan

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Thu Sep 18, 2014 2:07 pm

Hi Jean-Luc,

Do you know if there is any progress on the new method SetFormFieldComb? Let me know if I can assist with testing.

Thanks and best regards,

Dan

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by delbeke » Fri Sep 19, 2014 4:18 pm

Hi DanZigga

I am always on the developpement of a whole set of functions for the formfields. I think it will be finished this week. After that, the code will be submitted for review to the big boss.
If the boss approve the code, it will be included in the beta V11 for tests
So do not expect something before 2 weeks

Jean-Luc

DanZigga
Posts: 10
Joined: Tue Jul 08, 2014 11:35 am

Re: PDF FlattenFormFields not retaining Comb effect fields

Post by DanZigga » Tue Sep 23, 2014 11:26 am

Thanks for the feedback Jean-Luc,

Just another question regarding this. Is there an auto-font size option for PDF form fields?

Thanks and best regards,

Dan

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest