Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Form Filling Duplication Problem
  FAQ FAQ  Forum Search   Register Register  Login Login

Form Filling Duplication Problem

 Post Reply Post Reply
Author
Message
DAVe3283 View Drop Down
Beginner
Beginner
Avatar

Joined: 04 Jun 10
Location: USA
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote DAVe3283 Quote  Post ReplyReply Direct Link To This Post Topic: Form Filling Duplication Problem
    Posted: 04 Jun 10 at 3:23AM
I am having a major problem with the form filling abilities of QuickPDF.  I have several PDF files with form fields, that I want to fill differently.  However, when I fill a field once, every field with the same name will be filled with the same information, even in different files.

I created a simple demo to demonstrate this.  It is a Console Application compiled in Visual Studio 2010 Beta 2 and is using .NET Framework 4 Client Profile.
using System;
using QuickPDFAX0719;

namespace FormFieldError
{
    class Program
    {
        static void Main(string[] args)
        {
            QuickPDFAX0719.PDFLibrary qp = new PDFLibrary();        // Create a new QuickPDF Lib
            qp.UnlockKey("j53g73ru93q4dp4ja7ri53b4y");              // License key for the QuickPDF library (TRIAL - expires 06/23/2010)
            int mainDocument = qp.NewDocument();                    // Create a new document, store it's id
            int tempDocument;                                       // Holds the id of the loaded document

            // Get file paths
            string form1 = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "form1.pdf");
            string form2 = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "form2.pdf");
            string output = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "output.pdf");

            // Fill document 1
            qp.LoadFromFile(form1);                                 // Load the form
            tempDocument = qp.SelectedDocument();                   // Get the id of the loaded document
            qp.SetFormFieldValueByTitle("RecordFileNo", "123");     // Set the file #
            qp.SelectDocument(mainDocument);                        // Select the main document
            qp.MergeDocument(tempDocument);                         // Merge the temp document into the main document

            // Fill document 2
            qp.LoadFromFile(form2);                                 // Load the form
            tempDocument = qp.SelectedDocument();                   // Get the id of the loaded document
            qp.SetFormFieldValueByTitle("RecordFileNo", "abc");     // Set the file #
            qp.SelectDocument(mainDocument);                        // Select the main document
            qp.MergeDocument(tempDocument);                         // Merge the temp document into the main document

            // Save result
            qp.SelectDocument(mainDocument);                        // Select the main document
            qp.DeletePages(1, 1);                                   // Delete the first (blank) page
            qp.SaveToFile(output);                                  // Save to disk
        }
    }
}

Opening the output.pdf file, you would expect to find the text "123" on the first page and "abc" on the second page.  However, both pages have the text "123".

Am I doing something wrong, or is there a bug in the library?  I really need to get this to work for my application, and I already have too much time invested to switch to a different PDF writer.

Thanks!
~David
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jun 10 at 6:36AM
Hi!

You have different files with identical form field names.
After the merge both documents are one new with the same formfield names.
So the content is a bit mixed up.
For me it's clear. The only difference is that i had thought that in both fields is "abc" ;-)
I would change the fieldnames before merging. You can get all properties setting a new one with a name combined with an on going number over the other formfields....

Cheers and welcome here,
Ingo
 
Back to Top
DAVe3283 View Drop Down
Beginner
Beginner
Avatar

Joined: 04 Jun 10
Location: USA
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote DAVe3283 Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jun 10 at 4:25PM
Thanks, I'll try that and see if I can get it to work.

I would have though they would be "abc" as well, but they weren't.  Strange.

Is there a way to rename a field, rather than re-creating every field?

~David
Back to Top
Jack View Drop Down
Team Player
Team Player
Avatar

Joined: 03 Jun 09
Location: Lompoc, CA
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jack Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jun 10 at 4:28PM
I ran into the same problem in my program.  It turned out that it was an issue with the way that Acrobat handles fields.  If you go into Acrobat and set up a form with two fields named "Test_1" and then put "123" into one of the fields, it will show up in both.  Rename one of the fields to "Test_2" and the problem goes away.

My solution was to load a form from a template and then add the page number to the front of each field and then fill the fields.  Some of my forms have master and detail fields too.  For them, when I am setting up the form, I add the detail number to the end of the form field.

My uses have been pretty routine form filling so I probably have not run across every possible test, but QuickPDF has not let me down yet.

I hope this is helpful.

Jack


Back to Top
Jack View Drop Down
Team Player
Team Player
Avatar

Joined: 03 Jun 09
Location: Lompoc, CA
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jack Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jun 10 at 4:37PM
Here is the code I used to add the page number to the form fields:

procedure TPDF.AddPageNoToFieldNames(var oPDF: TQuickPDF; iPageNo: Integer);
var i: Integer;
    sFieldName: String;
begin
  for i := 1 to oPDF.FormFieldCount do begin
    sFieldName := oPDF.GetFormFieldTitle(i);
    sFieldName := LPad(iPageNo, 3, '0') + '_' + sFieldName;
    oPDF.SetFormFieldChildTitle(i, sFieldName);
  end;
end;
It's in Delphi, but it's pretty clear what it's doing.
Jack
Back to Top
DAVe3283 View Drop Down
Beginner
Beginner
Avatar

Joined: 04 Jun 10
Location: USA
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote DAVe3283 Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jun 10 at 5:51PM
Ingo:
I was able to re-create the fields and get the result I wanted.  However, the re-creation procedure takes a very long time (filling and merging 4 pages of fields takes a fraction of a second, recreating those ~50 fields takes 3-4 seconds).  Very strange.
Thanks for getting me going!

Jack:
That is pretty much what I am doing with my program.  Your method worked great, and much faster than re-creating every field.  It was exactly what I was looking for!  Thank you!


Edited by DAVe3283 - 04 Jun 10 at 5:53PM
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store