How to print html to pdf with copying being locked?

429 views Asked by At

I'm creating pdf files, by using the android printing framework, by loading html into a webview. This webview then gets printed and one of the selections of androids print manager is to create a pdf file.

But a client asked me to forbid users from copying text via CTRL+C from the documents that are created by my app. After a bit of searching I found that I, if I understood correctly, have to lock the right to copy from the pdf with a password. But i found nothing on how to do this in android. Does anyone have any suggestions on how to set this password?

The code I'm currently using is this:

PrintManager printManager = (PrintManager) getActivity().getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter;
if(android.os.Build.VERSION.SDK_INT >= 21){
    printAdapter = webView.createPrintDocumentAdapter(jobName);
}else{
    printAdapter = webView.createPrintDocumentAdapter();
}

PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMinMargins(PrintAttributes.Margins.NO_MARGINS);
builder.setMediaSize(PrintAttributes.MediaSize.ISO_A4);

File filePdf = new File(pathAndJobName);
printManager.print(filePdf.getName(), printAdapter, builder.build());
0

There are 0 answers