For example, you send a PDF document containing an invoice to a client, you want them to view your logo in it in color on the screen but when printed, you want your logo to be printed in its printable black / white version, is that possible? Thank you.
Thus, what you see on the screen (even in Print Preview) could differ slightly from when the document is actually printed. Why? Because when the printed document is handed over to the printer driver, then the printer's metrics are used instead of Word's internal metrics.
The answer, in a word, is margins. And depending on the PDF document and the capabilities of your printer, you may, or may not, be able to work around it. Most PDF documents are intended to be a representation of an equivalent paper document. That means that they're typically sized as if they were paper.
Corrupted fonts can also cause a problem printing PDF files. Reloading the fonts used may correct the problem. Your printer driver or firmware could also be a source of misprints or failure to print. If you get an out of memory error, the PDF could be too large for the printer to process.
There are a couple ways to do it.
Form fields can be set to "Print only" or "screen only". "Icon Only" Pushbutton fields can have an arbitrary appearance. Acrobat's UI will let you import any PDF page, and APIs that let you generate fields will generally let you draw your own appearances.
Optional Content Groups (aka layers). An OCG can have separate ON and OFF states for screen and print. OCGs are a relatively advanced feature, only supported by more mature APIs.
I'm a fan (and contributor) to iText, a Java library which is quite capable of both methods. It would be easier to build the icon-only button.
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 presumes you know the rectangle to use when generating the PDF, and have a PDF page holding the black-and-white logo.
NOTE: iText is licensed under the AGPL, which requires that anyone with access to the program's OUTPUT also have access to the source. AKA: Commercially hostile. Or you can buy a commercial license. Previous versions were available under the MPL or LGPL, but are no longer supported, save in places like this, Even then the answer is increasingly "get a newer version".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With