Cyotek Forums

Source Code => Source Code => Topic started by: iPhiTech on February 12, 2018, 07:37:31 PM

Title: PdfImagebox Create Selection
Post by: iPhiTech on February 12, 2018, 07:37:31 PM
Possible to create a selection area in pdfImagebox and get the image selected.Thank you for the feedback


(https://camo.githubusercontent.com/8c2e7544db827090e5889f029f1a2945bb65d198/687474703a2f2f7374617469632e63796f74656b2e636f6d2f66696c65732f61727469636c65696d616765732f696d67626f782d35612e706e67)
Title: Re: PdfImagebox Create Selection
Post by: Richard Moss on February 13, 2018, 06:37:09 AM
Hello,

If by "PdfImageBox" you mean the example project from our blog post (https://www.cyotek.com/blog/extending-the-imagebox-component-to-display-the-contents-of-a-pdf-file-using-csharp), then this is just a normal ImageBox control which exposes a GetSelectedImage method to return the image selection.

Regards;
Richard Moss
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 13, 2018, 06:40:27 AM
yes i want to add selection in pdfimagebox
Title: Re: PdfImagebox Create Selection
Post by: Richard Moss on February 13, 2018, 07:46:54 PM
Hello,

Not sure what to suggest - I grabbed the old source code from that demo, upgraded it to use the ImageBox package and was able to draw selection regions perfectly well.

Does your code have anything that clears the SelectionRegion property?
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 13, 2018, 07:57:43 PM
image grab is now working, but the draw select or the rectangle highlight are not showing , do you have skype ? iwant to donate if my projects done
Title: Re: PdfImagebox Create Selection
Post by: Richard Moss on February 14, 2018, 09:18:46 PM
I can't reproduce it not drawing the selection region, are you able to post your code?
Title: Re: PdfImagebox Create Selection
Post by: Richard Moss on February 18, 2018, 02:16:02 PM
Hello,

The PDF ImageBox sample from the Cyotek website uses a fairly old source code version of the ImageBox control that predates by around 6 months the improvements which added selection regions etc.

Install the CyotekImageBox NuGet package (https://www.nuget.org/packages/CyotekImageBox/), then delete the now unused ImageBox.cs, ImageBoxBorderStyle.cs, ImageBoxGridDisplayMode.cs and ImageBoxGridScale.cs files from the project. The PdfImageBox sample will then use the latest ImageBox control which offers the selection region behaviour.

I had assumed you'd already done this as your screenshot shows the new properties, but the code you posted looks like an unmodified copy of the Cyotek blog sample.

Regards;
Richard Moss
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 18, 2018, 03:55:12 PM
The Imagebox controll still shows the PDF ?
Title: Re: PdfImagebox Create Selection
Post by: Richard Moss on February 18, 2018, 04:01:24 PM
Yes, the PDF sample will continue to load the PDF. The sample uses the GhostScript API to convert PDF pages into images which are then loaded into the ImageBox. Upgrading the sample to used the embedded source version to the more up to date package won't break that.
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 18, 2018, 05:37:19 PM
ok thanks ill try it now
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 18, 2018, 05:48:07 PM
still not draw some highlight area.
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 18, 2018, 06:32:42 PM
Severity Code Description Project File Line Suppression State
Warning CS0436 The type 'ImageBoxSelectionMode' in 'E:\Selection\Revise2\Revise2\PdfImageBoxSample\PdfImageBoxSample\ImageBoxSelectionMode.cs' conflicts with the imported type 'ImageBoxSelectionMode' in 'Cyotek.Windows.Forms.ImageBox, Version=1.2.0.0, Culture=neutral, PublicKeyToken=58daa28b0b2de221'. Using the type defined in 'E:\Selection\Revise2\Revise2\PdfImageBoxSample\PdfImageBoxSample\ImageBoxSelectionMode.cs'. PdfImageBoxSample E:\Selection\Revise2\Revise2\PdfImageBoxSample\PdfImageBoxSample\PdfImageBox.cs 34 Active
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 19, 2018, 09:33:24 AM
Thanks Sir the code is now working  ;D
Title: Re: PdfImagebox Create Selection
Post by: Richard Moss on February 19, 2018, 06:03:32 PM
Thanks for letting me know! I confess I'm really confused over what the actual problem was but I'm glad you got it resolved.

I'm sure you've fixed this by now, but in regards to your build warning, the solution is to delete the source code file ImageBoxSelectionMode.cs from your project as it is already a part of the compiled version. Again though I'm confused as how that file is there in the first place as I'm pretty sure it was written after the PDF sample was to begin with.

Still, glad you got it resolved - good luck with your project!
Title: Re: PdfImagebox Create Selection
Post by: iPhiTech on February 20, 2018, 03:40:05 PM
ill remake the PDfImagebox fresh then added the image selection from nugget follow your instruction then boom .add the other feature then done.