PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

DocumentViewer in Windows Form
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2453
Page 1 of 1

Author:  olum [ Thu May 16, 2013 7:49 am ]
Post subject:  DocumentViewer in Windows Form

Hello,

I'm working on a new project with migradoc and I would like to have a preview of my pdf document in the windows form.
The DocumentViewer from the sample folder is running. But just stand alone.

How can I use that DocumentViewer in my Windows Form application?
Is it possible to add it as a user control or something else?

Maybe someone else does already have a solution for that problem.

Thank you
olum

Author:  Thomas Hoevel [ Thu May 16, 2013 8:35 am ]
Post subject:  Re: DocumentViewer in Windows Form

Hi!
olum wrote:
How can I use that DocumentViewer in my Windows Form application?
Just use it.

When using the GDI+ build of PDFsharp, you can use the WinForms user control MigraDoc.Rendering.Forms.DocumentPreview.
The Preview sample shows how to add a menu etc. (make sure to download the source package of PDFsharp with the complete sample code).

The WPF build includes the user control MigraDoc.Rendering.Windows.DocumentPreview. To use this with WinForms, you'll have to use an ElementHost to embed the WPF user control.
See also:
http://stackoverflow.com/a/11383196/162529
http://dotnet.dzone.com/articles/hostin ... s-winforms

Author:  olum [ Thu May 16, 2013 10:36 am ]
Post subject:  Re: DocumentViewer in Windows Form

Hello,

thanks you for your help.
Now it works for me.

Code:
preview = new MigraDoc.Rendering.Windows.DocumentPreview();
preview.InitializeComponent();
elementHost1.Child = preview;

Is it possible to add some more options to the toolbox menu of the preview element?

Thanks
olum

Author:  Thomas Hoevel [ Thu May 16, 2013 12:33 pm ]
Post subject:  Re: DocumentViewer in Windows Form

The preview uses the DocumentViewer control that comes with WPF.
You can use a Style to set a Template for the DocumentViewer.

Here's a sample:
http://msdn.microsoft.com/en-us/library ... 52(v=vs.90).aspx

You can create a new WPF user control that has a DocumentPreview and sets the style for it.
Not really simple when your new to WPF.

Author:  olum [ Wed May 22, 2013 8:11 am ]
Post subject:  Re: DocumentViewer in Windows Form

Thank you,

I changed to GDI+ because of the picture lock bug and I'm more familiar with this forms.

Author:  pistoletov [ Wed Oct 04, 2017 8:48 am ]
Post subject:  Re: DocumentViewer in Windows Form

Hi!
I try to put MigraDoc.Rendering.Forms.DocumentPreview pagePreview on form but i do not see this component in toolbox. in references MigraDoc rendering installed. ver 1.32.4334. if i put viewer.cs(from migradoc DocumenT Viewer example) to my project it work but i do not see in toolbox this elements.
Does it appear automaticaly in toolbox when i add package from Nuget or i need to manualy Choose Items in toolbox and add some dll's to toolbox?
Please help for newbie.

Author:  Thomas Hoevel [ Wed Oct 04, 2017 12:13 pm ]
Post subject:  Re: DocumentViewer in Windows Form

Hi!
pistoletov wrote:
Does it appear automaticaly in toolbox when i add package from Nuget or i need to manualy Choose Items in toolbox and add some dll's to toolbox?
I don't know.
You can always reference the .csproj files from the PDFsharp source code and then VS will list the controls in the Toolbar.
Not sure how it is with VS and NuGet packages. Do they show up when you compile, close VS, and open VS again?

Author:  pistoletov [ Wed Oct 04, 2017 1:45 pm ]
Post subject:  Re: DocumentViewer in Windows Form

i try to investigate this. Does VS store this setTing in csproj? i suppouse no. I open csproj with editor and can not found any info about this components.
But the components presence in toolbox

Attachments:
vs.jpg
vs.jpg [ 39.43 KiB | Viewed 2276 times ]

Author:  pistoletov [ Thu Oct 05, 2017 12:18 pm ]
Post subject:  Re: DocumentViewer in Windows Form

i add Migradoc project to my solution. If i edit forms in this project components shows in toolbox, if i switch to another project in solution they disappear from toolbox. I try to add manualy dll to toolbox and got error.

Attachments:
tb2.png
tb2.png [ 45.67 KiB | Viewed 2261 times ]

Author:  MwBakker [ Mon Oct 30, 2017 8:30 am ]
Post subject:  Re: DocumentViewer in Windows Form

You seriously even have a viewer? I had been searching ages for the right viewer, but it was there included all along? Is it working with stream?

Author:  TH-Soft [ Mon Oct 30, 2017 8:39 am ]
Post subject:  Re: DocumentViewer in Windows Form

MwBakker wrote:
You seriously even have a viewer?
Yep. And we seriously have a web site with samples pages. :wink:
http://pdfsharp.net/wiki/Preview-sample.ashx
http://pdfsharp.net/wiki/DocumentViewer-sample.ashx

Author:  MwBakker [ Tue Oct 31, 2017 2:20 pm ]
Post subject:  Re: DocumentViewer in Windows Form

TH-Soft wrote:
MwBakker wrote:
You seriously even have a viewer?
Yep. And we seriously have a web site with samples pages. :wink:
http://pdfsharp.net/wiki/Preview-sample.ashx
http://pdfsharp.net/wiki/DocumentViewer-sample.ashx


Great! Used it in my program, your credits are mentioned on the application while running. Gonna donate soon as well, many thanks!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/