I have a c# winform application, the form contains a panel to show ads of any type (video, image, pdf), everything works good except for the pdf files, since I have to set
ZoomMode.FitWidth
(client’s requirement). this setup results to show only the first part of each page.
to solve this issue I tried multiple solutions:
- adding the pdf to the panel and a timer (pdf size set to
panel.width
and pdf file height –PageSize.height * PageCount
) the timer starts and thepanel.verticalScroll.value
increases by one on each interval ==> the panel vertical scroll ends way before the the pdf ending. (the condition to stop the timer is
commissionsPanel.VerticalScroll.Value >= commissionsPanel.VerticalScroll.Maximum - commissionsPanel.VerticalScroll.LargeChange + 1
- Scrolling only the pdf file using
pdfViewer.Renderer.PerformScroll(ScrollAction.LineDown, Orientation.Vertical);
works fine but I can’t detect the very ending of the file, I can only fine the last page of the file, but since the ZoomMood.FitWidth
only the top part of the page appears.
- Adding a custom vScrollBar give it the pdf height as maximum value and increase it by one on each line down scrolling.
if (vScrollBar.Value <= vScrollBar.Maximum)
{
vScrollBar.Value++;
pdfViewer.Renderer.PerformScroll(ScrollAction.LineDown, Orientation.Vertical);
}
else
{
timerPdfcommissions.Stop();
MessageBox.Show("End Of File!");
}
the pdf ends way before the maximum value of the verticalScrollBar which leads to a very long waiting period.
-
there is no EOF in the library and can’t use the EOF marker in this context.
-
extracting the text or detecting the lines in the file doesn’t work if the pdf contains photos.
I tried so many hicks but nothing works. any help would be really appreciated, any tips to find the end of the file, please!