PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Dec 13, 2017 3:02 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Thu May 16, 2013 7:49 am 
Offline

Joined: Wed Apr 24, 2013 1:46 pm
Posts: 8
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


Top
 Profile  
Reply with quote  
PostPosted: Thu May 16, 2013 8:35 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2740
Location: Cologne, Germany
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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 16, 2013 10:36 am 
Offline

Joined: Wed Apr 24, 2013 1:46 pm
Posts: 8
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


Top
 Profile  
Reply with quote  
PostPosted: Thu May 16, 2013 12:33 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2740
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed May 22, 2013 8:11 am 
Offline

Joined: Wed Apr 24, 2013 1:46 pm
Posts: 8
Thank you,

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


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 04, 2017 8:48 am 
Offline

Joined: Tue Aug 15, 2017 11:27 am
Posts: 15
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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 04, 2017 12:13 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2740
Location: Cologne, Germany
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?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 04, 2017 1:45 pm 
Offline

Joined: Tue Aug 15, 2017 11:27 am
Posts: 15
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 567 times ]
Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 05, 2017 12:18 pm 
Offline

Joined: Tue Aug 15, 2017 11:27 am
Posts: 15
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 552 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 30, 2017 8:30 am 
Offline

Joined: Thu Oct 26, 2017 12:00 pm
Posts: 11
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?


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 30, 2017 8:39 am 
Offline
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 308
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 31, 2017 2:20 pm 
Offline

Joined: Thu Oct 26, 2017 12:00 pm
Posts: 11
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!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group