VintaSoft Imaging .NET SDK and Plug-ins Discussions
Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.
Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions
i would like to catch the click event on a WpfImageViewer with PDF Coordinates (to tell where the user has clicked on a pdf page). Is it possible?Yes, this is possible. For doing the task you need:
I would also like to show some rectangles on the pdf pages programmatically. How can i do that?This is also possible. Please read how to do this here: https://www.vintasoft.com/docs/vsimaging ... fPage.html
I tried the MouseDown event. It works however only on the right mouse click. I would like to work with the left mouse click event. Is it possible?There is no difference when you work with left or right mouse button. Could you share a snippet of your code?
could you please also tell me what ist the measurement of the Point if i get it from the PointToImage method?The PointToImage method (https://www.vintasoft.com/docs/vsimaging ... Image.html) returns point coordinate in pixels.
imageViewer.MouseDown += new MouseButtonEventHandler(Pdf_MouseDown);
private void Pdf_MouseDown(object sender, MouseEventArgs e)
{
...
}
Pdf_MouseDown is only triggered by the right mouse click....
this.imageViewer1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.imageViewer1_MouseClick);
this.imageViewer1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.imageViewer1_MouseDown);
...
private void imageViewer1_MouseDown(object sender, MouseEventArgs e)
{
MessageBox.Show("MouseDown " + e.Button.ToString());
}
private void imageViewer1_MouseClick(object sender, MouseEventArgs e)
{
MessageBox.Show("MouseClick " + e.Button.ToString());
}
and it works correctly for left and right mouse buttons.
private void NextPdf_Click(){
openDocument(nextIndex);
showRectangular();
}
private void showRectangulars()
{
using (PdfGraphics graphics = PdfGraphics.FromPage(FocusedPage))
{
System.Drawing.PointF p = new System.Drawing.PointF((float)x, (float)y);
FocusedPage.PointToUnit(ref p);
System.Drawing.Color brushColor = System.Drawing.Color.FromArgb(0, 0, 0);
PdfBrush brush = new PdfBrush(brushColor, GraphicsStateBlendMode.Multiply);
PdfPen pen = new PdfPen(brushColor);
graphics.FillAndDrawRectangle(pen, brush, 100, 100, 200, 200);
}
imageViewer.Image.Reload(true);
}
private void OpenDocument(int index)
{
CloseDocument();
PdfDocumentController.AuthenticateRequest += new EventHandler<PdfDocumentOpenedEventArgs>(PdfDocumentController_AuthenticateRequest);
String filename = VM.getPdfName(index);
try
{
// try open in read-write mode
_documentStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite);
}
catch (IOException)
{
try
{
// try open in read mode
_documentStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
}
catch (IOException e)
{
Debug.Write(e);
return;
}
}
catch (Exception e)
{
Debug.Write(e);
return;
}
try
{
_document = PdfDocumentController.OpenDocument(_documentStream);
if (_document.IsEncrypted && _document.AuthorizationResult == AuthorizationResult.IncorrectPassword)
{
CloseDocument();
return;
}
}
catch (Exception e)
{
Debug.Write(e);
CloseDocument();
return;
}
_document.RenderingSettings.UseEmbeddedThumbnails = true;
try
{
imageViewer.Images.Add(_documentStream);
}
catch (Exception e)
{
Debug.Write(e);
CloseDocument();
return;
}
}
/// <summary>
/// get the password from the AppConfiguration
/// </summary>
void PdfDocumentController_AuthenticateRequest(object sender, PdfDocumentOpenedEventArgs e)
{
PdfDocument document = e.Document;
while (true)
{
AuthorizationResult authorization = document.Authenticate(AppConfiguration.PDF_DECRYPTION_KEY);
if (authorization == AuthorizationResult.IncorrectPassword)
{
Console.WriteLine("The password is incorrect.");
}
else
{
Console.WriteLine(authorization.ToString());
return;
}
}
}
Best regardsi have yet another problem. I have some pdf documents, each containing only one page. I open the pdfs one after another, while showing a Rectangular on each of them. Problem is that sometimes the Rectangular shows and sometimes not. It looks like a race condition to me. My codes are likeI think your code has logical mistake. Please send working demo project which demonstrates the problem to support@vintasoft.com, we need reproduce your problem.