Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Add new Command to 'Save as PDF' (Read 6107 times)
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Add new Command to 'Save as PDF'
Apr 6th, 2017 at 5:21am
Print Post  
I'm trying to add new application command like 'Save as PDF'

So I created following `DesignerCanvas.Commands.cs` class and added following

Code
Select All
        public partial class DesignerCanvas
    {
        public static RoutedCommand SaveAsPDF = new RoutedCommand();

        public DesignerCanvas()
        {
            this.CommandBindings.Add(new CommandBinding(DesignerCanvas.SaveAsPDF, SaveAsPDF_Executed));
        }

        private void SaveAsPDF_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            throw new NotImplementedException();
        }
    } 



then I created 'DesignerCanvas.cs'

Code
Select All
    public partial class DesignerCanvas : Canvas
    {
    } 



then Added new Icon to tool bar like this in 'ApplicationToolbar.xaml'

Code
Select All
	<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:s="clr-namespace:SampleProject">

					<Button Margin="0,3,0,3" Padding="5" HorizontalContentAlignment="Left"
                            Style="{StaticResource ToolBarButtonBaseStyle}"
                            Command="{x:Static s:DesignerCanvas.SaveAsPDF}"
                            CommandTarget="{Binding ElementName=MyDesigner}">
                        <Button.Content>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Image Source="Images/Ungroup.png" Width="16"/>
                                <TextBlock Margin="3" Text="Ungroup" VerticalAlignment="Center" Grid.Column="1"/>
                            </Grid>
                        </Button.Content>

     </ResourceDictionary> 



but here I'm getting this error

The name "DesignerCanvas" does not exist in the namespace "clr-namespace:SampleProject".
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3156
Joined: Oct 19th, 2005
Re: Add new Command to 'Save as PDF'
Reply #1 - Apr 6th, 2017 at 7:46am
Print Post  
You might have to recompile the project for the Xaml designer to find that class.
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Add new Command to 'Save as PDF'
Reply #2 - Apr 6th, 2017 at 9:30am
Print Post  
I implemented following method to Save canvas to PDF ?

Code
Select All
        private void SaveAsPDF_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            SaveFileDialog saveDlg = new SaveFileDialog();
            saveDlg.Filter = "PDF files|*.pdf";
            if (saveDlg.ShowDialog() == true)
            {
                flowchart.SaveToXml(saveDlg.FileName);
                MindFusion.Diagramming.Export.PdfExporter pdfExp = new MindFusion.Diagramming.Export.PdfExporter();
                pdfExp.Export(diagramview.Diagram, saveDlg.FileName);
            }
        } 



above method I refreed from mindfusion documentation page

http://www.mindfusion.eu/onlinehelp/flowchartnet/Diagram_Exporting.htm

but here I'm having following errors

Error 1

'Diagram' does not contain a definition for 'Diagram' and no extension method 'Diagram' accepting a first argument of type 'Diagram' could be found

Error 2

The type or namespace name 'Export' does not exist in the namespace 'MindFusion.Diagramming'

but for this(2nd error) I already installed `MindFusion.Diagramming.Wpf` and gave namespace like this

`using MindFusion.Diagramming.Wpf;`

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3156
Joined: Oct 19th, 2005
Re: Add new Command to 'Save as PDF'
Reply #3 - Apr 6th, 2017 at 1:05pm
Print Post  
That link is to help files of our Windows Forms component. WPF version is here -
http://www.mindfusion.eu/onlinehelp/wpfdiagram/index.htm?CC_Exporting_the_Diagra...

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Add new Command to 'Save as PDF'
Reply #4 - Apr 7th, 2017 at 3:45am
Print Post  
once I add I'm having following compile time errors

The type or namespace name 'PdfExporter' could not be found
The type or namespace name 'Pdf' does not exist in the namespace 'MindFusion'

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3156
Joined: Oct 19th, 2005
Re: Add new Command to 'Save as PDF'
Reply #5 - Apr 7th, 2017 at 8:50am
Print Post  
Right-click the project and choose Add Reference command, then browse to the installed dll files and select mindfusion.pdf.dll

Regards,
Slavcho
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Add new Command to 'Save as PDF'
Reply #6 - Apr 7th, 2017 at 10:17am
Print Post  
I found mindfusion.pdf.dll from below link

http://api.256file.com/mindfusion.pdf.dll/en-download-124273.html

once after add that
'The type or namespace name 'Pdf' does not exist in the namespace 'MindFusion' this error goes away

but I unable to solve below error

'The type or namespace name 'PdfExporter' could not be found'
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3156
Joined: Oct 19th, 2005
Re: Add new Command to 'Save as PDF'
Reply #7 - Apr 7th, 2017 at 10:43am
Print Post  
Eh, better don't download these from random websites. You should also add a reference to the MindFusion.Diagramming.Wpf.PdfExport.dll assembly. You'll have it installed under C:\Program Files\MindFusion if you've ran the control's installer. You might as well get all the assemblies as a nuget package -
https://www.nuget.org/packages/MindFusion.Diagramming.Wpf/

Regards,
Slavcho
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Add new Command to 'Save as PDF'
Reply #8 - Apr 7th, 2017 at 11:14am
Print Post  
can you give the exact 'MindFusion.Diagramming.Wpf.PdfExport.dll' as attachment here , because I cant find though I installed Nuget package like this 'Install-Package MindFusion.Diagramming.Wpf'
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3156
Joined: Oct 19th, 2005
Re: Add new Command to 'Save as PDF'
Reply #9 - Apr 7th, 2017 at 11:32am
Print Post  
It should be available under project_path\packages\MindFusion.Diagramming.Wpf.3.4.2\lib\net40 after you install nuget package. Only the core assemblies are added automatically as references, you'll need to browse to that folder to select exporter's ones.
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Add new Command to 'Save as PDF'
Reply #10 - Apr 11th, 2017 at 3:35am
Print Post  
I copied the `MindFusion.Diagramming.Wpf.PdfExport.dll` from my following location

`Project_Location\packages\MindFusion.Diagramming.Wpf.3.4.2\lib\net40`

then I gave referred following namespace

`using MindFusion.Diagramming.Wpf.Export;`

but then Still I'm having following compile time errors



1. `The name 'PageSize' does not exist in the current context`

2. `The type 'PageOrientation' is defined in an assembly that is not referenced. You must add a reference to assembly 'MindFusion.Pdf, Version=1.3.0.13478, Culture=neutral, PublicKeyToken=0b3a610038a66854'`

3. `The type 'PageSize' is defined in an assembly that is not referenced. You must add a reference to assembly 'MindFusion.Pdf, Version=1.3.0.13478, Culture=neutral, PublicKeyToken=0b3a610038a66854'`

4. `The type or namespace name 'Pdf' does not exist in the namespace 'MindFusion`
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3156
Joined: Oct 19th, 2005
Re: Add new Command to 'Save as PDF'
Reply #11 - Apr 11th, 2017 at 8:28am
Print Post  
Also add a reference to MindFusion.Pdf.dll and a 'using MindFusion.Pdf' clause to import its namespace.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint