Print Page | Close Window

Page to Image- text fields not showing correctly

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=2026
Printed Date: 11 Jul 25 at 11:31AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Page to Image- text fields not showing correctly
Posted By: alecd4
Subject: Page to Image- text fields not showing correctly
Date Posted: 02 Nov 11 at 5:10PM
I am using QuickPDF to render pages from a  pdf file to image file. PDF file has several form fields that my application sets values to using the following APIs

SetNeedAppearances
SetFormFieldValue
SetFormFieldPrintable



Then my application calls SetFormFieldReadOnly against every field in a form.

This works just fine resulting in form with correct data in readonly fields (text,list,checkbox,radio)

Unfortunately when I render pages from that pdf to an image file text fields come with no data. Lists, checkboxes, and radio are fine.

Printing that pdf in Acrobat Reader shows all fields correctly

What I am doing wrong?



Replies:
Posted By: Ingo
Date Posted: 02 Nov 11 at 7:07PM
So try it with first readonly and then printable ... perhaps then it works?
The other thing:
What are the returning values after the function-calls... 0 or 1?
BTW: It could be that QuickPDF has still the loaded pdf in memory?
Perhaps you should save your modified pdf and after a new load it will work like you want it?

Cheers, Ingo


Posted By: alecd4
Date Posted: 02 Nov 11 at 7:37PM
setreadonly doesn't affect the result.

Return value from all API calls is 1 indicating success. In fact, text value are there. The result is correct except when rendering to file.

Pdf update and rendering are different events. Even if performed by different apps rendering of text fields fails.

You can see those in Acrobat and Reader. Printing also shows text fields.

Interestingly if I open pdf file in question after field update with Acrobat then save it without modification then the  rendering works just fine showing text values in the image.

I submitted test file. Case 9225


Posted By: alecd4
Date Posted: 02 Nov 11 at 10:52PM
I created simple pdf file that has a form with a single text field.
Here is the code I was using to set values

            PDFLibrary qp = new PDFLibrary(@"QuickPDFDLL0811.DLL");
            qp.UnlockKey("license here");
            qp.LoadFromFile("test.pdf", "");
            qp.SetNeedAppearances(1);
            int total = qp.FormFieldCount();
            for (int j = 1; j <= total; j++)
            {
                value="value-value";
                int ret=qp.SetFormFieldValue(j, value);
                int ret2 = qp.SetFormFieldPrintable(j, 1);
            }
            qp.SaveToFile("test2.pdf");

Open test2.pdf to confirm that new text values are set correctly.

Rendering test2.pdf pages to file doesn't show text values.


Posted By: Ingo
Date Posted: 03 Nov 11 at 7:07AM
Hi Alec!
 
... or try it the other way round and check the returning values for:
GetFormFieldPrintable
GetFormFieldType
GetFormFieldVisible
GetFormFieldReadOnly
... perhaps a way to determine the real problem?
... or has it to do with XFA- and non-XFA-formfields?
I'll stop here. But it's only a user-user-forum here - if you don't get a solution here you should use the official support pages.
 
Cheers, Ingo
 


Posted By: AndrewC
Date Posted: 03 Nov 11 at 9:14AM
QP.SetNeedAppearances(1) 

This tells Acrobat Reader that it should draw the formfields itself and that there are no 'appearance streams' in the file to help render the form fields.  

If you need QPL to render the form fields with QPL and RenderPageToFile then you need to replace SetNeedAppearances(1) with

            QP.SetNeedAppearances(0);
            for (int i = 1; i <= QP.FormFieldCount(); i++)
                    QP.UpdateAppearanceStream(i);

This tells QPL to create appearance streams for each of the formfield objects.

Andrew.





Posted By: alecd4
Date Posted: 04 Nov 11 at 9:08PM
            QP.SetNeedAppearances(0);
            for (int i = 1; i <= QP.FormFieldCount(); i++)
                    QP.UpdateAppearanceStream(i);

Above  helps

//error processing is removed
int id=Lib.LoadFromFile(path, password);
Lib.SetNeedAppearances(0);
int total = Lib.FormFieldCount();
for (int j = 1; j <= total; j++)
{
    Lib.UpdateAppearanceStream(j);
}
Lib.RenderPageToFile(dpi, no, option, path2);
Lib.RemoveDocument(id);


Does it make sense to call UpdateAppearanceStream() after I update formfields with new values and store updated pdf file? The reason is to store appearance stream for each form item in pdf file.






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