Migrate PDF library from .NET Framework to .NET Core

16 Jun 20236 minutes to read

In this section, we will see about the changes which need to be considered while migrating Syncfusion .NET PDF library from .NET Framework to .NET Core.

NuGet packages

Packages targeting .NET Framework Packages targeting .NET Standard 2.0/.NET Core

Syncfusion.Pdf.WinForms


Syncfusion.Pdf.Wpf


Syncfusion.Pdf.AspNet


Syncfusion.Pdf.AspNet.Mvc4


Syncfusion.Pdf.AspNet.Mvc5

Syncfusion.Pdf.Net.Core

Class changes

Missing classes Alternate classes

PdfLoadedDocument(String)

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

PdfLoadedDocument(Stream)

API.

PdfLoadedDocument(String, String)

You can open the encrypted document as stream or byte array with password from system file using

PdfLoadedDocument(Stream, String)

or

PdfLoadedDocument(Byte[], String)

API.

PdfLoadedDocument(String, Boolean)

You can open the corrupted PDF document as stream or byte array with Boolean from system file using

PdfLoadedDocument(Stream, Boolean)

or

PdfLoadedDocument(Byte[], Boolean)

API.

PdfBitmap(String)

PdfBitmap(Stream)

PdfBitmap(String, Boolean)

PdfBitmap(Steam, Boolean)

TextLines

TextLineCollection
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Text%20Extraction/Extract-each-lines-from-an-existing-PDF-document

PdfBitmap

PdfTiffImage
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Document%20conversion/TIFF-to-PDF/Converting-multipage-TIFF-to-PDF-document

XPSToPdfConverter

XPSToPdfConverter
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Document%20conversion/Converting-XPS-to-PDF-document

PdfCompressionOptions

PdfCompressionOptions
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Compression/Compress-the-images-in-an-existing-PDF-document

PdfFileLinkAnnotation

Not supported

PdfLaunchAction

Not supported

PdfJavaScriptAction

- Add/modify JavaScript actions on existing PDF document
Not supported

PdfDocumentAnalyzer(String)

You can check whether the existing PDF document is corrupted or not using

PdfDocumentAnalyzer(Stream)

.

PdfUsedFont

Not supported

ImageExportSettings

Not supported

PdfBarcodeException

BarcodeException

ImageExportSettings

Not supported

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

Not supported

TextLines

TextLineCollection
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Text%20Extraction/Extract-each-lines-from-an-existing-PDF-document

PdfMetafile

Not supported

PdfMetafileLayoutFormat

PdfLayoutFormat
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Text/Adding-HTML-styled-text-to-PDF-document/

XFdfDocument

Not supported

HtmlToPdfResult

Not supported

PdfAngleMeasurementAnnotation

Not supported

Method changes

Missing methods Alternate methods

ExtractText(out TextLines textLines)

ExtractText(out TextLineCollection textLineCollection)
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Text%20Extraction/Extract-each-lines-from-an-existing-PDF-document

ExtractImages()

ExtractImages
*Sample link:*

https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.PdfPageBase.html#Syncfusion_Pdf_PdfPageBase_ExtractImages().html

ExportAsImage()

ExportAsImage()
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Document%20conversion/PDF-to-Image/Convert-PDF-page-into-image

Redactions.Add(PdfRedaction)

AddRedaction(PdfRedaction) - Additionally, call the following method to execute the redaction.
PdfLoadedDocument.Redact();
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Redaction/Removing-sensitive-content-from-the-PDF-document/

ToImage()

ToImage()

Barcode.ToImage(SizeF size)

Barcode.ToImage(SizeF size)
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Barcode/Export-one-dimensional-barcode-as-image/

Split()

Not supported due to .NET Core framework limitations. Alternatively, this can be achieved by

importing pages from one document to another

.

FromRtf(String, Single, PdfImageType)

Not supported due to .NET Core framework limitations. Alternatively, this can be achieved by using

.NET Word library

.

RTF to PDF

Merge(PdfDocumentBase, object[])

Merge(PdfDocumentBase, Stream[])
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Merge%20PDFs/Merge-multiple-documents-from-stream/

Merge(String[])

