Skip to content

Added new kb article pdfviewer-upload-controls-visibility #2739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions knowledge-base/pdfviewer-upload-controls-visibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: How to Hide Upload Component in TelerikPdfViewer
description: Learn how to hide the Upload component in TelerikPdfViewer when loading a PDF file.
type: how-to
page_title: How to Hide Upload Component in TelerikPdfViewer
slug: pdfviewer-kb-hide-upload
tags: pdfviewer, blazor, upload, visibility, enableloadercontainer, hide
res_type: kb
ticketid: 1675214
---

## Environment

<table>
<tbody>
<tr>
<td>Product</td>
<td>PdfViewer for Blazor</td>
</tr>
</tbody>
</table>

## Description

When using the [TelerikPdfViewer](https://docs.telerik.com/blazor-ui/components/pdfviewer/overview) for Blazor, upload controls may still be visible while a PDF file is loading, even if the `EnableLoaderContainer` parameter is set to `false`.

This knowledge base article also answers the following questions:

- How to prevent interaction with Upload component while a PDF is loading in TelerikPdfViewer?
- How to hide Upload component in TelerikPdfViewer until the PDF file is fully loaded?
- How to use custom CSS with TelerikPdfViewer to hide Upload component?

## Solution

To control the visibility of Upload component in the `TelerikPdfViewer` while a PDF is loading, apply custom CSS to hide the upload controls. To achieve that, use the [`OnOpen`](slug://components/pdfviewer/events#onopen) event to apply a CSS class with the required styles that hide the controls until the PDF file is loaded successfully.

````RAZOR
<TelerikPdfViewer Data="@PdfSource"
Height="600px"
EnableLoaderContainer="false"
OnOpen="@OnPdfOpen"
Class="@PdfClass">
</TelerikPdfViewer>
<style>
.hide-pdf-upload .k-external-dropzone {
display: none;
}

.hide-pdf-upload .k-upload {
display: none;
}
</style>
@code {
private byte[] PdfSource { get; set; }
private string PdfClass { get; set; } = "";

private async Task OnPdfOpen(PdfViewerOpenEventArgs args)
{
//hide Upload component
PdfClass = "hide-pdf-upload";
}
}
````

## See Also

- [TelerikPdfViewer Overview](slug://components/pdfviewer/overview)
- [TelerikPdfViewer Events](slug://components/pdfviewer/events)