Copy link to clipboard
Copied
Hello -
So I've disabled printing and downloading in the embed API per the documentation (showPrintPDF and showDownloadPDF are set to false). I've also set a css attribute to @media print { display: none} for the container div. Both of these methods work and cover the file -> print (PDF does not display in file -> print which is good). However, when a user mouses over the document and hit CTRL (CMD) + P, they are still able to print. How can this be disabled? I've tried the @media print route with no luck.
Screenshot attached of the print dialog that comes up with CTRL + P.
Copy link to clipboard
Copied
When showPrintPDF is false, Embed API will not print the PDF file through its own print code, however, the browser will still print the contents of the body tag. With the embed mode set to "IN_LINE", it will appear that the PDF is printing when in fact it isn't. To prevent the printing of the contents of the element that Embed API draws into, add a CSS statement to hide the element that you are using for the divId. Be sure to add !important because... well... it's important.
Note: I've only tested this in Chrome. Let me know if you are seeing other behavior in other browsers and please be specific as to version numbers.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Shouldn't Print</title>
<style>
body {
padding: 0;
margin: 0;
}
@media print {
.noprint {
display: none !important;
}
}
</style>
</style>
</head>
<body>
<div id="adobe-dc-view" class="noprint"></div>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
<script type="text/javascript">
document.addEventListener("adobe_dc_view_sdk.ready", function () {
var adobeDCView = new AdobeDC.View({ clientId: "cdd2f1b0e6e84f7a8eb71e7ac84530fa", divId: "adobe-dc-view" });
adobeDCView.previewFile({
content: { location: { url: "bodea-summary.pdf" } },
metaData: { fileName: "Bodea Summary.pdf" }
}, { showPrintPDF: false, embedMode: "IN_LINE" });
});
</script>
</body>
</html>
Copy link to clipboard
Copied
Hi, thanks for the detailed answer - followed this but still having the issue. I'm able to select Save as PDF in the print dialog and I'm still able to successfully save it and print it using this method. But, specifically through CTRL + P - this method works on File -> Print.
Copy link to clipboard
Copied
What browser and OS, include version numbers.
Copy link to clipboard
Copied
Ends up, I am seeing the behavior described in Safari. The mouse must be over the embedded view when CTRL-P is pressed and it only prints the PDF the first time. The correct behavior happens each subsequent time.
I can see we already have a bug filed against this so stay tuned.
Copy link to clipboard
Copied
Hay una actualizacion con respecto a este tema
Copy link to clipboard
Copied
Hi Joel,
I am observing the same bug on latest version of Chrome as well. Already tried the suggested solution but in vain.
I see that this conversation is quite old but can you shed some light on this one ?
Thanks !
Copy link to clipboard
Copied
He resuelto el tema hasta ahora protegiendo el archivo con "PDF Services API"
de esta manera al generar el PDF le quito el permiso de imprimir "Protect PDF"
https://developer.adobe.com/document-services/docs/overview/pdf-services-api/howtos/protect-pdf/
y al abrir el PDF muestra el siguiente resultado
de la misma manera adobe deja algunos ejemplos de como hacerlo para este caso con JAVA
https://github.com/adobe/pdfservices-java-sdk-samples
Copy link to clipboard
Copied
I'll give this a try. Thanks !
Copy link to clipboard
Copied
The problem now is that we are not using any of the supported backend tech. This workaround won't solve the issue for us. I am more curious about a response from @Joel_Geraci / @Sumona Ghosh now.
Copy link to clipboard
Copied
Anything @Sumona Ghosh / @Joel_Geraci ?
Copy link to clipboard
Copied
Hi, Any update on this? I have followed this but still facing the issue [chrome].
Copy link to clipboard
Copied
Hello,
Sorry to hear that you are facing this issue. Which embed mode do you use to display the PDF?
Copy link to clipboard
Copied
IN_LINE
Copy link to clipboard
Copied
We have rolled out a fix for this issue. Please let us know if you still face it. Thanks!
Copy link to clipboard
Copied
Hi, I still having the same problem as @defaultbssold8ngxvl.
Copy link to clipboard
Copied
@Joel_Geraci I'm using SIZED_CONTAINER.
Copy link to clipboard
Copied
I solved this by Capturing PDF Embed API Events, when a user try to print it returns a "DOCUMENT_PRINT" type event, so there u can handle it.
Keep in mind that this is a callback, so the printing cannot be stopped by setting an event.preventdefault, my solution has been to reload the page so the printing is cancelled, it is not the cleanest solution but it is the only one that I have found.
Heres a code example:
Copy link to clipboard
Copied
Thankyou