I was expecting 
PDAppearanceCharacteristicsDictionary.setRolloverCaption(String<eclipse-javadoc:%E2%98%82=Morph2Form/D:%5C/JavaTraining%5C/EclipseNeonWorkspace%5C/CreateSimpleForm%5C/lib%5C/pdfbox-2.0.6.jar%3Corg.apache.pdfbox.pdmodel.interactive.annotation(PDAppearanceCharacteristicsDictionary.class%E2%98%83PDAppearanceCharacteristicsDictionary~setRolloverCaption~Ljava.lang.String;%E2%98%82java.lang.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();
        }
    }



Reply via email to