跳至頁尾內容
遷移指南

如何用 C# 從 SAP Crystal Reports 轉移到 IronPDF

從SAP Crystal Reports遷移到IronPDF將您的報告工作流程從具有COM時代依賴性的運行時MSI再分發轉換為現代NuGet包。 本指南提供了一個逐步的遷移路徑,消除了運行時安裝程式的需求,解除SAP生態系統的鎖定,並解鎖了Crystal Reports for Visual Studio(CR4VS)不支持的.NET 6/8/9和Linux/Docker目標。

為什麼從SAP Crystal Reports遷移到IronPDF

了解SAP Crystal Reports

SAP Crystal Reports是一個廣泛用於生成"像素完美"報告的企業報告平台,具有廣泛的資料源連接能力和長期存在的設計器生態系統。 Crystal Reports Designer仍然是用於構建複雜報告布局的SAP堆棧內一個有生產力的工具。

然而,運行時的COM時代架構和僅支持Windows/.NET Framework的局限性給目標.NET 6/8/9、Linux或優先容器部署的團隊帶來阻礙。

遷移的主要原因

  1. 運行時MSI可再分發:Crystal Reports運行時作為MSI安裝程式(通常根據32/64位和地區而定,大小從數十MB到數百MB不等)發佈,而不是NuGet包
  2. SAP生態系統鎖定:受SAP的發佈周期和產品路線圖約束;SAP已確認2027年末結束CR4VS的主流維護
  3. 許可:CR4VS本身可以免費下載,運行時也可以免費再分發,但是Crystal Reports設計工具系列(CR 2020 / CR 2025)和BI平台是商業SAP的SKU
  4. 舊有架構:依賴COM的運行時DLL目標.NET Framework 4.x,不能在.NET Core / .NET 5+下載入
  5. 不支持.NET Core / .NET 5+:沒有針對現代.NET的Crystal Reports運行時的路線圖; 專案保持釘在.NET Framework 4.x
  6. 32位運行時停產:SAP已確認32位CR .NET運行時在SP 39(2025年12月)後停產; 未來服務包僅提供64位
  7. 報告設計器依賴性:需要CR4VS Visual Studio擴展或獨立的Crystal Reports設計工具來建立.rpt文件

SAP Crystal Reports的隱藏成本

成本因素 SAP Crystal Reports IronPDF
運行時分發 可再分發的MSI安裝程式 NuGet套件
安裝 運行時安裝程式+ VS擴展 dotnet add package IronPdf
部署 在目標機器上運行MSI xcopy / 發佈
64位支持 是(32位運行時在SP 39後結束,2025年12月) 本機
.NET Core / .NET 5+ 不支持(僅限框架4.x) 完全支持(.NET 6/8/9,框架4.6.2+)
雲端部署 僅限Windows虛擬機 簡單
Linux / Docker 不支持(僅限Windows) 支援

SAP Crystal Reports與IronPDF的比較

功能 SAP Crystal Reports IronPDF
主要功能 企業報告平台 HTML到PDF轉換引擎和PDF操作
整合 在SAP生態系統中最好 現代.NET整合,輕量級NuGet包
易用性 複雜的設置和部署 簡化整合,支持.NET開發者
報告設計器 必需的 可選(HTML/CSS)
模板格式 .rpt(二進位) HTML/CSS
HTML 到 PDF 完整的Chromium
URL至PDF
CSS 支援 完整支持 CSS3
JavaScript 完整的ES2024
PDF 操作 完整(合併、拆分、編輯)
數位簽名
PDF/A合規性
現代相關性 下降,被現代替代品取代 現代,與當前技術良好整合

對於目標現代.NET(6、8、9)和跨平台部署的團隊,IronPDF提供了Crystal Reports運行時——鎖定到.NET Framework 4.x——無法提供的本機支持。


開始之前

前提條件

  1. .NET環境: .NET Framework 4.6.2+或.NET 6 / 8 / 9
  2. NuGet存取: 有能力安裝NuGet套件
  3. IronPDF授權:ironpdf.com獲取您的授權金鑰

