2014-02-14 44 views
0

我正在Windows Phone 7应用程序中构建应用程序。我的申请表中有一个表格。该窗体的代码是:如何从Windows Phone 7应用程序生成PDF

XAML:

<TextBox GotFocus="OnGotFocus" Canvas.Left="6" Canvas.Top="6" Height="74" Name="name" Text="*Name" Width="453" BorderThickness="0"/> 
<TextBox GotFocus="OnGotFocus1" Canvas.Left="6" Canvas.Top="66" Height="74" Name="age" Text="*Age" Width="453" BorderThickness="0" /> 
<TextBlock Canvas.Left="20" Canvas.Top="157" Height="44" Name="gen" Text="Gender" Foreground="Black" FontFamily="Verdana" FontSize="24" Width="134" /> 
<RadioButton Canvas.Left="139" Canvas.Top="157" FontStyle="Italic" GroupName="Gender" Foreground="Black" Content="Male" Height="71" Name="male" Width="154" /> 
<RadioButton Canvas.Left="139" Canvas.Top="207" FontStyle="Italic" GroupName="Gender" Foreground="Black" Content="Female" Height="71" Name="fem" Width="140" /> 
<TextBox GotFocus="OnGotFocus2" Canvas.Left="6" Canvas.Top="267" Height="74" Name="sadd" Text="*Street Address" Width="453" BorderThickness="0"/> 
<TextBox GotFocus="OnGotFocus3" Canvas.Left="6" Canvas.Top="327" Height="74" Name="cadd" Text="*City Address" Width="453" BorderThickness="0"/> 
<TextBox GotFocus="OnGotFocus4" Canvas.Left="6" Canvas.Top="387" Height="74" Name="eadd" Text="*Email Address" Width="453" BorderThickness="0"/> 
<TextBox GotFocus="OnGotFocus5" Canvas.Left="6" Canvas.Top="447" Height="74" Name="phn" Text="*Phone" Width="453" BorderThickness="0"/> 
<TextBox GotFocus="OnGotFocus6" Canvas.Left="6" Canvas.Top="507" Height="74" Name="zip" Text="*Zip Code" Width="453" BorderThickness="0"/> 

现在就点击提交按钮,我想产生它应该包含我已经在形式与一些手工数据一起输入的数据的PDF文件。生成的pdf应该像电子邮件中的附件一样发送,之后应该使用特定的“registertoteam”网络方法提交数据。任何人都可以请帮助我如何做到这一点的代码。目前我的CS文件看起来像这样:

namespace KejriwalPhoneApp 
{ 
public partial class Join : PhoneApplicationPage 
{ 
    public Join() 
    { 
     InitializeComponent(); 



    } 


    private void OnGotFocus(object sender, RoutedEventArgs e) 
    { 
     if (name.Text.Equals("*Name", StringComparison.OrdinalIgnoreCase)) 
     { 
      name.Text = string.Empty; 
     } 
    } 

    private void OnGotFocus1(object sender, RoutedEventArgs e) 
    { 
     if (age.Text.Equals("*Age", StringComparison.OrdinalIgnoreCase)) 
     { 
      age.Text = string.Empty; 
     } 
    } 

    private void OnGotFocus2(object sender, RoutedEventArgs e) 
    { 
     if (sadd.Text.Equals("*Street Address", StringComparison.OrdinalIgnoreCase)) 
     { 
      sadd.Text = string.Empty; 
     } 
    } 

    private void OnGotFocus3(object sender, RoutedEventArgs e) 
    { 
     if (cadd.Text.Equals("*City Address", StringComparison.OrdinalIgnoreCase)) 
     { 
      cadd.Text = string.Empty; 
     } 
    } 

    private void OnGotFocus4(object sender, RoutedEventArgs e) 
    { 
     if (eadd.Text.Equals("*Email Address", StringComparison.OrdinalIgnoreCase)) 
     { 
      eadd.Text = string.Empty; 
     } 
    } 

