You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by jarrod <xh...@yahoo.com.INVALID> on 2015/07/16 20:53:03 UTC

PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time

Hello,

I've converted a 1.8.9 project to the latest 2.0.0 shapshot (as of 20150716). This project fill's in acroForm fields and then saves to a new file.

1.  I'm having difficulty in assigning the selected value to a PDChoice field. In 1.8.9, I was able to use .setValue(strValueGoesHere) as long as the item already existed. When it didn't exist, i would add it first. In version 2.0.0, using .setValue(strValueGoesHere) throws an exception "not implemented". Then I proceeded to try using .setSelectedOptionsIndex but that throws the following exception "Setting the indices is not allowed for choice fields not allowing multiple selections."

How should I be setting this PDChoice field?


2.  Additionally, I've noticed the runtime execution time has dramatically increased when saving the document. The following lines of code only took 0 seconds previously and now takes 14 seconds;

java.util.Date startTime2 = new java.util.Date();
pdfDocument.save(dest);
pdfDocument.close();
java.util.Date endTime2 = new java.util.Date();
System.out.println("Save Time: " + ((endTime2.getTime()-startTime2.getTime())/1000));


3.  Also, I'm getting the following log entries during runtime although I'm guessing they are not very important;

Jul 16, 2015 1:43:30 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

Jul 16, 2015 1:43:30 PM org.apache.pdfbox.pdmodel.font.PDType1Font <init>
WARNING: Using fallback font ArialMT for base font ZapfDingbats


Thanks,

Jarrod

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,
> Am 16.07.2015 um 20:53 schrieb jarrod <xh...@yahoo.com.INVALID>:
> 
> Hello,
> 
> I've converted a 1.8.9 project to the latest 2.0.0 shapshot (as of 20150716). This project fill's in acroForm fields and then saves to a new file.
> 
> 1.  I'm having difficulty in assigning the selected value to a PDChoice field. In 1.8.9, I was able to use .setValue(strValueGoesHere) as long as the item already existed. When it didn't exist, i would add it first. In version 2.0.0, using .setValue(strValueGoesHere) throws an exception "not implemented". Then I proceeded to try using .setSelectedOptionsIndex but that throws the following exception "Setting the indices is not allowed for choice fields not allowing multiple selections."
> 
> How should I be setting this PDChoice field?

I've opened https://issues.apache.org/jira/browse/PDFBOX-2889 <https://issues.apache.org/jira/browse/PDFBOX-2889> to track support of the missing appearance generation.

BR
Maruan

> 
> 
> 2.  Additionally, I've noticed the runtime execution time has dramatically increased when saving the document. The following lines of code only took 0 seconds previously and now takes 14 seconds;
> 
> java.util.Date startTime2 = new java.util.Date();
> pdfDocument.save(dest);
> pdfDocument.close();
> java.util.Date endTime2 = new java.util.Date();
> System.out.println("Save Time: " + ((endTime2.getTime()-startTime2.getTime())/1000));
> 
> 
> 3.  Also, I'm getting the following log entries during runtime although I'm guessing they are not very important;
> 
> Jul 16, 2015 1:43:30 PM java.util.prefs.WindowsPreferences <init>
> WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
> 
> Jul 16, 2015 1:43:30 PM org.apache.pdfbox.pdmodel.font.PDType1Font <init>
> WARNING: Using fallback font ArialMT for base font ZapfDingbats
> 
> 
> Thanks,
> 
> Jarrod
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Am 17.07.2015 um 00:28 schrieb John Hewson:
>
>> On 16 Jul 2015, at 11:53, jarrod <xh...@yahoo.com.INVALID> wrote:
>>
>> Hello,
>>
>> I've converted a 1.8.9 project to the latest 2.0.0 shapshot (as of 20150716). This project fill's in acroForm fields and then saves to a new file.
>>
>> 1.  I'm having difficulty in assigning the selected value to a PDChoice field. In 1.8.9, I was able to use .setValue(strValueGoesHere) as long as the item already existed. When it didn't exist, i would add it first. In version 2.0.0, using .setValue(strValueGoesHere) throws an exception "not implemented". Then I proceeded to try using .setSelectedOptionsIndex but that throws the following exception "Setting the indices is not allowed for choice fields not allowing multiple selections."
>>
>> How should I be setting this PDChoice field?
>
> We don’t support generating the appearance for a choice field yet, but you can generate forms without appearances (as 1.8.9 does) by first calling setNeedAppearances(false) on the PDAcroForm.
>
>
>>
>> 2.  Additionally, I've noticed the runtime execution time has dramatically increased when saving the document. The following lines of code only took 0 seconds previously and now takes 14 seconds;
>>
>> java.util.Date startTime2 = new java.util.Date();
>> pdfDocument.save(dest);
>> pdfDocument.close();
>> java.util.Date endTime2 = new java.util.Date();
>> System.out.println("Save Time: " + ((endTime2.getTime()-startTime2.getTime())/1000));
>>
>
> Andreas, any thoughts?
No, but it looks like Jarrod already answered that question in his later 
posting, seems to be related to the creation of the appearance stream.

