PDFormFieldAdditionalActions.setC() not working?

2017-05-25 Thread Gary Grosso
In my project, I could not get setC to do anything, so I modified the 
CreateSimpleForm.java code to create 2 fields (just in case that mattered), 
which resulted in http://aapro.net/PDF/SimpleForm.pdf.

Then I commented out a lot of distracting other event handling in 
FieldTriggers.java, and duplicated everything to handle both fields, resulting 
in http://aapro.net/PDF/FieldTriggers.java . This, when run gives 
http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something 
like this:

AcroForm: (3) [3 0 R]
   DA: /Helv o Tfo g
   DR: (1) [70 R]
 Fields: (2)
   0: (12) [SOR] /T:Annot /S:Widget
   1: (11) [60R] /T:Annot /S:Widget
 AA: (2) [120 R]
 C: (3) [19 O R] /T:Action
 JS: app.alert("On 'recalculate' action")
 S: Javascript
 Type: Action
 D: (3) [13 o R] /T:Action
 JS: app.alert("On 'mouse down' action")
 S: Javascript
 Type: Action

Whatever I do, much as in my original project, I never see "On 'recalculate' 
action".

I get the expected (if somewhat annoying) behavior for setK, setF, and setV. 
Why not setC?

Thanks,
Gary



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



RE: what should PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

2017-05-25 Thread Gary Grosso
Never mind, it's as simple as:

PDPushButton.setAlternateFieldName()

I guess I'll use both setAlternateFieldName and setRolloverCaption.

Gary

-Original Message-
From: Gary Grosso [mailto:gary.gro...@oberontech.com] 
Sent: Thursday, May 25, 2017 1:29 PM
To: users@pdfbox.apache.org
Subject: RE: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

I see.

Does PDFBox provide a way to set the TU (alternate field name) field?

Thanks,
Gary

-Original Message-
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Thursday, May 25, 2017 11:57 AM
To: users@pdfbox.apache.org
Subject: Re: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

I looked at the files in PDFDebugger. The "This is a tooltip added by acrobat" 
line appears in "/TU", which is meant for something different:

(Optional; PDF 1.3) An alternate field name that shall be used in place of the 
actual field name wherever the field shall be identified in the user interface 
(such as in error or status messages referring to the field). This text is also 
useful when extracting the document’s contents in support of accessibility to 
users with disabilities or for other purposes (see 14.9.3, “Alternate 
Descriptions”).

Tilman