NuGet包變更

# Crystal Reports for Visual Studio is not distributed by SAP on NuGet.
# Projects typically reference the GAC-installed CrystalDecisions.*.dll
# assemblies delivered by the CR4VS / CR runtime MSI. Community-maintained
#NuGetwrappers such as CrystalReports.Engine exist for build automation
# but are not official SAP packages.

# 1. Remove direct assembly references (CrystalDecisions.*.dll) from your .csproj
# 2. If using a communityNuGetwrapper, remove it:
dotnet remove package CrystalReports.Engine

# 3. Uninstall the Crystal Reports runtime MSI from build/deploy targets

# 4. Install IronPDF
dotnet add package IronPdf
# Crystal Reports for Visual Studio is not distributed by SAP on NuGet.
# Projects typically reference the GAC-installed CrystalDecisions.*.dll
# assemblies delivered by the CR4VS / CR runtime MSI. Community-maintained
#NuGetwrappers such as CrystalReports.Engine exist for build automation
# but are not official SAP packages.

# 1. Remove direct assembly references (CrystalDecisions.*.dll) from your .csproj
# 2. If using a communityNuGetwrapper, remove it:
dotnet remove package CrystalReports.Engine

# 3. Uninstall the Crystal Reports runtime MSI from build/deploy targets

# 4. Install IronPDF
dotnet add package IronPdf
SHELL

授權配置

// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

完整API參考

名稱空間變更

// Before: SAP Crystal Reports
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer;

// After: IronPDF
using IronPdf;
// Before: SAP Crystal Reports
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer;

// After: IronPDF
using IronPdf;
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportAppServer

Imports IronPdf
$vbLabelText   $csharpLabel

核心API對應

SAP Crystal Reports IronPDF 注釋
ReportDocument ChromePdfRenderer 核心渲染
ReportDocument.Load() RenderHtmlAsPdf() 載入內容
.rpt文件 HTML/CSS模板 模板格式
SetDataSource() HTML和資料 資料綁定
SetParameterValue() 字串插值 參數
ExportToDisk() pdf.SaveAs() 保存文件
ExportToStream() pdf.BinaryData 獲取字節
PrintToPrinter() pdf.Print() 列印
Database.Tables C#資料存取 資料源
FormulaFieldDefinitions C#邏輯 計算
SummaryInfo pdf.MetaData PDF元資料
ExportFormatType.PortableDocFormat 預設輸出 PDF本機

程式碼遷移範例

範例1:HTML轉PDF轉換

之前(SAP Crystal Reports):

// NuGet: Install-Package CrystalReports.Engine
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;

class Program
{
    static void Main()
    {
        // Crystal Reports requires a .rpt file template
        ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load("Report.rpt");

        // Crystal Reports doesn't directly support HTML
        // You need to bind data to the report template
        // reportDocument.SetDataSource(dataSet);

        ExportOptions exportOptions = reportDocument.ExportOptions;
        exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

        DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions();
        diskOptions.DiskFileName = "output.pdf";
        exportOptions.DestinationOptions = diskOptions;

        reportDocument.Export();
        reportDocument.Close();
        reportDocument.Dispose();
    }
}
// NuGet: Install-Package CrystalReports.Engine
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;

class Program
{
    static void Main()
    {
        // Crystal Reports requires a .rpt file template
        ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load("Report.rpt");

        // Crystal Reports doesn't directly support HTML
        // You need to bind data to the report template
        // reportDocument.SetDataSource(dataSet);

        ExportOptions exportOptions = reportDocument.ExportOptions;
        exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

        DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions();
        diskOptions.DiskFileName = "output.pdf";
        exportOptions.DestinationOptions = diskOptions;

        reportDocument.Export();
        reportDocument.Close();
        reportDocument.Dispose();
    }
}
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System