Merge(PdfDocumentBase, Stream[])
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Merge%20PDFs/Merge-multiple-documents-from-stream/

Merge(String[], PdfMergeOptions)

Merge(PdfDocumentBase, PdfMergeOptions, Object[]) - Object[] in the form of 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, int)

PdfTrueTypeFont(Stream, int)

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[])
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Images/Remove-images-from-PDF-document

ReplaceImage(Int32, PdfImage)

ReplaceImage(Int32, PdfImage)
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Images/Replace-image-in-an-existing-PDF-document/

CreateBooklet(String, String, SizeF)

CreateBooklet(PdfLoadedDocument, SizeF)

CreateBooklet(String, String, SizeF, Boolean)

CreateBooklet(PdfLoadedDocument, SizeF, Boolean)

Save(String)

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

Save(Stream)

API.

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)

Replace(PdfFont)

Not supported

Property changes

Missing properties Alternate properties

ImagesInfo

GetImagesInfo()
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Image%20Extraction/Extract-the-image-info-from-a-PDF-page/

Conformance

ConvertToPDFA(PdfConformanceLevel.Pdf_A1B)
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/PDF%20Conformance/Get-PDF-to-PDFA-conversion-progress

XFA Flatten

Not supported
Pdf_X1A2001 through

PdfConformanceLevel

Not supported

PdfGrid.DataSource (DataTable)

[PdfGrid.DataSource (IEnumerable)](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Grid.PdfGrid.html#Syncfusion_Pdf_Grid_PdfGrid_DataSource)

- In ASP.NET Core, only the strongly typed IEnumerable objects are supported.

PdfLoadedDocument.CompressionOptions = PdfCompressionOptions

PdfLoadedDocument.Compress(PdfCompressionOptions)
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Compression/Compress-the-images-in-an-existing-PDF-document

EncodingType

- Enum
Not supported

ImageExportSettings

Not supported

IsAllFontsEmbedded

Not supported

ColorSpace

Not supported

Redactions

AddRedaction(PdfRedaction) - Additionally, call the following method to execute the redaction.
PdfLoadedDocument.Redact();
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Redaction/Removing-sensitive-content-from-the-PDF-document/

ImagesInfo

GetImagesInfo()
*Sample link:*

https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Image%20Extraction/Extract-the-image-info-from-a-PDF-page/

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 can run on Windows, MacOS, and Linux, making it a flexible option for developing web applications.
  • Integration with cloud services: ASP.NET Core can be easily integrated with cloud services, such as Microsoft Azure, Amazon Web Services, Docker and Google Cloud Platform.

Known limitations

  • EMF and WMF images are not supported on the .NET Core platform.

Notable changes

  1. For text measuring and graphics operations in the .NET Framework, our library utilizes System.Drawing. In contrast, for similar graphics operations in .NET Core, our library employs Syncfusion.Drawing.
  2. The following features utilize the NuGet package Syncfusion.Pdf.Imaging.Net.Core Which is separate from Syncfusion.Pdf.Net.Core NuGet package.
  3. For converting XPS to PDF document, kindly utilize the Syncfusion.XpsToPdfConverter.Net.Core NuGet package in your ASP.NET Core application.
  4. To convert PDF to image, please use the Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows NuGet package in your ASP.NET Core application.

NOTE

If you want to migrate without any code changes from Syncfusion.Pdf.AspNet NuGet in application targeting .NET Framework, you can consider using anyone of the following packages:

Migrate System.Drawing.Common to SkiaSharp package

Starting from our volume 2, 2023 release, we have removed the System.Drawing.Common package as a dependency from our Syncfusion.Pdf.Imaging.Net.Core package. In its place, we have introduced SkiaSharp as the replacement library. This migration brings some API breaking changes that need to be considered:

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 Stream 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 Stream Return Type: Stream
ToImage(System.drawing.SizeF size) PdfQRBarcode Image ToImage(Syncfusion.drawing.SizeF size) Return Type: Stream
ToImage(this PdfBidimensionalBarcode barcode) PdfBarcodeExtension Image Stream 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 Stream 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[] Stream[] Return Type: Stream[]
ToImage() PdfUnidimensionalBarcode Image Stream 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