BR
Andreas

>
>> 3.  Also, I'm getting the following log entries during runtime although I'm guessing they are not very important;
>>
>> Jul 16, 2015 1:43:30 PM java.util.prefs.WindowsPreferences <init>
>> WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
>
> That’s PDFBox trying to create a local cache of font files and failing. I’m not sure why, looks like the reason is Windows-specific. It might take a few extra seconds to load PDFBox without the cache, but it not a problem.
>
>> Jul 16, 2015 1:43:30 PM org.apache.pdfbox.pdmodel.font.PDType1Font <init>
>> WARNING: Using fallback font ArialMT for base font ZapfDingbats
>
> I’m surprised that PDFBox doesn’t find a better substitute for ZapfDingbats, enable TRACE logging and post the log file.
>
> — John
>
>>
>> Thanks,
>>
>> Jarrod
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time

Posted by John Hewson <jo...@jahewson.com>.
> On 16 Jul 2015, at 16:32, jarrod <xh...@yahoo.com.INVALID> wrote:
> 
> Hello John,
> 
> Adding  setNeedAppearances(true) did allow me to set PDChoice fields similar to version 1.8.9. I noticed that you did not have to add the value if it didn't exist first like you would have had to do in version 1.8.9.
> 
> Additionally, adding that line of code reduced the runtime for saving by a few seconds and also removed those warnings I was getting previously.
> 
> On top of all that, it appears to have resolved the auto sizing issue that I was facing and working on with Maruan.
> 
> So does this, "This tells consumers of the PDF that they will need to generate the appearances themselves, i.e. they are not pre-generated" mean that pdf reader's will then have to generate the appearance when it opens? I guess the danger there is that it can appear differently across different readers and versions.

Yes, unfortunately, that’s exactly what it means. We have plans to implement more appearances in the medium-term future. In general, PDF readers should support NeedAppearances, but your milage may vary.

— John