Class Program
    Shared Sub Main()
        ' Crystal Reports requires a .rpt file template
        Dim reportDocument As New ReportDocument()
        reportDocument.Load("Report.rpt")

        ' Crystal Reports doesn't directly support HTML
        ' You need to bind data to the report template
        ' reportDocument.SetDataSource(dataSet)

        Dim exportOptions As ExportOptions = reportDocument.ExportOptions
        exportOptions.ExportDestinationType = ExportDestinationType.DiskFile
        exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat

        Dim diskOptions As New DiskFileDestinationOptions()
        diskOptions.DiskFileName = "output.pdf"
        exportOptions.DestinationOptions = diskOptions

        reportDocument.Export()
        reportDocument.Close()
        reportDocument.Dispose()
    End Sub
End Class
$vbLabelText   $csharpLabel

之後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        // Create a PDF from HTML string
        var renderer = new ChromePdfRenderer();

        string htmlContent = "<h1>Hello World</h1><p>This is a PDF generated from HTML.</p>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created successfully!");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        // Create a PDF from HTML string
        var renderer = new ChromePdfRenderer();

        string htmlContent = "<h1>Hello World</h1><p>This is a PDF generated from HTML.</p>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created successfully!");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        ' Create a PDF from HTML string
        Dim renderer As New ChromePdfRenderer()

        Dim htmlContent As String = "<h1>Hello World</h1><p>This is a PDF generated from HTML.</p>"

        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("output.pdf")

        Console.WriteLine("PDF created successfully!")
    End Sub
End Class
$vbLabelText   $csharpLabel

此範例說明了根本的範式差異。 SAP Crystal Reports需要一個在Crystal Reports設計器中建立的預設計DiskFileDestinationOptions。 該庫不直接支持HTML內容——您必須將資料綁定到報告模板。

IronPDF直接接受HTML字串:建立一個SaveAs()。 不需要設計者,不需要二進制模板,不需要複雜的導出配置。 查看更多HTML到PDF文件以獲得完整的範例。

範例2:URL轉PDF轉換

之前(SAP Crystal Reports):

// NuGet: Install-Package CrystalReports.Engine
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;
using System.Net;

class Program
{
    static void Main()
    {
        // Crystal Reports cannot directly convert URLs to PDF
        // You need to create a report template first

        // Download HTML content
        WebClient client = new WebClient();
        string htmlContent = client.DownloadString("https://example.com");

        // Crystal Reports requires .rpt template and data binding
        // This approach is not straightforward for URL conversion
        ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load("WebReport.rpt");

        // Manual data extraction and binding required
        // reportDocument.SetDataSource(extractedData);

        reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "output.pdf");
        reportDocument.Close();
        reportDocument.Dispose();
    }
}
// NuGet: Install-Package CrystalReports.Engine
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;
using System.Net;

class Program
{
    static void Main()
    {
        // Crystal Reports cannot directly convert URLs to PDF
        // You need to create a report template first

        // Download HTML content
        WebClient client = new WebClient();
        string htmlContent = client.DownloadString("https://example.com");

        // Crystal Reports requires .rpt template and data binding
        // This approach is not straightforward for URL conversion
        ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load("WebReport.rpt");

        // Manual data extraction and binding required
        // reportDocument.SetDataSource(extractedData);

        reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "output.pdf");
        reportDocument.Close();
        reportDocument.Dispose();
    }
}
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System
Imports System.Net

Module Program
    Sub Main()
        ' Crystal Reports cannot directly convert URLs to PDF
        ' You need to create a report template first

        ' Download HTML content
        Dim client As New WebClient()
        Dim htmlContent As String = client.DownloadString("https://example.com")

        ' Crystal Reports requires .rpt template and data binding
        ' This approach is not straightforward for URL conversion
        Dim reportDocument As New ReportDocument()
        reportDocument.Load("WebReport.rpt")

        ' Manual data extraction and binding required
        ' reportDocument.SetDataSource(extractedData)

        reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "output.pdf")
        reportDocument.Close()
        reportDocument.Dispose()
    End Sub
End Module
$vbLabelText   $csharpLabel

之後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        // Create a PDF from a URL
        var renderer = new ChromePdfRenderer();

        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created from URL successfully!");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        // Create a PDF from a URL
        var renderer = new ChromePdfRenderer();

        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created from URL successfully!");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        ' Create a PDF from a URL
        Dim renderer As New ChromePdfRenderer()

        Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
        pdf.SaveAs("output.pdf")

        Console.WriteLine("PDF created from URL successfully!")
    End Sub
