FyTek Forum

Full Version: filling form fields with the DLL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(03-02-2010 06:36 AM)mario_pdf Wrote: [ -> ]Here's the test code I use:

Quote:IPDFMeldPtr pTestPDF(__uuidof(PDFMeld));
pTestPDF->setKeyName( "mykey" );
pTestPDF->setKeyCode( "mycode" );
pTestPDF->setInFile (_bstr_t(L"C:\\filein.pdf"));
pTestPDF->setOutFile (_bstr_t(L"c:\\fileout.pdf"));
_bstr_t outval = pTestPDF->buildPDF (); // THIS ONE RETURNS code -10 ???
_bstr_t allfields = pTestPDF->getFDFFields(); // THIS ONE RETURNS "" - EMPTY STRING???
_bstr_t thefield = pTestPDF->setFDFField("<< /T (Text2) /V (abc123) >>"); // THIS ONE DOES NOTHING VISIBLE, RETURNS MY FDF STRING
_bstr_t fieldval = pTestPDF->buildPDF (); // OR HOW ELSE DO I SAVE BACK THE RESULTS OF ABOVE OPS???

Pat has already the sample input file I'm using. What am I doing wrong?

The steps should be like this - I've added a step for the -10 error which means the PDF is using object streams or a different compression method (I'd have to do some investigation to see what's causing that):
IPDFMeldPtr pTestPDF(__uuidof(PDFMeld));
pTestPDF->setKeyName( "mykey" );
pTestPDF->setKeyCode( "mycode" );
pTestPDF->setInFile (_bstr_t(L"C:\\filein.pdf"));
pTestPDF->setOutFile (_bstr_t(L"c:\\fileout.pdf"));
pTestPDF->setParsev1(); // For the -10 error
pTestPDF->setUpdate(); // To keep fillable fields intact for Adobe Reader (only needed if this is a rights enabled PDF)
_bstr_t thefield = pTestPDF->setFDFField("<< /T (Text2) /V (abc123) >>"); // THIS ONE DOES NOTHING VISIBLE, RETURNS MY FDF STRING - correct, it only sets the string that the DLL will use when buildPDF is called
_bstr_t fieldval = pTestPDF->buildPDF (); // This should create your fileout.pdf with field Text2 set to the value abc123 (as long as that field is in filein.pdf).

Let me know what that does. If you're still having an issue, then let me know which PDF Pat has that you are using for your input and I'll do some testing with it.

Regards,
Mike Bernardo
FyTek, Inc.
Today's status is: it works.
What I had to learn the hard way is that I must set the fields at the final merging phase, not at the PDF loading time. The real life is more complicated than the small sample I sent you, namely buildPDF() gets called in more than one step (room for improvement here). So I had to add the fields at the very end. I also gave up the reader-enabled files, too much hassle for the moment.

I have a question with the proposed solution:
Are you sure setParsev1() is a valid option? I'm asking because in my application all the PDFs must be processed by the same function and there's no way I can guarantee the other files won't break with it (that's what I understand from the documentation)

I also have an issue with having the document title containing a comma, and I can't figure out yet which functionality is actually crashing the buildPDF() - title, bookmark, merging, something else... the error message I get is:
Quote:Can't locate object method "OPEN" via package "IO::String" at pdfmeld2.pl line 19053.
(03-04-2010 11:20 AM)mario_pdf Wrote: [ -> ]Today's status is: it works.
What I had to learn the hard way is that I must set the fields at the final merging phase, not at the PDF loading time. The real life is more complicated than the small sample I sent you, namely buildPDF() gets called in more than one step (room for improvement here). So I had to add the fields at the very end. I also gave up the reader-enabled files, too much hassle for the moment.

I have a question with the proposed solution:
Are you sure setParsev1() is a valid option? I'm asking because in my application all the PDFs must be processed by the same function and there's no way I can guarantee the other files won't break with it (that's what I understand from the documentation)

I also have an issue with having the document title containing a comma, and I can't figure out yet which functionality is actually crashing the buildPDF() - title, bookmark, merging, something else... the error message I get is:
Quote:Can't locate object method "OPEN" via package "IO::String" at pdfmeld2.pl line 19053.

Can you give me some more details on what you're passsing to what method(s)? I don't follow what you're saying about the comma in the document title. If you're passing a file name, it would be helpful to have the contents of that as well. I can probably put something in to correct the issue but I need to know what it is first.

Regards,
Mike Bernardo
FyTek, Inc.
(03-04-2010 04:08 PM)admin Wrote: [ -> ]Can you give me some more details on what you're passsing to what method(s)? I don't follow what you're saying about the comma in the document title. If you're passing a file name, it would be helpful to have the contents of that as well. I can probably put something in to correct the issue but I need to know what it is first.

Ok I was able to pinpoint it, the problem function is:
setFileDataB(id, bytes);
As soon as the "id" contains a comma string like "blabla, then more bla", the later buildPDF() crashes with the above mentioned error message.

Could you please also comment about the setParsev1() question I had before?

Not at least, are there any plans for a setFieldsFlatten() function which would flatten only ONE field at a time? Not all at once, because I'd like to flatten only the fields the program is filling, leaving the customer the others for his own data open...
(03-05-2010 08:32 AM)mario_pdf Wrote: [ -> ]
(03-04-2010 04:08 PM)admin Wrote: [ -> ]Can you give me some more details on what you're passsing to what method(s)? I don't follow what you're saying about the comma in the document title. If you're passing a file name, it would be helpful to have the contents of that as well. I can probably put something in to correct the issue but I need to know what it is first.

Ok I was able to pinpoint it, the problem function is:
setFileDataB(id, bytes);
As soon as the "id" contains a comma string like "blabla, then more bla", the later buildPDF() crashes with the above mentioned error message.

Could you please also comment about the setParsev1() question I had before?

Not at least, are there any plans for a setFieldsFlatten() function which would flatten only ONE field at a time? Not all at once, because I'd like to flatten only the fields the program is filling, leaving the customer the others for his own data open...

Are you using setErrFile? Best I can tell from what you've provided is it's having a problem opening the error file to write out whatever error is happening - if it seems to be when you use setFileDataB then I suppose it's related to that but I don't know what information you're passing with that method. Is there a reason you have to use commas in the id? Or can you provide me with more information on what you're doing with setFileDataB so I can try to reproduce the error? What would expedite the fix is if you could provide a small, complete working sample that exhibits the problem that I could use to for testing.

Yes, setParsev1 is a valid option. It's simply an alternate method of parsting the PDF. Will it work on every PDF? It should but there's no way for me know for sure. There are many ways to structure a PDF so I can't test every possibility.

At the moment I don't have any plans to change the setFieldsFlatten method but we can discuss that after these other issues are cleared up.

Regards,
Mike Bernardo
FyTek, Inc.
Pages: 1 2
Reference URL's