There are several ways to do this.
Only โPrint Onlyโ or โScreen Onlyโ can be set in the form fields. "Only icons" Key fields can have any appearance. Acrobat's user interface allows you to import any PDF page, and APIs that allow you to create fields will usually let you draw on your own.
Optional content groups (aka layers). OCG can have separate ON and OFF states for screen and printing. OCG is a relatively advanced feature supported only by more mature APIs.
I am a fan (and contributor) of iText, a Java library that is quite capable of both methods. It would be easier to create a button for icons only.
PushbuttonField iconButton = new PushbuttonField(myPdfWriter, rectangle, fieldName); iconButton.setLayout(PushbuttonField.LAYOUT_ICON_ONLY); iconButton.setScaleIcon(PushbuttonField.SCALE_ICON_ALWAYS); iconButton.setVisibility(BaseField.HIDDEN_BUT_PRINTABLE); PdfImportedPage iconAppearance = myPdfWriter.getImportedPage(pdfReader, pageNum); iconButton.setTemplate(iconAppearance); myPdfWriter.addAnnotation(iconButton.getField());
This assumes that you know the rectangle that will be used to create the PDF, and have a PDF page with a black and white logo.
NOTE. iText is licensed under AGPL, which requires that anyone with access to the OUTPUT program also have access to the source. AKA: Commercially hostile. Or you can buy a commercial license. Previous versions were available in MPL or LGPL, but are no longer supported, stored in such places. Even then, the answer is increasingly "getting a newer version."
source share