End Class
$vbLabelText   $csharpLabel

SAP Crystal Reports無法直接將URL轉換為PDF。 您需要手動下載HTML內容,使用.rpt模板中——這是一個不簡單的過程,需要大量的人工工作。

IronPDF的RenderUrlAsPdf()方法捕獲完全呈現的網頁,包含所有CSS,JavaScript和圖像,這只需要一個調用。 在我們的教程中了解更多。

範例3:具有頁碼的標頭和頁腳

之前(SAP Crystal Reports):

// NuGet: Install-Package CrystalReports.Engine
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;

class Program
{
    static void Main()
    {
        // Crystal Reports requires design-time configuration
        ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load("Report.rpt");

        // Headers and footers must be designed in the .rpt file
        // using Crystal Reports designer
        // You can set parameter values programmatically
        reportDocument.SetParameterValue("HeaderText", "Company Name");
        reportDocument.SetParameterValue("FooterText", "Page ");

        // Crystal Reports handles page numbers through formula fields
        // configured in the designer

        reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "output.pdf");
        reportDocument.Close();
        reportDocument.Dispose();
    }
}
// NuGet: Install-Package CrystalReports.Engine
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;

class Program
{
    static void Main()
    {
        // Crystal Reports requires design-time configuration
        ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load("Report.rpt");

        // Headers and footers must be designed in the .rpt file
        // using Crystal Reports designer
        // You can set parameter values programmatically
        reportDocument.SetParameterValue("HeaderText", "Company Name");
        reportDocument.SetParameterValue("FooterText", "Page ");

        // Crystal Reports handles page numbers through formula fields
        // configured in the designer

        reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "output.pdf");
        reportDocument.Close();
        reportDocument.Dispose();
    }
}
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System

Class Program
    Shared Sub Main()
        ' Crystal Reports requires design-time configuration
        Dim reportDocument As New ReportDocument()
        reportDocument.Load("Report.rpt")

        ' Headers and footers must be designed in the .rpt file
        ' using Crystal Reports designer
        ' You can set parameter values programmatically
        reportDocument.SetParameterValue("HeaderText", "Company Name")
        reportDocument.SetParameterValue("FooterText", "Page ")

        ' Crystal Reports handles page numbers through formula fields
        ' configured in the designer

        reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "output.pdf")
        reportDocument.Close()
        reportDocument.Dispose()
    End Sub
End Class
$vbLabelText   $csharpLabel

之後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        // Configure headers and footers
        renderer.RenderingOptions.TextHeader.CenterText = "Company Name";
        renderer.RenderingOptions.TextHeader.FontSize = 12;

        renderer.RenderingOptions.TextFooter.LeftText = "Confidential";
        renderer.RenderingOptions.TextFooter.RightText = "Page {page} of {total-pages}";
        renderer.RenderingOptions.TextFooter.FontSize = 10;

        string htmlContent = "<h1>Document Title</h1><p>Document content goes here.</p>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF with headers and footers created!");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        // Configure headers and footers
        renderer.RenderingOptions.TextHeader.CenterText = "Company Name";
        renderer.RenderingOptions.TextHeader.FontSize = 12;

        renderer.RenderingOptions.TextFooter.LeftText = "Confidential";
        renderer.RenderingOptions.TextFooter.RightText = "Page {page} of {total-pages}";
        renderer.RenderingOptions.TextFooter.FontSize = 10;

        string htmlContent = "<h1>Document Title</h1><p>Document content goes here.</p>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF with headers and footers created!");
    }
}
Imports IronPdf
Imports System

