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

Syncfusion.Pdf.WinForms


Syncfusion.Pdf.Wpf


Syncfusion.Pdf.AspNet.Mvc5

Syncfusion.Pdf.Net.Core

Class Changes

Missing classes Alternate classes

PdfLoadedDocument(String)

You can open the document as a stream from the file system using

PdfLoadedDocument(Stream)

.

PdfLoadedDocument(String, String)

You can open an encrypted document as a stream or byte array with a password using

PdfLoadedDocument(Stream, String)

or

PdfLoadedDocument(Byte[], String)

.

PdfLoadedDocument(String, Boolean)

You can open a corrupted PDF document as a stream or byte array using

PdfLoadedDocument(Stream, Boolean)

or

PdfLoadedDocument(Byte[], Boolean)

.

PdfBitmap(String)

PdfBitmap(Stream)

PdfBitmap(String, Boolean)

PdfBitmap(Stream, Boolean)

TextLines

TextLineCollection
Sample link:

Here

PdfBitmap

PdfTiffImage
Sample link:

Here

XPSToPdfConverter

XPSToPdfConverter
Sample link:

Here

PdfCompressionOptions

PdfCompressionOptions
Sample link:

Here

PdfFileLinkAnnotation

Not supported

PdfLaunchAction

Not supported

PdfJavaScriptAction

– Add or modify JavaScript actions on an existing PDF document.
Not supported

PdfDocumentAnalyzer(String)

You can check whether an existing PDF document is corrupted using

PdfDocumentAnalyzer(Stream)

.

PdfUsedFont

Not supported

ImageExportSettings

Not supported

PdfBarcodeException

BarcodeException

HtmlToPdfResult

Not supported

PdfRichMediaContent(String, PdfRichMediaContentType)

PdfRichMediaContent(String, Stream, String, PdfRichMediaContentType)

PdfAngleMeasurementAnnotation(PointF[])

Not supported

PdfCertificateDistinguishedName

Not supported

GraphicsStateData

Not supported

PdfConfig

Not supported

TextData

TextLineCollection
Sample link:

Here

PdfMetafile

Not supported

PdfMetafileLayoutFormat

PdfLayoutFormat

XFdfDocument

Not supported

Method Changes

Missing methods Alternate methods

ExtractText(out TextLines textLines)

ExtractText(out TextLineCollection textLineCollection)
Sample link:

Here

ExtractImages()

ExtractImages

ExportAsImage()

ExportAsImage()
Sample link:

Here

Redactions.Add(PdfRedaction)

AddRedaction(PdfRedaction). Additionally, call PdfLoadedDocument.Redact() to execute the redaction.
Sample link:

Here

ToImage()

ToImage()

Barcode.ToImage(SizeF size)

Barcode.ToImage(SizeF size)
Sample link:

Here

Split()

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.

FromRtf(String, Single, PdfImageType)

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, object[])

Merge(PdfDocumentBase, Stream[])

Merge(String[])

Merge(PdfDocumentBase, Stream[])

Merge(String[], PdfMergeOptions)

Merge(PdfDocumentBase, PdfMergeOptions, Stream[])

PdfImage.FromFile(String)

PdfImage.FromStream(Stream)

Image.FromFile(String)

Image.FromStream(Stream)

PdfSoundAction(String)

PdfSoundAction(Stream)

PdfSoundAnnotation(RectangleF, String)

PdfSoundAnnotation(RectangleF, Stream)

PdfTrueTypeFont(Font)

PdfTrueTypeFont(Stream)

PdfTrueTypeFont(Font, float)

PdfTrueTypeFont(Stream, float)

Replace(PdfFont)

Not supported

EmbedFonts()

Not supported

ExportAnnotations(String, AnnotationDataFormat)

ExportAnnotations(Stream, AnnotationDataFormat)

ImportAnnotations(String, AnnotationDataFormat)

ImportAnnotations(Stream, AnnotationDataFormat)

ExportData(String, DataFormat, String)

ExportData(Stream, DataFormat, String)

ImportData(String, DataFormat)

ImportData(Byte[], DataFormat)

ImportDataJson(String)

ImportDataJson(Stream)

ImportDataXFDF(String)

ImportDataXFDF(Stream)

GetFontsFromAppearance()

Not supported

RemoveImage(PdfImageInfo)

RemoveImage(PdfImageInfo[])

ReplaceImage(Int32, PdfImage)

ReplaceImage(Int32, PdfImage)
Sample link:

Here

CreateBooklet(String, String, SizeF)

CreateBooklet(PdfLoadedDocument, SizeF)

CreateBooklet(String, String, SizeF, Boolean)

CreateBooklet(PdfLoadedDocument, SizeF, Boolean)

Save(String)

You can save the document as a stream to the file system using

Save(Stream)

.

Save(String, HttpResponse, HttpReadType)

Not supported

Save(Stream, HttpContext)

Not supported

Draw(PdfGraphics, PointF, Single, Single)

Draw(PdfPage, PointF, Single, Single, PdfLayoutFormat)

Draw(PdfGraphics, RectangleF)

Draw(PdfPage, RectangleF, PdfLayoutFormat)

Draw(PdfPage, PointF, Single, PdfMetafileLayoutFormat)

Draw(PdfPage, PointF, Single, PdfLayoutFormat)

Draw(PdfPage, PointF, Single, Single, PdfMetafileLayoutFormat)

Draw(PdfPage, PointF, Single, Single, PdfLayoutFormat)

Draw(PdfPage, RectangleF, PdfMetafileLayoutFormat)

Draw(PdfPage, RectangleF, PdfLayoutFormat)

Property Changes

Missing properties Alternate properties

ImagesInfo

GetImagesInfo()
Sample link:

Here

Conformance

ConvertToPDFA(PdfConformanceLevel.Pdf_A1B)
Sample link:

Here

XFA Flatten

Not supported
Pdf_X1A2001 through

PdfConformanceLevel

Not supported

PdfGrid.DataSource (DataTable)

PdfGrid.DataSource (IEnumerable<object>)

– Only strongly typed IEnumerable objects are supported in ASP.NET Core.

PdfLoadedDocument.CompressionOptions = PdfCompressionOptions

PdfLoadedDocument.Compress(PdfCompressionOptions)
Sample link:

Here

EncodingType

– Enum
Not supported

ImageExportSettings

Not supported

IsAllFontsEmbedded

Not supported

ColorSpace

Not supported

Redactions

AddRedaction(PdfRedaction). Additionally, call PdfLoadedDocument.Redact() to execute the redaction.
Sample link:

Here

IsColored

Not supported

ActiveFrame

Not supported

Encoding

Not supported

FrameCount

Not supported

Mask

Not supported

Quality

Not supported

IsNativeRenderingEnabled

Not supported

TextAlign

Not supported

RightToLeft

Not supported

Event Changes

Missing events Alternate events
FontNotFoundEventArgs Not supported
ImagePreRenderEventArgs Not supported

ImagePreRenderEventArgs

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

  1. 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.
  2. The following features require the NuGet package Syncfusion.Pdf.Imaging.Net.Core, which is separate from the Syncfusion.Pdf.Net.Core NuGet package:
  3. To convert XPS to PDF in ASP.NET Core, use the Syncfusion.XpsToPdfConverter.Net.Core NuGet package.
  4. 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