Migrate PDF Library from .NET Framework to .NET Core
24 Jul 20264 minutes to read
This section describes the changes to consider when migrating the Syncfusion® .NET PDF library from .NET Framework to .NET Core. .NET Core is the recommended target for all new and existing applications, offering cross-platform support, improved performance, and long-term support from Microsoft.
NuGet Packages
The following table lists the NuGet package mappings when migrating from .NET Framework to .NET Standard 2.0 / .NET Core.
| Packages targeting .NET Framework | Packages targeting .NET Standard 2.0 / .NET Core |
|---|---|
|
|
Class Changes
| Missing classes | Alternate classes |
|---|---|
| You can open the document as a stream from the file system using . | |
| You can open an encrypted document as a stream or byte array with a password using or . | |
| You can open a corrupted PDF document as a stream or byte array using or . | |
|
TextLineCollection Sample link: |
|
|
PdfTiffImage Sample link: |
|
|
XPSToPdfConverter Sample link: |
|
|
PdfCompressionOptions Sample link: |
|
| Not supported | |
| Not supported | |
| – Add or modify JavaScript actions on an existing PDF document. | Not supported |
| You can check whether an existing PDF document is corrupted using . | |
| Not supported | |
| Not supported | |
| BarcodeException | |
| Not supported | |
|
PdfRichMediaContent(String, Stream, String, PdfRichMediaContentType) |
|
| Not supported | |
| Not supported | |
| Not supported | |
| Not supported | |
|
TextLineCollection Sample link: |
|
| Not supported | |
| Not supported |
Method Changes
| Missing methods | Alternate methods |
|---|---|
|
ExtractText(out TextLineCollection textLineCollection) Sample link: |
|
|
ExportAsImage() Sample link: |
|
AddRedaction(PdfRedaction). Additionally, call PdfLoadedDocument.Redact() to execute the redaction.Sample link: |
|
| ToImage() | |
|
Barcode.ToImage(SizeF size) Sample link: |
|
| Not supported due to .NET Core framework limitations. Alternatively, use the [importing pages from one document to another](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/working-with-pages#importing-pages-from-an-existing-document) approach. | |
|
Not supported due to .NET Core framework limitations. Use the [.NET Word library](https://help.syncfusion.com/document-processing/word/word-library/net/overview) instead. [RTF to PDF](https://support.syncfusion.com/kb/article/7542/how-to-convert-a-word-document-to-pdf-in-aspnet-core) |
|
| Merge(PdfDocumentBase, Stream[]) | |
| Merge(PdfDocumentBase, Stream[]) | |
| Merge(PdfDocumentBase, PdfMergeOptions, Stream[]) | |
| PdfSoundAction(Stream) | |
| PdfSoundAnnotation(RectangleF, Stream) | |
| PdfTrueTypeFont(Stream) | |
| PdfTrueTypeFont(Stream, float) | |
| Not supported | |
| Not supported | |
| Not supported | |
| RemoveImage(PdfImageInfo[]) | |
|
ReplaceImage(Int32, PdfImage) Sample link: |
|
| CreateBooklet(PdfLoadedDocument, SizeF) | |
| CreateBooklet(PdfLoadedDocument, SizeF, Boolean) | |
| You can save the document as a stream to the file system using . | |
| Not supported | |
| Not supported | |
| Draw(PdfPage, PointF, Single, Single, PdfLayoutFormat) | |
| Draw(PdfPage, RectangleF, PdfLayoutFormat) | |
| Draw(PdfPage, PointF, Single, PdfLayoutFormat) | |
|
Draw(PdfPage, PointF, Single, Single, PdfMetafileLayoutFormat) |
Draw(PdfPage, PointF, Single, Single, PdfLayoutFormat) |
| Draw(PdfPage, RectangleF, PdfLayoutFormat) |
Property Changes
| Missing properties | Alternate properties |
|---|---|
|
GetImagesInfo() Sample link: |
|
|
ConvertToPDFA(PdfConformanceLevel.Pdf_A1B) Sample link: |
|
| Not supported | |
| Pdf_X1A2001 through | Not supported |
|
PdfGrid.DataSource (IEnumerable<object>) – Only strongly typedIEnumerable objects are supported in ASP.NET Core.
|
|
|
PdfLoadedDocument.CompressionOptions = PdfCompressionOptions |
PdfLoadedDocument.Compress(PdfCompressionOptions) Sample link: |
| – Enum | Not supported |
| Not supported | |
| Not supported | |
| Not supported | |
AddRedaction(PdfRedaction). Additionally, call PdfLoadedDocument.Redact() to execute the redaction.Sample link: |
|
| Not supported | |
| Not supported | |
| Not supported | |
| Not supported | |
| Not supported | |
| Not supported | |
| Not supported | |
| Not supported | |
| Not supported |
Event Changes
| Missing events | Alternate events |
|---|---|
| FontNotFoundEventArgs | Not supported |
| ImagePreRenderEventArgs | Not supported |
| Not supported |
Advantages
- Cross-platform compatibility: ASP.NET Core runs on Windows, macOS, and Linux, making it a flexible option for developing web applications.
- Cloud integration: ASP.NET Core integrates easily with cloud platforms such as Microsoft Azure, Amazon Web Services, Docker, and Google Cloud Platform.
Notable Changes
- For text measuring and graphics operations in .NET Framework, the library uses System.Drawing. In .NET Core, the library uses Syncfusion.Drawing for the same operations.
- The following features require the NuGet package Syncfusion.Pdf.Imaging.Net.Core, which is separate from the Syncfusion.Pdf.Net.Core NuGet package:
- To convert XPS to PDF in ASP.NET Core, use the Syncfusion.XpsToPdfConverter.Net.Core NuGet package.
- To convert PDF to image in ASP.NET Core, use the Syncfusion.PdfToImageConverter.Net NuGet package.
Migrate from System.Drawing.Common to SkiaSharp
Starting with the Volume 2, 2023 release, the System.Drawing.Common package has been removed as a dependency from the Syncfusion.Pdf.Imaging.Net.Core package. SkiaSharp has been introduced as the replacement library. This migration introduces the following API breaking changes.
| API Name | Class | Return Type | Alternative API / Return Type |
|---|---|---|---|
| ToImage() | Pdf417Barcode | Image | ToImage(Syncfusion.Drawing.SizeF size) Return Type: Stream |
| ToImage(System.Drawing.SizeF size) | Pdf417Barcode | Image | ToImage(Syncfusion.Drawing.SizeF size) Return Type: Stream |
| ToImage(System.Drawing.SizeF size) | PdfDataMatrixBarcode | Image | ToImage(Syncfusion.Drawing.SizeF size) Return Type: Stream |
| ToImage() | PdfEan13Barcode | Image | ToImage() Return Type: Stream |
| ToImage(System.Drawing.SizeF size) | PdfEan13Barcode | Image | ToImage(Syncfusion.Drawing.SizeF size) Return Type: Stream |
| ToImage(System.Drawing.SizeF size) | PdfEan8Barcode | Image | ToImage(Syncfusion.Drawing.SizeF size) Return Type: Stream |
| ToImage() | PdfEan8Barcode | Image | ToImage() Return Type: Stream |
| ToImage(System.Drawing.SizeF size) | PdfQRBarcode | Image | ToImage(Syncfusion.Drawing.SizeF size) Return Type: Stream |
| ToImage(this PdfBidimensionalBarcode barcode) | PdfBarcodeExtension | Image | ToImage(this PdfBidimensionalBarcode barcode) Return Type: Stream |
| ToImage(this PdfBidimensionalBarcode barcode, System.Drawing.SizeF size) | PdfBarcodeExtension | Image | ToImage(this PdfBidimensionalBarcode barcode, Syncfusion.Drawing.SizeF size) Return Type: Stream |
| ToImage(this PdfUnidimensionalBarcode barcode) | PdfBarcodeExtension | Image | ToImage(this PdfUnidimensionalBarcode barcode) Return Type: Stream |
| ToImage(this PdfUnidimensionalBarcode barcode, System.Drawing.SizeF size) | PdfBarcodeExtension | Image | ToImage(this PdfUnidimensionalBarcode barcode, Syncfusion.Drawing.SizeF size) Return Type: Stream |
| Image | PdfImageInfo | Image | ImageStream Return Type: Stream |
| PdfTiffImage(Image image) | PdfTiffImage | Image | PdfTiffImage(Stream image) Return Type: Stream |
| ExtractImages(this PdfPageBase page) | PdfImageExtractor | Image[] | ExtractImages(this PdfPageBase page) Return Type: Stream[] |
| ToImage() | PdfUnidimensionalBarcode | Image | ToImage() Return Type: Stream |
| ToImage(System.Drawing.SizeF size) | PdfUnidimensionalBarcode | Image | ToImage(Syncfusion.Drawing.SizeF size) Return Type: Stream |
| RenderToImage(this PdfBidimensionalBarcode barcode) | PdfBarcodeExtension | Image | ToImage(this PdfBidimensionalBarcode barcode) |
| RenderToImage(this PdfBidimensionalBarcode barcode, System.Drawing.SizeF size) | PdfBarcodeExtension | Image | ToImage(this PdfBidimensionalBarcode barcode, Syncfusion.Drawing.SizeF size) |
| RenderToImage(this PdfUnidimensionalBarcode barcode) | PdfBarcodeExtension | Image | ToImage(this PdfUnidimensionalBarcode barcode) |
| RenderToImage(this PdfUnidimensionalBarcode barcode, System.Drawing.SizeF size) | PdfBarcodeExtension | Image | ToImage(this PdfUnidimensionalBarcode barcode, Syncfusion.Drawing.SizeF size) |
| Bounds | PdfImageInfo | System.Drawing.RectangleF | Syncfusion.Drawing.RectangleF |