> Now I'm just wondering if there is anyway to reduce the 8seconds to save.
> 
> Thanks for all the support!
> 
> Jarrod
> 
> 
> --------------------------------------------
> On Thu, 7/16/15, John Hewson <jo...@jahewson.com> wrote:
> 
> Subject: Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time
> To: users@pdfbox.apache.org
> Date: Thursday, July 16, 2015, 5:29 PM
> 
> 
> 
>> On 16 Jul 2015, at 15:28, John Hewson
> <jo...@jahewson.com>
> wrote:
>> 
>>> 
>>> On 16 Jul 2015, at 11:53, jarrod
> <xh...@yahoo.com.INVALID>
> wrote:
>>> 
>>> 
> Hello,
>>> 
>>> 
> I've converted a 1.8.9 project to the latest 2.0.0
> shapshot (as of 20150716). This project fill's in
> acroForm fields and then saves to a new file.
>>> 
>>> 1.  I'm
> having difficulty in assigning the selected value to a
> PDChoice field. In 1.8.9, I was able to use
> .setValue(strValueGoesHere) as long as the item already
> existed. When it didn't exist, i would add it first. In
> version 2.0.0, using .setValue(strValueGoesHere) throws an
> exception "not implemented". Then I proceeded to
> try using .setSelectedOptionsIndex but that throws the
> following exception "Setting the indices is not allowed
> for choice fields not allowing multiple selections."
>>> 
>>> How should I
> be setting this PDChoice field?
>> 
>> We don’t support generating the
> appearance for a choice field yet, but you can generate
> forms without appearances (as 1.8.9 does) by first calling
> setNeedAppearances(false) on the PDAcroForm.
> 
> Sorry, that should have been
> setNeedAppearances(true). This tells consumers of the PDF
> that they will need to generate the appearances themselves,
> i.e. they are not pre-generated.
> 
> — John
>> 
>>> 
>>> 2. 
> Additionally, I've noticed the runtime execution time
> has dramatically increased when saving the document. The
> following lines of code only took 0 seconds previously and
> now takes 14 seconds;
>>> 
>>> java.util.Date startTime2 = new
> java.util.Date();
>>> 
> pdfDocument.save(dest);
>>> 
> pdfDocument.close();
>>> java.util.Date
> endTime2 = new java.util.Date();
>>> 
> System.out.println("Save Time: " +
> ((endTime2.getTime()-startTime2.getTime())/1000));
>>> 
>> 
>> Andreas, any thoughts?
>> 
>>> 3.  Also,
> I'm getting the following log entries during runtime
> although I'm guessing they are not very important;
>>> 
>>> Jul 16, 2015
> 1:43:30 PM java.util.prefs.WindowsPreferences
> <init>
>>> WARNING: Could not
> open/create prefs root node Software\JavaSoft\Prefs at root
> 0x80000002. Windows RegCreateKeyEx(...) returned error code
> 5.
>> 
>> That’s
> PDFBox trying to create a local cache of font files and
> failing. I’m not sure why, looks like the reason is
> Windows-specific. It might take a few extra seconds to load
> PDFBox without the cache, but it not a problem.
>> 
>>> Jul 16, 2015
> 1:43:30 PM org.apache.pdfbox.pdmodel.font.PDType1Font
> <init>
>>> WARNING: Using
> fallback font ArialMT for base font ZapfDingbats
>> 
>> I’m surprised that
> PDFBox doesn’t find a better substitute for ZapfDingbats,
> enable TRACE logging and post the log file.
>> 
>> — John
>> 
>>> 
>>> Thanks,
>>> 
>>> Jarrod
>>> 
>>> 
> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> <ma...@pdfbox.apache.org>
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
> <ma...@pdfbox.apache.org>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time

Posted by jarrod <xh...@yahoo.com.INVALID>.
Hello John,

Adding  setNeedAppearances(true) did allow me to set PDChoice fields similar to version 1.8.9. I noticed that you did not have to add the value if it didn't exist first like you would have had to do in version 1.8.9.

Additionally, adding that line of code reduced the runtime for saving by a few seconds and also removed those warnings I was getting previously.

On top of all that, it appears to have resolved the auto sizing issue that I was facing and working on with Maruan.

So does this, "This tells consumers of the PDF that they will need to generate the appearances themselves, i.e. they are not pre-generated" mean that pdf reader's will then have to generate the appearance when it opens? I guess the danger there is that it can appear differently across different readers and versions.

Now I'm just wondering if there is anyway to reduce the 8seconds to save.

Thanks for all the support!

Jarrod


