将Crystal报表转换为PDF

时间:2011-04-02 06:53:54

标签: c# .net pdf crystal-reports

水晶报告(c#.net)中是否有任何设施可以将字体更改为其他语言?如果没有,如何将水晶报告转换为pdf格式?

5 个答案:

答案 0 :(得分:1)

protected void Page_Load(object sender, EventArgs e)
{
    ExportOptions objExOpt;

    CrystalReportViewer1.ReportSource = (object)getReportDocument();
    CrystalReportViewer1.DataBind();
    // Get the report document
       ReportDocument repDoc = getReportDocument();

    repDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
    repDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
    DiskFileDestinationOptions objDiskOpt = new DiskFileDestinationOptions();
    objDiskOpt.DiskFileName = @"c:\crystal report\TFA.pdf";
    repDoc.ExportOptions.DestinationOptions = objDiskOpt;
    repDoc.Export();
 }

private ReportDocument getReportDocument()
{
  // File Path for Crystal Report
  string repFilePath = Server.MapPath("~/CrystalReport1.rpt");
  // Declare a new Crystal Report Document object
  // and the report file into the report document
  ReportDocument repDoc = new ReportDocument();

  repDoc.Load(repFilePath);

  // Set the datasource by getting the dataset from business
  // layer and
 // In our case business layer is getCustomerData function
 return repDoc;
}

答案 1 :(得分:0)

foreach (ReportObject objReport in rpt.ReportDefinition.Sections["Section3"].ReportObjects)
{
   FieldObject objField = (FieldObject)objReport;
   objField.ApplyFont(new Font("Arial", 8.25F, FontStyle.Italic, GraphicsUnit.Point, ((byte)(0))));
}

对于PDF,请参阅以下内容:

答案 2 :(得分:0)

ReportDocument reportobj = //Add code to return valid report document from a crystal report 
if (reportobj != null)
{
    //Export to PDF
    ((ReportDocument)reportobj).ExportToDisk(ExportFormatType.PortableDocFormat, file);
    //Open using default app for PDF docs
    if (System.IO.File.Exists(file))
         System.Diagnostics.Process.Start(file);
}

答案 3 :(得分:-1)

请尝试以下操作: 首先创建Crystal报表实例,您只需调用“导出到磁盘”

  RtpDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\report.pdf")

答案 4 :(得分:-2)

要将水晶报告转换为PDF,您可以尝试将水晶报告打印到pdf文件的PDF库。

相关问题