I have to display a PDF inside a winform (c# on .net 2.0 framework). For now, I am using the ActiveX PDF control provided by Adobe. I have to disable the entire control so that a user can't print or save via right-click or hotkeys. Unfortunately, many of the documents need to be rotated (just viewed, not permanently saved that way). I'd like to allow them to rotate the view by pressing a button control. I've tried enabling the control then programmatically sending the hotkeys (ctrl shift +) using SendKeys and SendInput but the timing issues make this a non-viable solution.
I've asked on the proper Adobe boards and they said it was not possible being that all of my clients will only have the reader version installed.
just rotate the control. put the control in a panel and rotate the panel or something.
I don't suppose you could put controls on the PDF that prevent saving and printing?
Related
As a learning project in C# .net I am re-creating a Gnome 3 plugin for seeing who of the streamers you follow on Twitch is live. I have the settings form done, I am now working on the interface that is viewed from a click on the taskbar.
This is a rough image of what I want the interface to look like. When two or more streamers are live the interface would add another block and resize the form vertically similar to the menu for selecting a Wifi network in Windows.
What would be the best way for me to complete this?
My current thought is to maybe create a custom control and just place those inside a FlowLayoutPanel with some kind of code to change the vertical size of the form to match the added entries. Maybe this can be done without a custom control and be done with code inside a FlowLayoutPanel? I'm not too sure.
Ideally I would also have a click event in the panel for each streamer so I could then open a browser to their channel. A slight highlight would also be a plus (maybe change the background colour based on mouse hover).
Thanks in advance for any suggestions!
Similar question:
convert windows form to pdf file
I am trying to print a Windows form to PDF in a similar manner as the above question, however the method described in that particular answer is essentially taking an image of the form. I have controls that use a scrollbar (e.g. tablelayoutpanel) and need to see all of the information within, rather than whatever selection the scrollbar happens to be on.
Is this possible?
You will need to take a screen shot and use that image to generate a pdf.
The only way I have seen this done is using a program called Snagit, which scrolls the application window automatically whilst capturing it and I assume stitches that together.
I would imagine you would need to do that programatically to get the output you need?
I’m trying to show PDF files in Windows Form WebBrowser control. I do this by WebBrowser.Navigate() method. It is work when I want show one PDF file, which is not enough for me. I need when a user clicks a button , WebBrowser show another PDF file. What I have to do?
Avoid using WebBrowser control just to show a pdf. Try using one of the many free PDF libraries available for .net such as PDFSharp.
This will allow you to draw pdf's on to the Form and using TabControl you can create tabs programmatically and place a new pdf viewer inside of the tab.
You could easily make a 2 different files PDF viewer (side by side or top and bottom) by using the PDFSharp. Or you can use the ActiveX control for Adobe Reader.
Edit: It was my understanding that PDFSharp can render pdf's directly. This can only be done by exporting the page to a Jpeg/Png and then displaying the images. Sorry for any confusion.
At your place I'd do tabControl, and foreach tabControl, I'd put a webbroswer inwhich there would be a PDF by Tab.
EDIT : A WebBroswer isn't like internet explorer. Internet Explorer has the "Feature" of having multiple tabs (just like Chrome, etc). The WebBroswer Element is only the content of the tab :)
EDIT2 : After many years into this, I would recommend using a PDF library also. As a prototype usecase it might work, but in real world, we never know how many there will be. the best would probably to: either let the option to the user to open in a competent software i.e. Acrobat Reader where tab is natively used (DC), or use a PDF Library.
What i think is that you are facing a very simple navigate issue here. I have worked out a project for you, take a look at it, I hope it will solve your issue.
download here.
This is about testing a desktop application. I have been trying to click a hyperlink on an embedded browser of a Windows form. I could move the mouse anywhere if the component (buttons, or whatever) is part of the form, but elements inside the browser, i can't seem to control at all....sigh.....yes, I could move the mouse if I use the screen coordinates but I plan to control the embedded browser using Watin, etc..without opening a new IE....Using Microsoft's UISpy tool (when I hover the cursor to the link..it shows a Pane ControlType)....the hyperlink is part of the tree structure but only the name property is available...some of the parent's properties are blank....
I tried extending the example from the link below
http://archive.msdn.microsoft.com/uiautomation
and this is where i'm stuck (I have tried FindChildByName and other related methods too...sigh..no luck):
var commontab=AutomationElement.RootElement.FindFirstChildHavingDescendantWhere(new[] { new PropertyCondition(AutomationElement.NameProperty, "Search")});
Mouse.MoveTo(menutab.GetClickablePoint().ToDrawingPoint());
Mouse.Click(MouseButton.Left);
Somehow the mouse cannot find the 'Search' hyperlink...sigh...please guys...any ideas??
Would it not be a simpler idea to split this into 2 testing strategies? The first is testing the desktop UI, buttons etc. as you are. The second is to test the html which is to be placed within the embedded browser frame.
You shouldn't be testing that the embedded browser works, that's Microsofts job. The only testing that you may want to do on the frame is to ensure that it's content is loaded, that the call is to the correct (internal) url etc.
I need to be able to embed and control the playback of an AVI file in a WinForms app, using C#. The video needs to be embedded in the form, not launched in a separate media player window.
What's the best approach to do this? I found the System.Media namespace, which sounded promising, but it appears that is only useful for sound.
Do I use DirectX to do this? MCI? Or some other approach?
You can use Media Player inside your Winform. This would been an easy way to do it.
The way i did it was, and I quote:
Right-click the Toolbox, and click Choose Items.
Note: If you do not see the Toolbox, click Toolbox on the View menu to
open it. The Customize Toolbox Items dialog box opens.
On the COM Components tab, select the Windows Media Player check box,
and then click OK.
The Windows Media Player control appears on the current Toolbox tab.
When you add the Windows Media Player control to the Toolbox, Visual
Studio automatically adds references to two libraries: AxWMPLib and
WMPLib. The next step is to add the control to the Windows Form.
To add the Windows Media Player control to a Windows Form
Drag the Windows Media Player control from the Toolbox to the Windows
Form.
In the Properties window, set the Dock property to Fill. You can do
this by clicking the center square.
Double-click the title bar of the form to add the default Load event
in the Code Editor.
Add the following code to the Form_Load event handler to load a video
when the application opens.
axWindowsMediaPlayer1.URL =
#"http://go.microsoft.com/fwlink/?LinkId=95772";
http://msdn.microsoft.com/en-us/library/bb383953(v=vs.90).aspx
I highly recommend this library:
http://directshownet.sourceforge.net/
It is a .NET wrapper around the DirectShow API.
(The sample apps should get you going very quickly.)
--Bruce
The suggestions from Daok and Brian Genisio are both good options. Let me add a third: DirectShow. Used to be part of DirectX but has now been promoted to the Windows SDK. There are many good C# sample applications to look at, and it gives complete control of the playback.
I would consider using the WPF media controls and just use the ElementHost to put your WPF control inside your WinForms app. I think you will get a much more rich experience.
See System.Windows.Forms.Integration for more information