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 1 commit
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
73 changes: 73 additions & 0 deletions knowledge-base/pdfviewer-upload-controls-visibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: Handle Upload Controls Visibility in TelerikPdfViewer
description: Learn how to manage the visibility of upload controls in TelerikPdfViewer when loading a PDF file.
type: how-to
page_title: How to Control Upload Component Visibility in TelerikPdfViewer
slug: pdfviewer-kb-upload-controls-visibility
tags: pdfviewer, blazor, upload controls, visibility, enableloadercontainer
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 controls 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 manage control visibility?

## Solution

To control the visibility of upload controls in the `TelerikPdfViewer` while a PDF is loading, apply custom CSS to hide the upload controls. This can be achieved by leveraging 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>
.my-pdf .k-external-dropzone {
display: none;
}

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

private async Task OnPdfOpen(PdfViewerOpenEventArgs args)
{
//hide upload controls
PdfClass = "my-pdf";
}

protected override void OnInitialized()
{
base.OnInitialized();
}
}
````

## See Also

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