Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Display watermark only when document is printed

Question

Is it possible to make a watermark display on the pages of my document only when the document is printed?

So for example, the user would be able to read my PDF on their computer without seeing the watermark, but when they print the document, the watermark would appear on the printed paper.

Answer

Yes, it's definitely possible to have a watermark displayed only when a page is printed. I've included some basic sample code for this below.

QP.UnlockKey(' ...license key... ');
QP.DrawText(100, 500, 'No OCG (View and print)');

QP.NewLayer;
QP.DrawText(100, 400, 'Apple OCG (No view, print)');
OC1 := QP.NewOptionalContentGroup('Apple');
QP.SetLayerOptional(OC1);

QP.NewLayer;
QP.DrawText(100, 300, 'Banana OCG (View, no print)');
OC2 := QP.NewOptionalContentGroup('Banana');
QP.SetLayerOptional(OC2);

QP.SetOptionalContentGroupVisible(OC1, 0);
QP.SetOptionalContentGroupPrintable(OC1, 1);
QP.SetOptionalContentGroupVisible(OC2, 1);
QP.SetOptionalContentGroupPrintable(OC2, 0);

QP.SaveToFile('qplwatermark.pdf');

Please note: this example demonstrates how to do it both ways -- that is to say, how to have the watermark displayed on screen but not printed, and how to have the watermark not shown on the screen, but printed. It's easy to switch between the two options.

In addition, you may like to add some PDF security to the document so that the end-user can't delete the optional content groups/layers.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum