New to Telerik Document Processing? Download free 30-day trial

Resolving Compiler Ambiguous Reference Error CS0104 with PdfFormatProvider

Environment

Version Product Author
2023.3.1106 RadPdfProcessing Desislava Yordanova

Description

When using the PdfFormatProvider in your project, you may encounter one of the following Compiler Error CS0104 messages during the application build:

  • 'PdfFormatProvider' is an ambiguous reference between 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider' and 'Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider'

  • 'PdfFormatProvider' is an ambiguous reference between 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider' and 'Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider'

Usually, such an error may occur when the following using statements are imported:

using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using Telerik.Windows.Documents.Flow.FormatProviders.Pdf;
using Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf;

PdfFormatProvider provider = PdfFormatProvider();

Solution

Telerik Document Processing Libraries offer PdfFormatProvider which makes it easy to import/export a RadFixedDocument from/to PDF format, preserving the entire document structure and formatting. It is available for:

  • RadWordsProcessing: The PdfFormatProvider class of RadWordsProcessing is located in the Telerik.Windows.Documents.Flow.FormatProviders.Pdf namespace. RadFlowDocument supports only the export option to PDF format. Importing a PDF document to RadFlowDocument is not supported.

  • RadSpreadProcessing: The PdfFormatProvider class of RadSpreadProcessing is located in the Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf namespace. The Workbook supports only the export to PDF format. Importing a PDF document to Workbook is not supported.

  • RadPdfProcessing: The PdfFormatProvider class of RadPdfProcessing is located in the Telerik.Windows.Documents.Fixed.FormatProviders.Pdf namespace.

Explicitly specify the namespace when declaring the PdfFormatProvider object based on your specific requirement:

  • If you are working with RadSpreadProcessing, use the following namespace:
 Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
  • If you are working with RadWordsProcessing, use the following namespace:
  Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
  • If you are working with RadPdfProcessing, use the following namespace:
  Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();

By explicitly specifying the namespace, you ensure that the correct PdfFormatProvider is used and avoid ambiguous reference errors.

See Also

In this article