PdfDocumentView ZoomPercentage is not updated instantly after load

Hi,

I have issue with PdfDocumentView

pdfDocumentView.LoadAsync(stream);
pdfDocumentView.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.FitPage;
int percentage = pdfDocumentView.ZoomPercentage;//always 100


but if I call another method having(pdfDocumentView.ZoomPercentage) like after 1 second of this, its correct percentage. Please fix this issue.


Version 27.2.2

.net8 - windows


1 Reply 1 reply marked as answer

KG Krithika Ganesan Syncfusion Team November 22, 2024 02:03 PM UTC

Hi John,


Upon analyzing the code snippet, we observe that the PDF is being loaded into the PdfViewer and the zoom mode is being set. At that moment, both the PdfViewer and the PDF document are not fully loaded, causing the zoom percentage to be retrieved incorrectly. Therefore, please obtain the zoom percentage of the PdfViewer in the `DocumentLoaded` event of PdfViewer. In the WPF PdfViewer, the zoom percentage for the `FitPage` zoom mode will be determined based on the loaded PDF pages. For your convenience, we have included a code snippet and a sample to serve as a reference.


public MainWindow()

{

    InitializeComponent();

    FileStream stream = new FileStream("../../../F#.pdf", FileMode.Open, FileAccess.ReadWrite);

    pdfDocumentView.LoadAsync(stream);

    pdfDocumentView.DocumentLoaded += pdfDocumentView_DocumentLoaded;

}

private void pdfDocumentView_DocumentLoaded(object sender, EventArgs args)

{

    pdfDocumentView.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.FitPage;

    int percentage = pdfDocumentView.ZoomPercentage;//always 100

}


Regards,

Krithika


Attachment: PdfDocumentViewWPF_74b5b4d0.zip

Marked as answer
Loader.
Up arrow icon