--------------------------------------------
On Thu, 7/16/15, John Hewson <jo...@jahewson.com> wrote:

 Subject: Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time
 To: users@pdfbox.apache.org
 Date: Thursday, July 16, 2015, 5:29 PM
 
 
 
 > On 16 Jul 2015, at 15:28, John Hewson
 <jo...@jahewson.com>
 wrote:
 > 
 >> 
 >> On 16 Jul 2015, at 11:53, jarrod
 <xh...@yahoo.com.INVALID>
 wrote:
 >> 
 >>
 Hello,
 >> 
 >>
 I've converted a 1.8.9 project to the latest 2.0.0
 shapshot (as of 20150716). This project fill's in
 acroForm fields and then saves to a new file.
 >> 
 >> 1.  I'm
 having difficulty in assigning the selected value to a
 PDChoice field. In 1.8.9, I was able to use
 .setValue(strValueGoesHere) as long as the item already
 existed. When it didn't exist, i would add it first. In
 version 2.0.0, using .setValue(strValueGoesHere) throws an
 exception "not implemented". Then I proceeded to
 try using .setSelectedOptionsIndex but that throws the
 following exception "Setting the indices is not allowed
 for choice fields not allowing multiple selections."
 >> 
 >> How should I
 be setting this PDChoice field?
 > 
 > We don’t support generating the
 appearance for a choice field yet, but you can generate
 forms without appearances (as 1.8.9 does) by first calling
 setNeedAppearances(false) on the PDAcroForm.
 
 Sorry, that should have been
 setNeedAppearances(true). This tells consumers of the PDF
 that they will need to generate the appearances themselves,
 i.e. they are not pre-generated.
 
 — John
 > 
 >> 
 >> 2. 
 Additionally, I've noticed the runtime execution time
 has dramatically increased when saving the document. The
 following lines of code only took 0 seconds previously and
 now takes 14 seconds;
 >> 
 >> java.util.Date startTime2 = new
 java.util.Date();
 >>
 pdfDocument.save(dest);
 >>
 pdfDocument.close();
 >> java.util.Date
 endTime2 = new java.util.Date();
 >>
 System.out.println("Save Time: " +
 ((endTime2.getTime()-startTime2.getTime())/1000));
 >> 
 > 
 > Andreas, any thoughts?
 > 
 >> 3.  Also,
 I'm getting the following log entries during runtime
 although I'm guessing they are not very important;
 >> 
 >> Jul 16, 2015
 1:43:30 PM java.util.prefs.WindowsPreferences
 <init>
 >> WARNING: Could not
 open/create prefs root node Software\JavaSoft\Prefs at root
 0x80000002. Windows RegCreateKeyEx(...) returned error code
 5.
 > 
 > That’s
 PDFBox trying to create a local cache of font files and
 failing. I’m not sure why, looks like the reason is
 Windows-specific. It might take a few extra seconds to load
 PDFBox without the cache, but it not a problem.
 > 
 >> Jul 16, 2015
 1:43:30 PM org.apache.pdfbox.pdmodel.font.PDType1Font
 <init>
 >> WARNING: Using
 fallback font ArialMT for base font ZapfDingbats
 > 
 > I’m surprised that
 PDFBox doesn’t find a better substitute for ZapfDingbats,
 enable TRACE logging and post the log file.
 > 
 > — John
 > 
 >> 
 >> Thanks,
 >> 
 >> Jarrod
 >> 
 >>
 ---------------------------------------------------------------------
 >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
 <ma...@pdfbox.apache.org>
 >> For additional commands, e-mail: users-help@pdfbox.apache.org
 <ma...@pdfbox.apache.org>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time

Posted by John Hewson <jo...@jahewson.com>.

> On 16 Jul 2015, at 15:28, John Hewson <jo...@jahewson.com> wrote:
> 
>> 
>> On 16 Jul 2015, at 11:53, jarrod <xh...@yahoo.com.INVALID> wrote:
>> 
>> Hello,
>> 
>> I've converted a 1.8.9 project to the latest 2.0.0 shapshot (as of 20150716). This project fill's in acroForm fields and then saves to a new file.
>> 
>> 1.  I'm having difficulty in assigning the selected value to a PDChoice field. In 1.8.9, I was able to use .setValue(strValueGoesHere) as long as the item already existed. When it didn't exist, i would add it first. In version 2.0.0, using .setValue(strValueGoesHere) throws an exception "not implemented". Then I proceeded to try using .setSelectedOptionsIndex but that throws the following exception "Setting the indices is not allowed for choice fields not allowing multiple selections."
>> 
>> How should I be setting this PDChoice field?
> 
> We don’t support generating the appearance for a choice field yet, but you can generate forms without appearances (as 1.8.9 does) by first calling setNeedAppearances(false) on the PDAcroForm.