Module Program
    Sub Main()
        Dim renderer As New ChromePdfRenderer()

        ' Configure headers and footers
        renderer.RenderingOptions.TextHeader.CenterText = "Company Name"
        renderer.RenderingOptions.TextHeader.FontSize = 12

        renderer.RenderingOptions.TextFooter.LeftText = "Confidential"
        renderer.RenderingOptions.TextFooter.RightText = "Page {page} of {total-pages}"
        renderer.RenderingOptions.TextFooter.FontSize = 10

        Dim htmlContent As String = "<h1>Document Title</h1><p>Document content goes here.</p>"

        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("output.pdf")

        Console.WriteLine("PDF with headers and footers created!")
    End Sub
End Module
$vbLabelText   $csharpLabel

SAP Crystal Reports需要為頁眉和頁腳進行設計時配置。 您必須在.rpt文件中使用Crystal Reports設計器設計它們,然後在運行時傳遞像"FooterText"一樣的參數值。頁碼必須通過設計器中的公式字段來配置。

IronPDF通過TextFooter屬性提供程式化的頁眉/頁腳配置。 可在程式碼中直接設置FontSize。 頁碼使用{total-pages}占位符——不需要設計器。


常見遷移問題

問題1:.rpt文件轉換

SAP Crystal Reports:二進位.rpt文件,嵌入了布局、資料、公式。

解決方案:不能直接轉換——必須重新建立為HTML:

  1. 在Crystal Reports設計器中打開.rpt
  2. 文件布局、字體、顏色
  3. 記錄所有公式字段
  4. 用HTML/CSS重建
  5. 將公式轉換為C#程式碼

問題2:資料庫連接

SAP Crystal Reports:嵌入連接字串和ODBC。

解決方案:使用您的應用程式的資料層:

// Instead of Crystal's database integration
var data = await _dbContext.Orders
    .Where(o => o.Date >= startDate && o.Date <= endDate)
    .ToListAsync();

// Bind to HTML template
var html = GenerateReportHtml(data);
// Instead of Crystal's database integration
var data = await _dbContext.Orders
    .Where(o => o.Date >= startDate && o.Date <= endDate)
    .ToListAsync();

// Bind to HTML template
var html = GenerateReportHtml(data);
Option Strict On



' Instead of Crystal's database integration
Dim data = Await _dbContext.Orders _
    .Where(Function(o) o.Date >= startDate AndAlso o.Date <= endDate) _
    .ToListAsync()

' Bind to HTML template
Dim html = GenerateReportHtml(data)
$vbLabelText   $csharpLabel

問題3:運行時依賴性

SAP Crystal Reports:需要安裝Crystal Reports運行時(500MB以上)。

解決方案:IronPDF是自帶的:

# Just add theNuGetpackage
dotnet add package IronPdf
# That's it - no additional installs needed
# Just add theNuGetpackage
dotnet add package IronPdf
# That's it - no additional installs needed
SHELL

問題4:32-bit/64-bit和.NET Framework鎖定

SAP Crystal Reports:Crystal Reports運行時依賴於COM並分發於獨立的32位和64位MSI中。 SAP已確認32位CR .NET運行時在SP 39(2025年12月)後停產; 未來服務包僅提供64位。 運行時目標.NET Framework 4.x,且不能在.NET Core /.NET 5+下載入。

解決方案:IronPDF可在.NET Framework 4.6.2+、.NET 6、.NET 8和.NET 9上運行——包括Linux和Docker。 64位或AnyCPU不需要特殊配置。


遷移後的新能力

遷移到IronPDF後,您獲得SAP Crystal Reports無法提供的功能:

PDF合併

