Skip to content

Update toolbar-customization.md #4853

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
86 changes: 44 additions & 42 deletions blazor/pdfviewer-2/toolbar-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ To customize the Primary Toolbar in the PDF Viewer, you can achieve this by sett

@code{
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
SfPdfViewer2 Viewer;
MemoryStream stream;
SfPdfViewer2 Viewer = default!;
MemoryStream stream = default!;

// List provide the position and element for the custom toolbar items
public List<PdfToolbarItem> CustomToolbarItems = new List<PdfToolbarItem>()
Expand All @@ -253,45 +253,47 @@ To customize the Primary Toolbar in the PDF Viewer, you can achieve this by sett
// Get the renderfragment element for the custom toolbaritems in the primary toolbar
private static RenderFragment GetTemplate(string name)
{
return __builder =>
{
if (name == "PreviousPage")
{
<ToolbarItem PrefixIcon="e-icons e-chevron-up"
Text="Previous Page"
TooltipText="Previous Page"
Id="previousPage"
Align="ItemAlign.Left">
</ToolbarItem>
}
else if(name == "NextPage")
{
<ToolbarItem PrefixIcon="e-icons e-chevron-down"
Text="Next Page"
TooltipText="Next Page"
Id="nextPage"
Align="ItemAlign.Left">
</ToolbarItem>
}
else if(name == "Save")
{
<ToolbarItem PrefixIcon="e-icons e-save"
Text="Save"
TooltipText="Save Document"
Id="save"
Align="ItemAlign.Right">
</ToolbarItem>
}
else if(name == "Download")
{
<ToolbarItem PrefixIcon="e-icons e-download"
Text="Download"
TooltipText="Download"
Id="download"
Align="ItemAlign.Right">
</ToolbarItem>
}
};
if (name == "PreviousPage")
{
return @<ToolbarItem PrefixIcon="e-icons e-chevron-up"
Text="Previous Page"
TooltipText="Previous Page"
Id="previousPage"
Align="ItemAlign.Left">
</ToolbarItem>;
}

if (name == "NextPage")
{
return @<ToolbarItem PrefixIcon="e-icons e-chevron-down"
Text="Next Page"
TooltipText="Next Page"
Id="nextPage"
Align="ItemAlign.Left">
</ToolbarItem>;
}

if (name == "Save")
{
return @<ToolbarItem PrefixIcon="e-icons e-save"
Text="Save"
TooltipText="Save Document"
Id="save"
Align="ItemAlign.Right">
</ToolbarItem>;
}

if (name == "Download")
{
return @<ToolbarItem PrefixIcon="e-icons e-download"
Text="Download"
TooltipText="Download"
Id="download"
Align="ItemAlign.Right">
</ToolbarItem>;
}

return _ => { };
}

// Click for the custom toolbaritems in the primary toolbar
Expand Down Expand Up @@ -438,4 +440,4 @@ You can customize the appearance of the toolbar icons. The below code illustrate

[View sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Toolbar/Custom%20Toolbar/Primary%20Custom%20Toolbar%20-%20SfPdfViewer/Icon-Style-Change).

N> This is applicable only for custom toolbar.
N> This is applicable only for custom toolbar.