Sorry, that should have been setNeedAppearances(true). This tells consumers of the PDF that they will need to generate the appearances themselves, i.e. they are not pre-generated.

— John
> 
>> 
>> 2.  Additionally, I've noticed the runtime execution time has dramatically increased when saving the document. The following lines of code only took 0 seconds previously and now takes 14 seconds;
>> 
>> java.util.Date startTime2 = new java.util.Date();
>> pdfDocument.save(dest);
>> pdfDocument.close();
>> java.util.Date endTime2 = new java.util.Date();
>> System.out.println("Save Time: " + ((endTime2.getTime()-startTime2.getTime())/1000));
>> 
> 
> Andreas, any thoughts?
> 
>> 3.  Also, I'm getting the following log entries during runtime although I'm guessing they are not very important;
>> 
>> Jul 16, 2015 1:43:30 PM java.util.prefs.WindowsPreferences <init>
>> WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
> 
> That’s PDFBox trying to create a local cache of font files and failing. I’m not sure why, looks like the reason is Windows-specific. It might take a few extra seconds to load PDFBox without the cache, but it not a problem.
> 
>> Jul 16, 2015 1:43:30 PM org.apache.pdfbox.pdmodel.font.PDType1Font <init>
>> WARNING: Using fallback font ArialMT for base font ZapfDingbats
> 
> I’m surprised that PDFBox doesn’t find a better substitute for ZapfDingbats, enable TRACE logging and post the log file.
> 
> — John
> 
>> 
>> Thanks,
>> 
>> Jarrod
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org <ma...@pdfbox.apache.org>
>> For additional commands, e-mail: users-help@pdfbox.apache.org <ma...@pdfbox.apache.org>

Re: PDFBox 2.0.0 Snapshot PDChoice and Increased Runtime Execution Time

Posted by John Hewson <jo...@jahewson.com>.
> On 16 Jul 2015, at 11:53, jarrod <xh...@yahoo.com.INVALID> wrote:
> 
> Hello,
> 
> I've converted a 1.8.9 project to the latest 2.0.0 shapshot (as of 20150716). This project fill's in acroForm fields and then saves to a new file.
> 
> 1.  I'm having difficulty in assigning the selected value to a PDChoice field. In 1.8.9, I was able to use .setValue(strValueGoesHere) as long as the item already existed. When it didn't exist, i would add it first. In version 2.0.0, using .setValue(strValueGoesHere) throws an exception "not implemented". Then I proceeded to try using .setSelectedOptionsIndex but that throws the following exception "Setting the indices is not allowed for choice fields not allowing multiple selections."
> 
> How should I be setting this PDChoice field?

We don’t support generating the appearance for a choice field yet, but you can generate forms without appearances (as 1.8.9 does) by first calling setNeedAppearances(false) on the PDAcroForm.


> 
> 2.  Additionally, I've noticed the runtime execution time has dramatically increased when saving the document. The following lines of code only took 0 seconds previously and now takes 14 seconds;
> 
> java.util.Date startTime2 = new java.util.Date();
> pdfDocument.save(dest);
> pdfDocument.close();
> java.util.Date endTime2 = new java.util.Date();
> System.out.println("Save Time: " + ((endTime2.getTime()-startTime2.getTime())/1000));
> 

Andreas, any thoughts?

> 3.  Also, I'm getting the following log entries during runtime although I'm guessing they are not very important;
> 
> Jul 16, 2015 1:43:30 PM java.util.prefs.WindowsPreferences <init>
> WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

That’s PDFBox trying to create a local cache of font files and failing. I’m not sure why, looks like the reason is Windows-specific. It might take a few extra seconds to load PDFBox without the cache, but it not a problem.

> Jul 16, 2015 1:43:30 PM org.apache.pdfbox.pdmodel.font.PDType1Font <init>
> WARNING: Using fallback font ArialMT for base font ZapfDingbats

I’m surprised that PDFBox doesn’t find a better substitute for ZapfDingbats, enable TRACE logging and post the log file.

— John

> 
> Thanks,
> 
> Jarrod
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org