    private void OnGotFocus5(object sender, RoutedEventArgs e) 
    { 
     if (phn.Text.Equals("*Phone", StringComparison.OrdinalIgnoreCase)) 
     { 
      phn.Text = string.Empty; 
     } 
    } 

    private void OnGotFocus6(object sender, RoutedEventArgs e) 
    { 
     if (zip.Text.Equals("*Zip Code", StringComparison.OrdinalIgnoreCase)) 
     { 
      zip.Text = string.Empty; 
     } 
    } 


    private void Image_Previous(object sender, RoutedEventArgs e) 
    { 
     NavigationService.Navigate(new Uri("/AAP.xaml", UriKind.Relative)); 
    } 

    private void submit_Click(object sender, RoutedEventArgs e) 
    { 
     if (name.Text == String.Empty) 
     { 
      MessageBox.Show("Please Enter the name"); 
      name.Focus(); 
     } 

     if (age.Text == String.Empty) 
     { 
      MessageBox.Show("Please Enter the age"); 
      age.Focus(); 
     } 

     if (male.IsChecked == true) 
     { 
      string gender = male.Content.ToString(); 
     } 
     else if (fem.IsChecked == true) 
     { 
      string gender = fem.Content.ToString(); 
     } 
     else //none of them is selected. 
     { 
      MessageBox.Show("Please select your Gender"); 
     } 

     if (sadd.Text == String.Empty) 
     { 
      MessageBox.Show("Please Enter the Street Address"); 
      sadd.Focus(); 
     } 

     if (cadd.Text == String.Empty) 
     { 
      MessageBox.Show("Please Enter the City Address"); 
      cadd.Focus(); 
     } 

     if (eadd.Text == String.Empty) 
     { 
      MessageBox.Show("Please Enter the Email Address"); 
      eadd.Focus(); 
     } 

     if (phn.Text == String.Empty) 
     { 
      MessageBox.Show("Please Enter the Phone Number"); 
      phn.Focus(); 
     } 

     if (zip.Text == String.Empty) 
     { 
      MessageBox.Show("Please Enter the Zipcode"); 
      zip.Focus(); 
     } 

} 

    private void reset_Click(object sender, RoutedEventArgs e) 
    { 
     name.Text = String.Empty; 
     age.Text = String.Empty; 
     sadd.Text = String.Empty; 
     cadd.Text = String.Empty; 
     eadd.Text = String.Empty; 
     phn.Text = String.Empty; 
     zip.Text = String.Empty; 
     male.IsChecked = false; 
     fem.IsChecked = false; 

    } 
} 

}

我知道如何添加我的web服务,以及如何从网络服务中获取数据,并在我的应用程序显示出来。现在我想将这些数据发送到regmertoteam的webmethod。请帮忙

回答

0

我目前无法分享代码,但用bing快速搜索,结果如下http://pdfsharpwp7.codeplex.com/http://itextsharpsl.codeplex.com/(推荐)。

+0

如果以后能分享代码,或者如果pdf生成的代码太长,只需编写代码将数据发送到registertoteam webmethod,点击提交按钮 – bhaku

+0

网络方法regitertoteam包含以下数据:name,street_address,city_address,zip_code,email_address,phone_no,年龄,性别 – bhaku

+0

明天晚上我可以坐在上面吧 – maciejgos

1

我最近在我的一个应用程序中集成了它。我想出了以下决定

codeplex提供的开源库不值得。他们甚至不会被添加到项目中。

目前,没有任何支持或任何图书馆availbale为Windows手机开发人员使用它来呈现PDF。

这将是一个乏味的任务。至于制作pdf,你需要自己制作完整的pdf文件格式,因为没有图书馆的支持。

这样做的核心this是我要推荐的第一个链接(这解决了你的目的)。此链接也附有源代码。

为更多和组织良好的解决方案检查我的叠层流程question关于相同。

而关于电子邮件附件其我和你的坏!到现在为止,开发人员没有这种支持。 :(

+0

好的,谢谢你提供的信息。表单提交到一个特定的web方法来定义提交按钮我想发送数据的web方法是registertoteam – bhaku

相关问题