Am 25.05.2017 um 15:23 schrieb Gary Grosso:
> One more upload: 
> http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip-also-Text
> Field.pdf
>
> Contrary to what I inferred from "how to add tooltip" articles I read online, 
> Acrobat allows me to add a tooltip to a textfield (not just a button), and it 
> works just fine.
>
> This is so much nicer than foodling around with invisible buttons. It would 
> be great if this just worked in PDFBox.
>
> Gary
>
>
> -Original Message-
> From: Gary Grosso [mailto:gary.gro...@oberontech.com]
> Sent: Thursday, May 25, 2017 9:04 AM
> To: users@pdfbox.apache.org
> Subject: RE: what should 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption do?
>
> I also uploaded 
> http://aapro.net/PDF/DocBookTest3_modified_captionsByPDFBox.pdf
>
> -Original Message-
> From: Gary Grosso [mailto:gary.gro...@oberontech.com]
> Sent: Thursday, May 25, 2017 8:54 AM
> To: users@pdfbox.apache.org
> Subject: RE: what should 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption do?
>
> Yes, it does work if done with Acrobat, see 
> http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip.pdf ( done using 
> Button Properties > General > Tooltip).
>
> I need general tooltip capability. Everywhere I look, this is done with 
> buttons, sometimes invisible. This is perhaps the last requirement needed for 
> a customer to choose PDFBox (and my services) for this work.
>
> Can this be made to work, or can another way be described of getting tooltips 
> (to appear on various form fields)?
>
> One possibility seems to be using NormalCaption on an invisible button. I am 
> able to make the button invisible, but not the caption text. Also, if I 
> succeed in making the caption text invisible, I don't know if it will stay 
> invisible when moused over.
>
> Thanks,
> Gary
>
>
>
> -Original Message-
> From: Tilman Hausherr [mailto:thaush...@t-online.de]
> Sent: Thursday, May 25, 2017 4:21 AM
> To: users@pdfbox.apache.org
> Subject: Re: what should 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption do?
>
> According to the PDF spec: "(Optional; pushbutton fields only) The widget 
> annotation's rollover caption, which shall be displayed when the user rolls 
> the cursor into its active area without pressing the mouse button."
>
> The best would be to create such a file with Adobe Acrobat to see if it works 
> at all.
>
> Tilman
>
>
> Am 25.05.2017 um 03:45 schrieb Gary Grosso:
>> I was expecting 
>> PDAppearanceCharacteristicsDictionary.setRolloverCaption(String
>>  caption) to display the value of argument caption when the user's mouse 
>> rolled over the widget.
>>
>> I get the value passed to setNormalCaption() regardless. Is the problem with 
>> my expectations, my usage, or the implementation?
>>
>> I'm morphing an existing PDF document, finding locations based on a kludge, 
>> since this is still proof-of-principle, so I only show the one method below. 
>> I can write a create-PDF-from-scratch driver for the method if necessary.
>>
>> Thanks,
>> Gary
>>
>>   private static void addButtonAtRect(PDPage page, PDAcroForm acroForm, 
>> String text, PDRectangle rect) {
>>   PDPushButton pushButton = new PDPushButton(acroForm);
>>
>>   // For now, just make sure each partial name is unique.
>>   String nameStr = text.replaceAll(" ", "") + "Name" + 
>> 

RE: what should PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

2017-05-25 Thread Gary Grosso
I see.

Does PDFBox provide a way to set the TU (alternate field name) field?

Thanks,
Gary

-Original Message-
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Thursday, May 25, 2017 11:57 AM
To: users@pdfbox.apache.org
Subject: Re: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

I looked at the files in PDFDebugger. The "This is a tooltip added by acrobat" 
line appears in "/TU", which is meant for something different:

(Optional; PDF 1.3) An alternate field name that shall be used in place of the 
actual field name wherever the field shall be identified in the user interface 
(such as in error or status messages referring to the field). This text is also 
useful when extracting the document’s contents in support of accessibility to 
users with disabilities or for other purposes (see 14.9.3, “Alternate 
Descriptions”).

Tilman

Am 25.05.2017 um 15:23 schrieb Gary Grosso:
> One more upload: 
> http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip-also-Text
> Field.pdf
>
> Contrary to what I inferred from "how to add tooltip" articles I read online, 
> Acrobat allows me to add a tooltip to a textfield (not just a button), and it 
> works just fine.
>
> This is so much nicer than foodling around with invisible buttons. It would 
> be great if this just worked in PDFBox.
>
> Gary
>
>
> -Original Message-
> From: Gary Grosso [mailto:gary.gro...@oberontech.com]
> Sent: Thursday, May 25, 2017 9:04 AM
> To: users@pdfbox.apache.org
> Subject: RE: what should 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption do?
>
> I also uploaded 
> http://aapro.net/PDF/DocBookTest3_modified_captionsByPDFBox.pdf
>
> -Original Message-
> From: Gary Grosso [mailto:gary.gro...@oberontech.com]
> Sent: Thursday, May 25, 2017 8:54 AM
> To: users@pdfbox.apache.org
> Subject: RE: what should 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption do?
>
> Yes, it does work if done with Acrobat, see 
> http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip.pdf ( done using 
> Button Properties > General > Tooltip).
>
> I need general tooltip capability. Everywhere I look, this is done with 
> buttons, sometimes invisible. This is perhaps the last requirement needed for 
> a customer to choose PDFBox (and my services) for this work.
>
> Can this be made to work, or can another way be described of getting tooltips 
> (to appear on various form fields)?
>
> One possibility seems to be using NormalCaption on an invisible button. I am 
> able to make the button invisible, but not the caption text. Also, if I 
> succeed in making the caption text invisible, I don't know if it will stay 
> invisible when moused over.
>
> Thanks,
> Gary
>
>
>
> -Original Message-
> From: Tilman Hausherr [mailto:thaush...@t-online.de]
> Sent: Thursday, May 25, 2017 4:21 AM
> To: users@pdfbox.apache.org
> Subject: Re: what should 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption do?
>
> According to the PDF spec: "(Optional; pushbutton fields only) The widget 
> annotation's rollover caption, which shall be displayed when the user rolls 
> the cursor into its active area without pressing the mouse button."
>
> The best would be to create such a file with Adobe Acrobat to see if it works 
> at all.
>
> Tilman
>
>
> Am 25.05.2017 um 03:45 schrieb Gary Grosso:
>> I was expecting 
>> PDAppearanceCharacteristicsDictionary.setRolloverCaption(String
>>  caption) to display the value of argument caption when the user's mouse 
>> rolled over the widget.
>>
>> I get the value passed to setNormalCaption() regardless. Is the problem with 
>> my expectations, my usage, or the implementation?
>>
>> I'm morphing an existing PDF document, finding locations based on a kludge, 
>> since this is still proof-of-principle, so I only show the one method below. 
>> I can write a create-PDF-from-scratch driver for the method if necessary.
>>
>> Thanks,
>> Gary
>>
>>   private static void addButtonAtRect(PDPage page, PDAcroForm acroForm, 
>> String text, PDRectangle rect) {
>>   PDPushButton pushButton = new PDPushButton(acroForm);
>>
>>   // For now, just make sure each partial name is unique.
>>   String nameStr = text.replaceAll(" ", "") + "Name" + 
>> Integer.toString(nameCnt);
>>   nameCnt++;
>>   pushButton.setPartialName(nameStr);
>>
>>   acroForm.getFields().add(pushButton);
>>
>>   PDAnnotationWidget widget = pushButton.getWidgets().get(0);
>>   widget.setRectangle(rect);
>>   if (rect.getHeight() < MIN_RECT_HEIGHT) {
>>   float diff = MIN_RECT_HEIGHT - 

Re: what should PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

2017-05-25 Thread Tilman Hausherr
I looked at the files in PDFDebugger. The "This is a tooltip added by 
acrobat" line appears in "/TU", which is meant for something different:


(Optional; PDF 1.3) An alternate field name that shall be used in place 
of the actual field name wherever the field shall be identified in the 
user interface (such as in error or status messages referring to the 
field). This text is also useful when extracting the document’s contents 
in support of accessibility to users with disabilities or for other 
purposes (see 14.9.3, “Alternate Descriptions”).


Tilman

Am 25.05.2017 um 15:23 schrieb Gary Grosso:

One more upload: 
http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip-also-TextField.pdf

Contrary to what I inferred from "how to add tooltip" articles I read online, 
Acrobat allows me to add a tooltip to a textfield (not just a button), and it works just 
fine.

This is so much nicer than foodling around with invisible buttons. It would be 
great if this just worked in PDFBox.

Gary


-Original Message-
From: Gary Grosso [mailto:gary.gro...@oberontech.com]
Sent: Thursday, May 25, 2017 9:04 AM
To: users@pdfbox.apache.org
Subject: RE: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

I also uploaded http://aapro.net/PDF/DocBookTest3_modified_captionsByPDFBox.pdf

-Original Message-
From: Gary Grosso [mailto:gary.gro...@oberontech.com]
Sent: Thursday, May 25, 2017 8:54 AM
To: users@pdfbox.apache.org
Subject: RE: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

Yes, it does work if done with Acrobat, see 
http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip.pdf ( done using Button 
Properties > General > Tooltip).

I need general tooltip capability. Everywhere I look, this is done with 
buttons, sometimes invisible. This is perhaps the last requirement needed for a 
customer to choose PDFBox (and my services) for this work.

Can this be made to work, or can another way be described of getting tooltips 
(to appear on various form fields)?

One possibility seems to be using NormalCaption on an invisible button. I am 
able to make the button invisible, but not the caption text. Also, if I succeed 
in making the caption text invisible, I don't know if it will stay invisible 
when moused over.

Thanks,
Gary



-Original Message-
From: Tilman Hausherr [mailto:thaush...@t-online.de]
Sent: Thursday, May 25, 2017 4:21 AM
To: users@pdfbox.apache.org
Subject: Re: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

According to the PDF spec: "(Optional; pushbutton fields only) The widget 
annotation's rollover caption, which shall be displayed when the user rolls the cursor 
into its active area without pressing the mouse button."

The best would be to create such a file with Adobe Acrobat to see if it works 
at all.

Tilman


Am 25.05.2017 um 03:45 schrieb Gary Grosso:

I was expecting 
PDAppearanceCharacteristicsDictionary.setRolloverCaption(String
 caption) to display the value of argument caption when the user's mouse rolled over 
the widget.

I get the value passed to setNormalCaption() regardless. Is the problem with my 
expectations, my usage, or the implementation?

I'm morphing an existing PDF document, finding locations based on a kludge, 
since this is still proof-of-principle, so I only show the one method below. I 
can write a create-PDF-from-scratch driver for the method if necessary.

Thanks,
Gary

  private static void addButtonAtRect(PDPage page, PDAcroForm acroForm, 
String text, PDRectangle rect) {
  PDPushButton pushButton = new PDPushButton(acroForm);

  // For now, just make sure each partial name is unique.
  String nameStr = text.replaceAll(" ", "") + "Name" + 
Integer.toString(nameCnt);
  nameCnt++;
  pushButton.setPartialName(nameStr);

  acroForm.getFields().add(pushButton);

  PDAnnotationWidget widget = pushButton.getWidgets().get(0);
  widget.setRectangle(rect);
  if (rect.getHeight() < MIN_RECT_HEIGHT) {
  float diff = MIN_RECT_HEIGHT - rect.getHeight();
  rect.setLowerLeftY((float) (rect.getLowerLeftY() - diff/2.0));
  rect.setUpperRightY((float) (rect.getUpperRightY() + diff/2.0));
  }

  widget.setPage(page);

  String jsString = "app.alert(\"" + text + " Performed.\");";

  //Creating PDActionJavaScript object
  PDActionJavaScript action = new PDActionJavaScript(jsString);
  widget.setAction(action);

  acroForm.setNeedAppearances(true);

  PDAppearanceCharacteristicsDictionary 

Re: PDF Signing, generated PDF Document certification is invalid, using HSM

2017-05-25 Thread Tilman Hausherr
ok... sorry I can't help further. Maybe it's best to ask on 
stackoverflow. Use a label for bouncycastle and include all, i.e. code, 
links to PDF files and the image.



Tilman





Am 25.05.2017 um 12:42 schrieb Paresh Chouhan:
oh I cannot attach the image, see my work flow is something like this 
http://i64.tinypic.com/29v02u.png
so I am doing the signing on the client and reattaching the signed 
hash that I receive from client.


On Thu, May 25, 2017 at 4:09 PM Paresh Chouhan 
> wrote:


On Thu, May 25, 2017 at 3:13 PM Tilman Hausherr
> wrote:

Am 25.05.2017 um 08:22 schrieb Paresh Chouhan:
> Original PDF : https://www.mediafire.com/?bg9z4c9450v01io
> Signed PDF : https://www.mediafire.com/?fqvnf9mg50pfzjh

Thanks... I wanted to see the files first because I'm lazy and
had hoped
it's some obvious problem in the PDF itself, but it isn't. So
I looked
at your code... the signing is quite different than in our
example, why
is this so? The "CreateSignatureBase" class has the code to
produce the
signature.

That you mention a HSM isn't really relevant... At work, I'm
signing
with a PKI card and all I had to change was getting the keystore.

Tilman

-
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org

For additional commands, e-mail: users-h...@pdfbox.apache.org


workflow.png

-- 
Regards

Paresh Chouhan
https://github.com/pareshchouhan

--
Regards
Paresh Chouhan
https://github.com/pareshchouhan





Re: PDF Signing, generated PDF Document certification is invalid, using HSM

2017-05-25 Thread Paresh Chouhan
Hi  Diego,
Only thing is I am not discarding changes so my steps are more like
   - Grab original PDF
   - add signature dictionary and get the hash
   - send the hash to client
   - Wait for data on Standard Input.
   - Wait for Client to send the signed hash back, This data is then feeded
to the paused program, that is, the data is sent to standard input of the
program
   - add the CMS. :)

On Thu, May 25, 2017 at 7:07 PM Diego Azevedo  wrote:

> Hey, Paresh
>
> I had the same problem with a similar workflow, and glancing at your code I
> think you did the same as I did before:
>
>
>- Grab original PDF
>- add signature dictionary and get the hash
>- discart changes
>- send the hash to client
>- mount CMS package with information returned from client
>- grab original PDF
>- add signature dictionary AND the CMS
>
> This won't work. Adding the same dictionary, with the same information, in
> two different moments will create two different PDFs, with different
> hashes.
> The cause is the trailer dictionary. It has an ID entry that will always
> change.
>
> If that's really the cause (I only glanced at your code), you have two
> workarrounds:
>
>- Change PDFbox to create the same ID in different moments (It uses the
>document itself and I think it also uses "currentTimeInMilis" somewhere)
>- save your PDF with a garbage signature and update it latter with the
>CMS
>
>
>
>
> On Thu, May 25, 2017 at 7:42 AM, Paresh Chouhan <
> pareshchouhan2...@gmail.com
> > wrote:
>
> > oh I cannot attach the image, see my work flow is something like this
> > http://i64.tinypic.com/29v02u.png
> > so I am doing the signing on the client and reattaching the signed hash
> > that I receive from client.
> >
> > On Thu, May 25, 2017 at 4:09 PM Paresh Chouhan <
> > pareshchouhan2...@gmail.com> wrote:
> >
> >> On Thu, May 25, 2017 at 3:13 PM Tilman Hausherr 
> >> wrote:
> >>
> >>> Am 25.05.2017 um 08:22 schrieb Paresh Chouhan:
> >>> > Original PDF : https://www.mediafire.com/?bg9z4c9450v01io
> >>> > Signed PDF : https://www.mediafire.com/?fqvnf9mg50pfzjh
> >>>
> >>> Thanks... I wanted to see the files first because I'm lazy and had
> hoped
> >>> it's some obvious problem in the PDF itself, but it isn't. So I looked
> >>> at your code... the signing is quite different than in our example, why
> >>> is this so? The "CreateSignatureBase" class has the code to produce the
> >>> signature.
> >>>
> >>> That you mention a HSM isn't really relevant... At work, I'm signing
> >>> with a PKI card and all I had to change was getting the keystore.
> >>>
> >>> Tilman
> >>>
> >>> -
> >>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> >>> For additional commands, e-mail: users-h...@pdfbox.apache.org
> >>>
> >> [image: workflow.png]
> >>>
> >> --
> >> Regards
> >> Paresh Chouhan
> >> https://github.com/pareshchouhan
> >>
> > --
> > Regards
> > Paresh Chouhan
> > https://github.com/pareshchouhan
> >
>
>
>
> --
> []'s
>
> Diego Azevedo
>
-- 
Regards
Paresh Chouhan
https://github.com/pareshchouhan


Re: PDF Signing, generated PDF Document certification is invalid, using HSM

2017-05-25 Thread Diego Azevedo
Hey, Paresh

I had the same problem with a similar workflow, and glancing at your code I
think you did the same as I did before:


   - Grab original PDF
   - add signature dictionary and get the hash
   - discart changes
   - send the hash to client
   - mount CMS package with information returned from client
   - grab original PDF
   - add signature dictionary AND the CMS

This won't work. Adding the same dictionary, with the same information, in
two different moments will create two different PDFs, with different hashes.
The cause is the trailer dictionary. It has an ID entry that will always
change.

If that's really the cause (I only glanced at your code), you have two
workarrounds:

   - Change PDFbox to create the same ID in different moments (It uses the
   document itself and I think it also uses "currentTimeInMilis" somewhere)
   - save your PDF with a garbage signature and update it latter with the
   CMS




On Thu, May 25, 2017 at 7:42 AM, Paresh Chouhan  wrote:

> oh I cannot attach the image, see my work flow is something like this
> http://i64.tinypic.com/29v02u.png
> so I am doing the signing on the client and reattaching the signed hash
> that I receive from client.
>
> On Thu, May 25, 2017 at 4:09 PM Paresh Chouhan <
> pareshchouhan2...@gmail.com> wrote:
>
>> On Thu, May 25, 2017 at 3:13 PM Tilman Hausherr 
>> wrote:
>>
>>> Am 25.05.2017 um 08:22 schrieb Paresh Chouhan:
>>> > Original PDF : https://www.mediafire.com/?bg9z4c9450v01io
>>> > Signed PDF : https://www.mediafire.com/?fqvnf9mg50pfzjh
>>>
>>> Thanks... I wanted to see the files first because I'm lazy and had hoped
>>> it's some obvious problem in the PDF itself, but it isn't. So I looked
>>> at your code... the signing is quite different than in our example, why
>>> is this so? The "CreateSignatureBase" class has the code to produce the
>>> signature.
>>>
>>> That you mention a HSM isn't really relevant... At work, I'm signing
>>> with a PKI card and all I had to change was getting the keystore.
>>>
>>> Tilman
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
>>> For additional commands, e-mail: users-h...@pdfbox.apache.org
>>>
>> [image: workflow.png]
>>>
>> --
>> Regards
>> Paresh Chouhan
>> https://github.com/pareshchouhan
>>
> --
> Regards
> Paresh Chouhan
> https://github.com/pareshchouhan
>



-- 
[]'s

Diego Azevedo


RE: what should PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

2017-05-25 Thread Gary Grosso
One more upload: 
http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip-also-TextField.pdf 

Contrary to what I inferred from "how to add tooltip" articles I read online, 
Acrobat allows me to add a tooltip to a textfield (not just a button), and it 
works just fine. 

This is so much nicer than foodling around with invisible buttons. It would be 
great if this just worked in PDFBox.

Gary


-Original Message-
From: Gary Grosso [mailto:gary.gro...@oberontech.com] 
Sent: Thursday, May 25, 2017 9:04 AM
To: users@pdfbox.apache.org
Subject: RE: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

I also uploaded http://aapro.net/PDF/DocBookTest3_modified_captionsByPDFBox.pdf 

-Original Message-
From: Gary Grosso [mailto:gary.gro...@oberontech.com] 
Sent: Thursday, May 25, 2017 8:54 AM
To: users@pdfbox.apache.org
Subject: RE: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

Yes, it does work if done with Acrobat, see 
http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip.pdf ( done using 
Button Properties > General > Tooltip).

I need general tooltip capability. Everywhere I look, this is done with 
buttons, sometimes invisible. This is perhaps the last requirement needed for a 
customer to choose PDFBox (and my services) for this work.

Can this be made to work, or can another way be described of getting tooltips 
(to appear on various form fields)?

One possibility seems to be using NormalCaption on an invisible button. I am 
able to make the button invisible, but not the caption text. Also, if I succeed 
in making the caption text invisible, I don't know if it will stay invisible 
when moused over.

Thanks,
Gary



-Original Message-
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Thursday, May 25, 2017 4:21 AM
To: users@pdfbox.apache.org
Subject: Re: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

According to the PDF spec: "(Optional; pushbutton fields only) The widget 
annotation's rollover caption, which shall be displayed when the user rolls the 
cursor into its active area without pressing the mouse button."

The best would be to create such a file with Adobe Acrobat to see if it works 
at all.

Tilman


Am 25.05.2017 um 03:45 schrieb Gary Grosso:
> I was expecting 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption(String
>  caption) to display the value of argument caption when the user's mouse 
> rolled over the widget.
>
> I get the value passed to setNormalCaption() regardless. Is the problem with 
> my expectations, my usage, or the implementation?
>
> I'm morphing an existing PDF document, finding locations based on a kludge, 
> since this is still proof-of-principle, so I only show the one method below. 
> I can write a create-PDF-from-scratch driver for the method if necessary.
>
> Thanks,
> Gary
>
>  private static void addButtonAtRect(PDPage page, PDAcroForm acroForm, 
> String text, PDRectangle rect) {
>  PDPushButton pushButton = new PDPushButton(acroForm);
>
>  // For now, just make sure each partial name is unique.
>  String nameStr = text.replaceAll(" ", "") + "Name" + 
> Integer.toString(nameCnt);
>  nameCnt++;
>  pushButton.setPartialName(nameStr);
>
>  acroForm.getFields().add(pushButton);
>
>  PDAnnotationWidget widget = pushButton.getWidgets().get(0);
>  widget.setRectangle(rect);
>  if (rect.getHeight() < MIN_RECT_HEIGHT) {
>  float diff = MIN_RECT_HEIGHT - rect.getHeight();
>  rect.setLowerLeftY((float) (rect.getLowerLeftY() - diff/2.0));
>  rect.setUpperRightY((float) (rect.getUpperRightY() + diff/2.0));
>  }
>
>  widget.setPage(page);
>
>  String jsString = "app.alert(\"" + text + " Performed.\");";
>
>  //Creating PDActionJavaScript object
>  PDActionJavaScript action = new PDActionJavaScript(jsString);
>  widget.setAction(action);
>
>  acroForm.setNeedAppearances(true);
>
>  PDAppearanceCharacteristicsDictionary fieldAppearance = new 
> PDAppearanceCharacteristicsDictionary(new COSDictionary());
>  fieldAppearance.setBorderColour(new PDColor(new float[]{0.3F, 0.3F, 
> 0.7F}, PDDeviceRGB.INSTANCE));
>  fieldAppearance.setBackground(new PDColor(new float[]{0.9F, 0.9F, 
> 0.9F}, PDDeviceRGB.INSTANCE));
>  fieldAppearance.setNormalCaption("This is my NormalCaption");
>  fieldAppearance.setRolloverCaption("This is my RolloverCaption");
>  fieldAppearance.setAlternateCaption("This is my AlternateCaption");
>

RE: what should PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

2017-05-25 Thread Gary Grosso
I also uploaded http://aapro.net/PDF/DocBookTest3_modified_captionsByPDFBox.pdf 

-Original Message-
From: Gary Grosso [mailto:gary.gro...@oberontech.com] 
Sent: Thursday, May 25, 2017 8:54 AM
To: users@pdfbox.apache.org
Subject: RE: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

Yes, it does work if done with Acrobat, see 
http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip.pdf ( done using 
Button Properties > General > Tooltip).

I need general tooltip capability. Everywhere I look, this is done with 
buttons, sometimes invisible. This is perhaps the last requirement needed for a 
customer to choose PDFBox (and my services) for this work.

Can this be made to work, or can another way be described of getting tooltips 
(to appear on various form fields)?

One possibility seems to be using NormalCaption on an invisible button. I am 
able to make the button invisible, but not the caption text. Also, if I succeed 
in making the caption text invisible, I don't know if it will stay invisible 
when moused over.

Thanks,
Gary



-Original Message-
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Thursday, May 25, 2017 4:21 AM
To: users@pdfbox.apache.org
Subject: Re: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

According to the PDF spec: "(Optional; pushbutton fields only) The widget 
annotation's rollover caption, which shall be displayed when the user rolls the 
cursor into its active area without pressing the mouse button."

The best would be to create such a file with Adobe Acrobat to see if it works 
at all.

Tilman


Am 25.05.2017 um 03:45 schrieb Gary Grosso:
> I was expecting 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption(String
>  caption) to display the value of argument caption when the user's mouse 
> rolled over the widget.
>
> I get the value passed to setNormalCaption() regardless. Is the problem with 
> my expectations, my usage, or the implementation?
>
> I'm morphing an existing PDF document, finding locations based on a kludge, 
> since this is still proof-of-principle, so I only show the one method below. 
> I can write a create-PDF-from-scratch driver for the method if necessary.
>
> Thanks,
> Gary
>
>  private static void addButtonAtRect(PDPage page, PDAcroForm acroForm, 
> String text, PDRectangle rect) {
>  PDPushButton pushButton = new PDPushButton(acroForm);
>
>  // For now, just make sure each partial name is unique.
>  String nameStr = text.replaceAll(" ", "") + "Name" + 
> Integer.toString(nameCnt);
>  nameCnt++;
>  pushButton.setPartialName(nameStr);
>
>  acroForm.getFields().add(pushButton);
>
>  PDAnnotationWidget widget = pushButton.getWidgets().get(0);
>  widget.setRectangle(rect);
>  if (rect.getHeight() < MIN_RECT_HEIGHT) {
>  float diff = MIN_RECT_HEIGHT - rect.getHeight();
>  rect.setLowerLeftY((float) (rect.getLowerLeftY() - diff/2.0));
>  rect.setUpperRightY((float) (rect.getUpperRightY() + diff/2.0));
>  }
>
>  widget.setPage(page);
>
>  String jsString = "app.alert(\"" + text + " Performed.\");";
>
>  //Creating PDActionJavaScript object
>  PDActionJavaScript action = new PDActionJavaScript(jsString);
>  widget.setAction(action);
>
>  acroForm.setNeedAppearances(true);
>
>  PDAppearanceCharacteristicsDictionary fieldAppearance = new 
> PDAppearanceCharacteristicsDictionary(new COSDictionary());
>  fieldAppearance.setBorderColour(new PDColor(new float[]{0.3F, 0.3F, 
> 0.7F}, PDDeviceRGB.INSTANCE));
>  fieldAppearance.setBackground(new PDColor(new float[]{0.9F, 0.9F, 
> 0.9F}, PDDeviceRGB.INSTANCE));
>  fieldAppearance.setNormalCaption("This is my NormalCaption");
>  fieldAppearance.setRolloverCaption("This is my RolloverCaption");
>  fieldAppearance.setAlternateCaption("This is my AlternateCaption");
>  widget.setAppearanceCharacteristics(fieldAppearance);
>
>  widget.setPrinted(true);
>
>  try {
>  page.getAnnotations().add(widget);
>  } catch (IOException e) {
>  e.printStackTrace();
>  }
>  }
>
>
>
>


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


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

RE: what should PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

2017-05-25 Thread Gary Grosso
Yes, it does work if done with Acrobat, see 
http://aapro.net/PDF/DocBookTest3_modified_w-Acrobat-Tooltip.pdf ( done using 
Button Properties > General > Tooltip).

I need general tooltip capability. Everywhere I look, this is done with 
buttons, sometimes invisible. This is perhaps the last requirement needed for a 
customer to choose PDFBox (and my services) for this work.

Can this be made to work, or can another way be described of getting tooltips 
(to appear on various form fields)?

One possibility seems to be using NormalCaption on an invisible button. I am 
able to make the button invisible, but not the caption text. Also, if I succeed 
in making the caption text invisible, I don't know if it will stay invisible 
when moused over.

Thanks,
Gary



-Original Message-
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Thursday, May 25, 2017 4:21 AM
To: users@pdfbox.apache.org
Subject: Re: what should 
PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

According to the PDF spec: "(Optional; pushbutton fields only) The widget 
annotation's rollover caption, which shall be displayed when the user rolls the 
cursor into its active area without pressing the mouse button."

The best would be to create such a file with Adobe Acrobat to see if it works 
at all.

Tilman


Am 25.05.2017 um 03:45 schrieb Gary Grosso:
> I was expecting 
> PDAppearanceCharacteristicsDictionary.setRolloverCaption(String
>  caption) to display the value of argument caption when the user's mouse 
> rolled over the widget.
>
> I get the value passed to setNormalCaption() regardless. Is the problem with 
> my expectations, my usage, or the implementation?
>
> I'm morphing an existing PDF document, finding locations based on a kludge, 
> since this is still proof-of-principle, so I only show the one method below. 
> I can write a create-PDF-from-scratch driver for the method if necessary.
>
> Thanks,
> Gary
>
>  private static void addButtonAtRect(PDPage page, PDAcroForm acroForm, 
> String text, PDRectangle rect) {
>  PDPushButton pushButton = new PDPushButton(acroForm);
>
>  // For now, just make sure each partial name is unique.
>  String nameStr = text.replaceAll(" ", "") + "Name" + 
> Integer.toString(nameCnt);
>  nameCnt++;
>  pushButton.setPartialName(nameStr);
>
>  acroForm.getFields().add(pushButton);
>
>  PDAnnotationWidget widget = pushButton.getWidgets().get(0);
>  widget.setRectangle(rect);
>  if (rect.getHeight() < MIN_RECT_HEIGHT) {
>  float diff = MIN_RECT_HEIGHT - rect.getHeight();
>  rect.setLowerLeftY((float) (rect.getLowerLeftY() - diff/2.0));
>  rect.setUpperRightY((float) (rect.getUpperRightY() + diff/2.0));
>  }
>
>  widget.setPage(page);
>
>  String jsString = "app.alert(\"" + text + " Performed.\");";
>
>  //Creating PDActionJavaScript object
>  PDActionJavaScript action = new PDActionJavaScript(jsString);
>  widget.setAction(action);
>
>  acroForm.setNeedAppearances(true);
>
>  PDAppearanceCharacteristicsDictionary fieldAppearance = new 
> PDAppearanceCharacteristicsDictionary(new COSDictionary());
>  fieldAppearance.setBorderColour(new PDColor(new float[]{0.3F, 0.3F, 
> 0.7F}, PDDeviceRGB.INSTANCE));
>  fieldAppearance.setBackground(new PDColor(new float[]{0.9F, 0.9F, 
> 0.9F}, PDDeviceRGB.INSTANCE));
>  fieldAppearance.setNormalCaption("This is my NormalCaption");
>  fieldAppearance.setRolloverCaption("This is my RolloverCaption");
>  fieldAppearance.setAlternateCaption("This is my AlternateCaption");
>  widget.setAppearanceCharacteristics(fieldAppearance);
>
>  widget.setPrinted(true);
>
>  try {
>  page.getAnnotations().add(widget);
>  } catch (IOException e) {
>  e.printStackTrace();
>  }
>  }
>
>
>
>


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


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



Re: PDF Signing, generated PDF Document certification is invalid, using HSM

2017-05-25 Thread Paresh Chouhan
oh I cannot attach the image, see my work flow is something like this
http://i64.tinypic.com/29v02u.png
so I am doing the signing on the client and reattaching the signed hash
that I receive from client.

On Thu, May 25, 2017 at 4:09 PM Paresh Chouhan 
wrote:

> On Thu, May 25, 2017 at 3:13 PM Tilman Hausherr 
> wrote:
>
>> Am 25.05.2017 um 08:22 schrieb Paresh Chouhan:
>> > Original PDF : https://www.mediafire.com/?bg9z4c9450v01io
>> > Signed PDF : https://www.mediafire.com/?fqvnf9mg50pfzjh
>>
>> Thanks... I wanted to see the files first because I'm lazy and had hoped
>> it's some obvious problem in the PDF itself, but it isn't. So I looked
>> at your code... the signing is quite different than in our example, why
>> is this so? The "CreateSignatureBase" class has the code to produce the
>> signature.
>>
>> That you mention a HSM isn't really relevant... At work, I'm signing
>> with a PKI card and all I had to change was getting the keystore.
>>
>> Tilman
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
>> For additional commands, e-mail: users-h...@pdfbox.apache.org
>>
> [image: workflow.png]
>>
> --
> Regards
> Paresh Chouhan
> https://github.com/pareshchouhan
>
-- 
Regards
Paresh Chouhan
https://github.com/pareshchouhan


Re: PDF Signing, generated PDF Document certification is invalid, using HSM

2017-05-25 Thread Paresh Chouhan
On Thu, May 25, 2017 at 3:13 PM Tilman Hausherr 
wrote:

> Am 25.05.2017 um 08:22 schrieb Paresh Chouhan:
> > Original PDF : https://www.mediafire.com/?bg9z4c9450v01io
> > Signed PDF : https://www.mediafire.com/?fqvnf9mg50pfzjh
>
> Thanks... I wanted to see the files first because I'm lazy and had hoped
> it's some obvious problem in the PDF itself, but it isn't. So I looked
> at your code... the signing is quite different than in our example, why
> is this so? The "CreateSignatureBase" class has the code to produce the
> signature.
>
> That you mention a HSM isn't really relevant... At work, I'm signing
> with a PKI card and all I had to change was getting the keystore.
>
> Tilman
>
> -
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
> [image: workflow.png]
>
-- 
Regards
Paresh Chouhan
https://github.com/pareshchouhan


Re: PDF Signing, generated PDF Document certification is invalid, using HSM

2017-05-25 Thread Tilman Hausherr

Am 25.05.2017 um 08:22 schrieb Paresh Chouhan:

Original PDF : https://www.mediafire.com/?bg9z4c9450v01io
Signed PDF : https://www.mediafire.com/?fqvnf9mg50pfzjh


Thanks... I wanted to see the files first because I'm lazy and had hoped 
it's some obvious problem in the PDF itself, but it isn't. So I looked 
at your code... the signing is quite different than in our example, why 
is this so? The "CreateSignatureBase" class has the code to produce the 
signature.


That you mention a HSM isn't really relevant... At work, I'm signing 
with a PKI card and all I had to change was getting the keystore.


Tilman

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



Re: what should PDAppearanceCharacteristicsDictionary.setRolloverCaption do?

2017-05-25 Thread Tilman Hausherr
According to the PDF spec: "(Optional; pushbutton fields only) The 
widget annotation’s rollover caption, which shall be displayed when the 
user rolls the cursor into its active area without pressing the mouse 
button."


The best would be to create such a file with Adobe Acrobat to see if it 
works at all.


Tilman


Am 25.05.2017 um 03:45 schrieb Gary Grosso:

I was expecting 
PDAppearanceCharacteristicsDictionary.setRolloverCaption(String
 caption) to display the value of argument caption when the user's mouse rolled over 
the widget.

I get the value passed to setNormalCaption() regardless. Is the problem with my 
expectations, my usage, or the implementation?

I'm morphing an existing PDF document, finding locations based on a kludge, 
since this is still proof-of-principle, so I only show the one method below. I 
can write a create-PDF-from-scratch driver for the method if necessary.

Thanks,
Gary

 private static void addButtonAtRect(PDPage page, PDAcroForm acroForm, 
String text, PDRectangle rect) {
 PDPushButton pushButton = new PDPushButton(acroForm);

 // For now, just make sure each partial name is unique.
 String nameStr = text.replaceAll(" ", "") + "Name" + 
Integer.toString(nameCnt);
 nameCnt++;
 pushButton.setPartialName(nameStr);

 acroForm.getFields().add(pushButton);

 PDAnnotationWidget widget = pushButton.getWidgets().get(0);
 widget.setRectangle(rect);
 if (rect.getHeight() < MIN_RECT_HEIGHT) {
 float diff = MIN_RECT_HEIGHT - rect.getHeight();
 rect.setLowerLeftY((float) (rect.getLowerLeftY() - diff/2.0));
 rect.setUpperRightY((float) (rect.getUpperRightY() + diff/2.0));
 }

 widget.setPage(page);

 String jsString = "app.alert(\"" + text + " Performed.\");";

 //Creating PDActionJavaScript object
 PDActionJavaScript action = new PDActionJavaScript(jsString);
 widget.setAction(action);

 acroForm.setNeedAppearances(true);

 PDAppearanceCharacteristicsDictionary fieldAppearance = new 
PDAppearanceCharacteristicsDictionary(new COSDictionary());
 fieldAppearance.setBorderColour(new PDColor(new float[]{0.3F, 0.3F, 
0.7F}, PDDeviceRGB.INSTANCE));
 fieldAppearance.setBackground(new PDColor(new float[]{0.9F, 0.9F, 
0.9F}, PDDeviceRGB.INSTANCE));
 fieldAppearance.setNormalCaption("This is my NormalCaption");
 fieldAppearance.setRolloverCaption("This is my RolloverCaption");
 fieldAppearance.setAlternateCaption("This is my AlternateCaption");
 widget.setAppearanceCharacteristics(fieldAppearance);

 widget.setPrinted(true);

 try {
 page.getAnnotations().add(widget);
 } catch (IOException e) {
 e.printStackTrace();
 }
 }







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



Re: How do I specify the google noto font with printed

2017-05-25 Thread Tilman Hausherr

Am 25.05.2017 um 08:01 schrieb Rock Lin:

Hi Sir:
I used the PDDocument.load(PdfInputStream) to load a PDF File.

And I want to print this PDF use google noto
font(NotoSansCJKtc-Regular.otf).(The PDF has many chinese word)

How did I do?


You can't, at least not out of the box. It wouldn't make sense, because 
a PDF decides itself what fonts are to be used. If the fonts are not 
embedded, then you should get the missing font and install it on your 
system. When fonts are missing, PDFBox tries to map to an existing font.


Alternatively, set your own fontmapper. To do this, download the source 
code and have a look at the implementation of FontMapperImpl. Create 
your own and install it with FontMappers.set(new MyNewFontMapper());


Tilman

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



How do I specify the google noto font with printed

2017-05-25 Thread Rock Lin
Hi Sir:
I used the PDDocument.load(PdfInputStream) to load a PDF File.

And I want to print this PDF use google noto
font(NotoSansCJKtc-Regular.otf).(The PDF has many chinese word)

How did I do?

Thanks for your help!


RE: Warning about document close

2017-05-25 Thread Vassallo, Fabio
Good morning.
Yesterday I finally had the time to thoroughly debug  my code: it was actually 
my fault.
In certain cases I didn't close a document and PDFBox was right to point it out.

Thank you,
Fabio


Fabio Vassallo
Product Development (CIS)


Würth Phoenix S.r.l.
via Kravogl 4, 39100 Bolzano
T: +39 0471 564 116
F: +39 0471 564 122
Website | e-Mail | Map

      

-Original Message-
From: Tilman Hausherr [mailto:thaush...@t-online.de] 
Sent: Tuesday, May 16, 2017 11:52 AM
To: users@pdfbox.apache.org
Subject: Re: Warning about document close

Am 16.05.2017 um 08:54 schrieb Vassallo, Fabio:
>
> Good morning.
>
> In my job I have to create several kind of documents.
>
> I also have a user task that allows to create a single document by 
> merging some (or many) of these documents.
>
> So I create each document to merge, create and save the merged 
> document, close it.
>
> After that I call PDDocument.close() on each of the original document.
>
> Everything works fine if I merge a little number of PDDocuments (I'm 
> sure I call close() on each one); but if I merge many documents (and 
> so the procedure last a longer time), I get a warning:
>
> Warning: You did not close a PDF Document
>

Hard to tell without code. You must close every PDDocument that you open or 
create. Use "try with resources" if possible.

Tilman

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



Re: PDF Signing, generated PDF Document certification is invalid, using HSM

2017-05-25 Thread Paresh Chouhan
Original PDF : https://www.mediafire.com/?bg9z4c9450v01io
Signed PDF : https://www.mediafire.com/?fqvnf9mg50pfzjh
^Tilman :)


On Thu, May 25, 2017 at 12:28 AM Tilman Hausherr 
wrote:

> Hi,
> Please upload your signed PDF file to a public location.
> Tilman
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>
> --
Regards
Paresh Chouhan
https://github.com/pareshchouhan