Print Page | Close Window

New User, VB6 with QuickPDF

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1793
Printed Date: 28 Apr 26 at 9:58AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: New User, VB6 with QuickPDF
Posted By: SnoopyUK
Subject: New User, VB6 with QuickPDF
Date Posted: 04 Apr 11 at 1:30PM
Hi, I have installed the trial version and am currently trying to get this to work for me. I have a test PDF with 2 pages each with 3 fields on. When I step through my code it finds and populates all the fields but when I view the saved PDF the Qty field is blank and still editable.

Can anyone point out any obvious mistakes?

This is the relevant code:


qp.LoadFromFile ("C:\Users\Andy\Desktop\testfields.pdf")
FFCount = qp.FormFieldCount

       If FFCount > 0 Then

       For i = 1 To FFCount

            fftitle = qp.GetFormFieldTitle(i)
                
        If Right(fftitle, 10) = "Project[0]" Then
            qp.SetNeedAppearances (i)
            qp.SetFormFieldValue i, "New Project"
            qp.UpdateAppearanceStream (i)
        End If
        
        If Right(fftitle, 6) = "Qty[0]" Then
            qp.SetNeedAppearances (i)
            qp.SetFormFieldValue i, "632"
            qp.UpdateAppearanceStream (i)
        End If

        If Right(fftitle, 7) = "Date[0]" Then
            qp.SetNeedAppearances (i)
            qp.SetFormFieldValue i, "04/04/11"
            qp.UpdateAppearanceStream (i)
        End If
        
        Next i
    
            For i = 1 To FFCount
                qp.FlattenFormField (i)
            Next i
End If

qp.SaveToFile "C:\Users\Andy\Desktop\testfields2.pdf"

Any help would be greatly appreciated.

Thank you



Replies:
Posted By: AndrewC
Date Posted: 04 Apr 11 at 2:14PM

When you flatten a form field it reduces the total Form Field count by 1 so the last loop in your code needs to be reversed in order to work properly to allow for the shrinking form field list.  

For i = FFCount to 1 step -1      '  I haven't programmed Basic in years....
                qp.FlattenFormField (i)
            Next i

Andrew.


Posted By: jpbro
Date Posted: 04 Apr 11 at 2:14PM
Can you post a link to the test PDF?


Posted By: Rowan
Date Posted: 04 Apr 11 at 2:20PM
Two possibly issues, one minor, one big:

1. If you're calling SetNeedAppearances then you don't need to call UpdateAppearanceStream.
2. SetNeedAppearances takes 0 (false) or 1 (true), you can't update it with the index.


Posted By: SnoopyUK
Date Posted: 04 Apr 11 at 2:34PM

Thanks for all the quick replies. Didn't really know what the appearances were for, just included them after looking at various snippets of code Smile
But...   AndrewC, excellent thank you. works fine now. Very helpful.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk