Query |
Details |
I am unable to disable printing, the only way to prevent printing and downloading is by disabling the toolbar, it is all or nothing as long as the Toolbar is enabled all the toolbarItems are enabled whether or not you disable them as above. |
You can disable the print and download toolbar items by hiding the toolbar items from the toolbar of PDF Viewer control. Please find more details from the below documentation.
|
Can I please have a sample dealing with binary PDF stored in the database, in my case I cannot use the file system. |
Yes, we can load the PDF documents from the database in the PDF Viewer control. We have created ASP.NET Core application to load the PDF document as base64 string from the database using PDF Viewer control. It can be downloaded from the following link.
In the above sample, we have provided a button “Load PDF document as Base64String” in the page. When the button is clicked, a request will be sent to the sever to get the base64 string of the document stored in the database. This base64 string will be loaded in the PDF Viewer control after the completion of the request.
Note: Please modify the connection string and the variables as the per your database in the above sample.
Please confirm us that the above sample meets your requirements. If not, provide more details about your requirements. It will be helpful for us to analyze further and assist you better. |
<div id="target" style="display:block;height:600px">
<ejs-pdfviewer id="pdfviewer" style="height:750px"
serviceUrl="/api/PdfViewer"
documentPath="PDF Succinctly.pdf"
toolbarSettings="@(new Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings { ShowTooltip = true, ToolbarItem = "OpenOption,PageNavigationTool,MagnificationTool,PanTool,SelectionTool,SearchOption,DownloadOption,UndoRedoTool,AnnotationEditTool"})"></ejs-pdfviewer>
</div> |
public IActionResult Load([FromBody] Dictionary<string, string> jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
MemoryStream stream = new MemoryStream();
object jsonResult = new object();
if (jsonObject != null && jsonObject.ContainsKey("document"))
{
if (bool.Parse(jsonObject["isFileName"]))
{
//Gets the Pdf document as bytearray using its name from the database.
byte[] bytes = GetDocument(jsonObject["document"]);
stream = new MemoryStream(bytes);
}
else
{
byte[] bytes = Convert.FromBase64String(jsonObject["document"]);
stream = new MemoryStream(bytes);
}
}
jsonResult = pdfviewer.Load(stream, jsonObject);
return Content(JsonConvert.SerializeObject(jsonResult));
} |