I have a word doc that i created using RadFlowDocument and i want to convert this to a pdf. i have tried couple of ways and it never worked.
'Exporting the Rad Document to Word Document
Using output As Stream = File.OpenWrite(directoryPath + "FlexFab.docx")
Dim provider As DocxFormatProvider = New DocxFormatProvider()
'Convert word to PDF
Dim fileFormatProvider As IFormatProvider(Of RadFlowDocument) = New DocxFormatProvider()
Using input As FileStream = New FileStream(filePath, FileMode.Open)
document = fileFormatProvider.Import(input)
fileFormatProvider = New PdfFormatProvider()
Using output2 As Stream = New FileStream(directoryPath + "FlexFab.pdf", FileMode.OpenOrCreate)
The Error that i am getting is :
Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider' to type 'Telerik.Windows.Documents.Common.FormatProviders.IFormatProvider`1[Telerik.Windows.Documents.Flow.Model.RadFlowDocument]'.
I also tried the below method and that dosent work either, is there a way i can achieve this.
Dim document As RadFlowDocument = CreateRadFlowDocument
Dim provider Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
Dim fixedDocument As RadFixedDocument = provider.ExportToFixedDocument(document);
13 Answers, 1 is accepted
The reason for such a behavior might be the usage of improper namespaces. When you are exporting a RadFlowDocument (DOCX, RTF, HTML or plain text) you will need to use RadWordsProcessing`s PdfFormatProvider with its reference to Telerik.Windows.Documents.Flow.FormatProviders.Pdf.dll. Can you please verify the required assemblies are referenced in the project and the correct imports are added?. The Using PdfFormatProvider topic lists the prerequisites for using the export to PDF functionality.
Additionally, you might find helpful to check the examples in our SDK repository which show several usages of the library.
I hope this helps. Please, let me know if there is anything else I can assist you with.
Yes i did try using the correct namespace and this is what happens every time i import the dll.
looks like the dll file dose not have the pdf library in it. Attaching the screenshot
What I am assuming is that still there is a mismatch in the references. For better analysis of this behavior, could I ask you to send us a screenshot of the DLLs referenced in the project? I verified the case and everything seems to be working as expected on our side.
Everything seems fine, except that in the provided screenshot I didn't see Telerik.Windows.Documents.Flow.FormatProviders.Pdf.dll. This should be the reason for the messages of the missing library. Please, make sure to include the missing reference to your project and let me know if you are still experiencing issues.
Can you tell me how to do that? How can i add the missing reference to my project?
First thing you will need to do is to install the Telerik bundles which includes the Telerik Document Processing. After creating a project in Visual Studio in Solution Explorer window right-click on the References and search for required DLL in the Assemblies >> Extensions (see AddReferenceScreenshot). Find Telerik.Windows.Documents.Flow.FormatProviders.Pdf (or any other Document Processing DLL), select it and click OK (see ReferenceManagerScreenshot). The assembly should now appear in your references.
I have been doing that from the beginning, the problem here is i dont see the Telerik.Windows.Documents.Flow.FormatProviders.Pdf within the Telerik.Windows.Documents.Flow.FormatProviders.
It is missing, i also checked the DLL file in the bin folder and it dose not have it either, see the screenshot i have attached here, also refer to other screenshots i have attached in this conversation.
The first thing I would like to point out to your attention is that the Telerik.Windows.Documents.Flow.FormatProviders.Pdf is not part of the Telerik.Windows.Documents.Flow.FormatProviders namespace, but it is a separate assembly, which must be referenced from the project’s references.
A possible solution of the case could be firstly in the Project Designer to click the References tab (as I saw from the screenshot you already did), then click on the Add button (screenshot1). Next, you will need to search and add the required DLL in the Assemblies >> Extensions (screenshot2). If you found the missing DLL, you could see it now in the project References (screenshot3 & screenshot4). For more information please check How to: Add or remove imported namespaces and Manage references in a project help topics.
I was thinking that Telerik.Windows.Documents.Flow.FormatProviders.Pdf is part of the Telerik.Windows.Documents.Flow.FormatProviders namespace. Thank you very much for being very patient with me through out the conversation. I did try what u said and it works now.
Thank You again.