var pdf1 = PdfDocument.FromFile("report1.pdf");
var pdf2 = PdfDocument.FromFile("report2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("complete_report.pdf");
var pdf1 = PdfDocument.FromFile("report1.pdf");
var pdf2 = PdfDocument.FromFile("report2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("complete_report.pdf");
Dim pdf1 = PdfDocument.FromFile("report1.pdf")
Dim pdf2 = PdfDocument.FromFile("report2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("complete_report.pdf")
$vbLabelText   $csharpLabel

PDF安全性

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(reportHtml);

pdf.MetaData.Title = "Quarterly Sales Report";
pdf.MetaData.Author = "Finance Department";

pdf.SecuritySettings.OwnerPassword = "admin123";
pdf.SecuritySettings.UserPassword = "view123";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;

pdf.SaveAs("secure_report.pdf");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(reportHtml);

pdf.MetaData.Title = "Quarterly Sales Report";
pdf.MetaData.Author = "Finance Department";

pdf.SecuritySettings.OwnerPassword = "admin123";
pdf.SecuritySettings.UserPassword = "view123";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;

pdf.SaveAs("secure_report.pdf");
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(reportHtml)

pdf.MetaData.Title = "Quarterly Sales Report"
pdf.MetaData.Author = "Finance Department"

pdf.SecuritySettings.OwnerPassword = "admin123"
pdf.SecuritySettings.UserPassword = "view123"
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights
pdf.SecuritySettings.AllowUserCopyPasteContent = False

pdf.SaveAs("secure_report.pdf")
$vbLabelText   $csharpLabel

數位簽名

var signature = new PdfSignature("certificate.pfx", "password");
pdf.Sign(signature);
var signature = new PdfSignature("certificate.pfx", "password");
pdf.Sign(signature);
Dim signature = New PdfSignature("certificate.pfx", "password")
pdf.Sign(signature)
$vbLabelText   $csharpLabel

水印

using IronPdf.Editing;

pdf.ApplyWatermark("<h1 style='color:red; opacity:0.3;'>DRAFT</h1>");
using IronPdf.Editing;

pdf.ApplyWatermark("<h1 style='color:red; opacity:0.3;'>DRAFT</h1>");
Imports IronPdf.Editing

pdf.ApplyWatermark("<h1 style='color:red; opacity:0.3;'>DRAFT</h1>")
$vbLabelText   $csharpLabel

功能比較總結

功能 SAP Crystal Reports IronPDF
安裝 運行時分發 MSI可再分發 NuGet
安裝方法 MSI + Visual Studio擴展 NuGet
部署 在目標機器上運行MSI xcopy / 發佈
平台支持 .NET Framework 4.x 是(4.6.2+)
.NET Core / .NET 5+ 不支持 是(.NET 6/8/9)
64位本機 是(32位於2025年12月SP 39後結束)
Linux / Docker 不支持(僅限Windows)
Azure / AWS 僅限Windows虛擬機 簡單
開發 報告設計器 必需的 可選(HTML)
模板格式 .rpt(二進位) HTML/CSS
學習曲線 Crystal語法 網路標準
IntelliSense 完整的C#
渲染 HTML轉PDF 完整的Chromium
URL到PDF
CSS支持 完整支持 CSS3
JavaScript 完整的ES2024
PDF功能 合併PDF
拆分PDF
浮水印 有限 完整HTML
數位簽名
PDF/A

遷移檢查表

遷移前

  • 清點所有.rpt文件
  • 截圖每個報告布局以供參考
  • 文件公式字段和計算
  • 列出所有資料源和參數
  • 確定列印要求
  • 獲取IronPDF授權金鑰來自ironpdf.com

程式碼更新

  • 移除Crystal Reports包(CrystalDecisions.CrystalReports.Engine,等)
  • 從部署中移除運行時安裝
  • 安裝IronPdf NuGet包
  • .rpt布局轉換為HTML/CSS模板
  • 將Crystal公式轉換為C#程式碼
  • SetDataSource()更新資料綁定為HTML字串插值
  • 將列印程式碼從pdf.Print()
  • 在應用程式啟動時新增授權初始化

基礎結構

  • 從伺服器中移除水晶運行時
  • 更新部署腳本
  • 移除32位相容模式
  • 更新Docker映像(如果適用)

測試

  • 將PDF輸出與原始報告進行比較
  • 驗證所有計算
  • 測試所有參數
  • 測試列印功能
  • 性能測試
  • 64位測試

請注意SAP Crystal Reports是其相應所有者的註冊商標。 本網站未與SAP相關聯,未經SAP批准或贊助。所有產品名稱、徽標和品牌均為其相應所有者的財產。 比較僅供參考,反映撰寫時公開可用的資訊。

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

Iron 支援團隊

我們線上24小時,每週5天。
聊天
電子郵件
給我打電話