|
<SfPdfViewerServer ID="pdfviewer" @ref="@PdfViewer" DocumentPath="@documentPath">
<PdfViewerEvents Created="created"></PdfViewerEvents>
</SfPdfViewerServer>
private void created()
{
var document = new PdfDocument();
byte[] bytes;
//Add a new page to the PDF document.
PdfPage page = document.Pages.Add();
//Create a textbox field and add the properties.
PdfTextBoxField textBoxField = new PdfTextBoxField(page, "FirstName");
textBoxField.Bounds = new RectangleF(0, 0, 100, 20);
textBoxField.ToolTip = "First Name";
//Add the form field to the document.
document.Form.Fields.Add(textBoxField);
//stream.Position = 0;
var stream = new MemoryStream();
//Save the document.
document.Save(stream);
bytes = stream.ToArray();
string base64string = Convert.ToBase64String(bytes);
documentPath = "data:application/pdf;base64," + base64string;
//close the document
document.Close(true);
}
|
|
Query |
Details | |
|
It doesn't work. The compiler complains that various components (SfTab, etc.) are defined in more than one assembly when I use SfPdfViewerServer. |
From the release (v18.4.0.30), the Syncfusion Blazor UI components are separately available in individual NuGet packages. The NuGet packages are segregated based on the component usage and its namespace. we suggest you use only Syncfusion.Blazor.PdfViewerServer.Windows instead of Syncfusion.Blazor NuGet packages. Please find the documentation from the below link.
Note : Do not use both Syncfusion.Blazor and individual NuGet packages in the same application. It will throw ambiguous errors while compiling the project.
| |
|
When I use SfPdfViewer, I can see the PDF viewer but the spinner keeps going and nothing loads, even when I open a file by clicking the folder icon on the viewer toolbar. I have attached a sample project that shows the issue.
|
We have checked the sample that you have used the SfPdfViewer tag. Our Blazor client-side PDF Viewer control depends on server-side processing to render the PDF files, it is mandatory to set the serviceUrl property. But you have missed the serviceUrl property. So, the issue occurs. Kindly modify the code snippet as like below. And we have shared the sample for your reference. You can create your own web service using the below KB link:
Blazor UG Documentation:
Code snippet:
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfDocumentTest2110347958
|