Extract text and all Font information from pdf viewer - winforms

User will see a pdf in webbrowser Control(or any other viewer) and select the text from it then I want to find
1)Coordinates of selected text.
2)Font Size of selected text.
3)Font Color of Selected text.
4)Page Number of selected text.
So that i can use this information to find the text from pdf with same theme .
Problem 1:
Is it possible to find which text or coordinate is selected in webbrowser control? There must be a better way to do it using pdf tron viewer?
My approach will be to fix the Form ,so that user will not change the length, width
a) i will find a way to transform screen coordinates to pdf rectangle coordinates(#problem 2)
b) then i fill fetch text from those coordinates
c) then i will find color and other properties of that text
but i am sure ,there must be a easy way .I tried to find help but was unable to find such help. Kindly provide related documentation and a help to figure out starting point to start a task.

This is not possible using webbrowser but there is an alternative using PDFViewCtrl.
1) add control in toolbox by browsing PDFNET.dll
2) its better not to drag and drop the control ,alternatively initialize pdfviewctrl in after initializeComponent();
3) Add these lines to give user option of selection
pdfViewCtrl1.SetDoc(doc);
pdfViewCtrl1.SetToolMode(pdftron.PDF.PDFViewCtrl.ToolMode.e_text_rect_select);
4)Add this code behind the click event of start button so that user tell the program that he/she has selected text.
int pagenumber = pdfViewCtrl1.GetCurrentPage();
if (pdfViewCtrl1.HasSelectionOnPage(pagenumber))
{
pdftron.PDF.PDFViewCtrl.Selection selection = pdfViewCtrl1.GetSelection();
string HTML = selection.GetAsHtml();
HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
document.LoadHtml(HTML);
double[] coordinates = selection.GetQuads();
Rect rect = new Rect(coordinates[6], coordinates[7], coordinates[2], coordinates[3]);
}
you will get everything in html else you have text and coordinates so you can find more information ,
Find samples of code on http://www.pdftron.com/pdfnet/samplecode.html

Related

Combo box in a MFC application

My question is about combo boxes in Windows MFC applications.
The dropdown part of the combo box contains items composed of a bitmap and a string.
Sometimes, the strings are too long and I have to adjust the width of the dropdown part of the combo box using the CComboBox::SetDroppedWidth() method.
My problem is that when the combo box is near the right edge of the computer screen, the right part of the dropdown is hidden (see image_1 and image_2 below).
I would like it to behave like in Excel (see image_3 below) meaning I would like the dropdown list to be shifted accordingly so that all its items can be seen without being cropped.
How can this be achieved?
image_1: right part of the dropdown is NOT hidden
image_2: near the computer right edge, the right part of the dropdown is hidden
image_3: Excel combo box
=================================================================
EDIT 1
=================================================================
EDIT 2
Ok. I forgot to mention that m_cbXmodels is a CComboBoxEx object. This is why the handles are NULL. I could get the handles via GetComboBoxCtrl()...
Handle the CBN_DROPDOWN notification.
Get the handle for the list control with GetComboBoxInfo.
Now use MoveWindow to adjust the window as needed.
Getting the current screen size is available with MonitorFromWindow. See rcWork member in MONITORINFO. You just need to adjust the left and right coordinates.
EDIT: As you can read in the comments: My Approach with CBN_DROPDOWN is to early Thanks to zett42). It is not possible to resize the combo box list part here.
But it is possible to post a user defined message to the same window and to reposition the window than.

Adding text in a richtextbox after adding a graphic

When adding a graphic to the end of some text in a richtextbox. It works great. However, when I begin to add more text, the graphic is overwritten. This is not the desired outcome.
I am using the clipboard method for taking a graphic from resources and pasting it into the richtextbox.
// initiate the horizontal bar file
Image image = Properties.Resources.hoz_line_212x4;
// Put the image on the clipboard
Clipboard.SetImage(image);
//// Paste it into the rich text box.
this.msgsrtbx.Paste();
this.msgsrtbx.SelectionLength = 0;
this.msgsrtbx.ScrollToCaret();
When I come to the next bit of text I want to place in teh richtextbox, the graphic is overwritten. I would like it to still remain in the box.

How to increase the size of Gridview RepositoryEditText ? winforms devexpress

I used Repository EditText in Gridview to write description of some items. When i click enter button on keyboard, the new rows will comes to type but the height of the RepositoryEditText will not increase. If user Click enter button keyboard i need to extend the EditText height. I want to display both lines in same cell of gridview. How to complete my task ? Help me.
The TextEdit editor doesn't support the multi-line feature. So, you need to use MemoEdit as you already did. To display several lines, increase the GridView.RowHeight property, for example, to 60. On the other hand, in order to adjust a row height to completely display a cell content, enable the GridView.OptionsView.RowAutoHeight option.

WPF Visual to XPS document method creates only one page

I have a WPF Window that I want to save to an XPS file (or really, any type of file that would store the window image). This window contains a lengthy DataGrid. So far I am able to write to an XPS file, but the resulting document contains only one page, so most of the DataGrid rows are missing. How can I get the XPSDocumentWriter to use as many pages as necessary?
Here is what I've got so far (I've turned off the grid scroll bar and autosized the window to make sure it is full-sized before writing to XPS file):
Dim visual = CType(Me.Content, Media.Visual)
Me.LogGrid.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden
Me.SizeToContent = Windows.SizeToContent.WidthAndHeight
Dim xd As New System.Windows.Xps.Packaging.XpsDocument(file, IO.FileAccess.ReadWrite)
Dim xw = System.Windows.Xps.Packaging.XpsDocument.CreateXpsDocumentWriter(xd)
xw.Write(visual)
xd.Close()
I think Will's comment is probably the right answer.

text in paint like application

Hope I can make the question clear.
I am working on a paint like application where users can add different objects and also text. The way to add text is that we show a dialog where user can enter text and then that text is added to the draw area.
Now we want that text should be added in the same way as in Power Point. A user clicks any where in the draw area, a rectangular text entering area is shown, where user can enter text, format it, move the rectangle to move the text and then click outside to enter the text on the drawing area.
Since the paint event of the draw area is called and every object is added to the draw area using graphics and paint, what is the best way to add text using the interface as I explained above.
Any suggestions would be appreciated.
Your best option is to place a TextBox as a child control and that will allow the user to modify the text as required. Once they finish changing the text you then remove the text box and draw the string instead. If they click the text becaues they want to change it then you put the text box back again so they can edit it.

Resources