We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose support for Silverlight 4

Hi @

I am developing an application with VS 2010 Silverlight 4.0...

I have a requirement where I have to generate Word docs, Excels, PDF's....

I can achieve all this if this for a normal Web application and if it was not a silverlight application.

Since this is a Silverlighht based application I am unable to use Aspose.

When I am trying to add any Aspose reference to Silverlight project then it is not allowing to add the reference.

Please let me know the support of Aspose for Silverlight based projects.

Please provide some helpful link.

Thanks in advance.

Hi Aneesh,

Thank you for your interest in Aspose.Words.

Unfortunately, at the moment there is no special version of Aspose.Words for Silverlight. We are planning to create a special version of Aspose.Words for Silverlight sometime in the near future. Silverlight does not have .NET GDI+ which is currently required by Aspose.Words. In the next release of Aspose.Words (10.0) these dependencies on the GDI class will be removed to facilitate porting of .NET code to the Java platform. This will open the doors to more easily developing a version for Silverlight.

Your request has been linked to the appropriate issue and you will be notified as soon as this feature is supported.

Please note, if it is appropriate for you for the time being, Aspose.Words does support converting to XPS format, which can be easily used in Silverlight for document preview. Please see the following documentation article for more information: http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/display-word-documents-in-silverlight.html.

Thanks,

Hello,

I have been experimenting with running Aspose.Words and PDF.Kit on the server side in Silverlight 4 using a WCF service. The service does some data merging with .docx files and then converts them to PDF format. The results have been generally good. I say generally because applying the license file has been tricky -- sometimes it works and sometimes it throws a null reference exception. So far there is no pattern I can detect. When it works the results of the merge and PDF output are very good. I believe that once the licence business is working that this will be a good solution.

Give this a try and if you need some code snippets let me know. Good luck.

Randy

Hi Randy,

Thanks for this additonal information.

Yes please attach your code here and we will look into what could be causing the problem you are having.

Please note that Aspose.Words has it's own built in direct rendering process. Please see here for details. The old method of PDF rendering was removed from the most recent versions.

Thanks,

Hi Adam,

Thanks for responding. My code is below. I have studied the documentation and forums, and the error appears to be coming from calling the setlicense method multiple times; perhaps two calls are occurring simultaneously. One suggestion was to call SetLicence in the application startup, but I haven't figured out how to do that on the server side in Silverlight. My current solution is to call SetLicence each time the service is used, immediately destroying the Words.License object afterwards. This generally works, but not always.

Thanks for any suggestions.

Randy

<OperationContract()>

Public Sub CreateMergeDoc(ByVal sTemplateFileName As String, ByVal sOutputFileName As String, ByVal sCustFolder As String, ByVal asTag() As String, ByVal asData() As String)

Dim nCounter As Integer = 0

Dim sProc As String = "AsposeMergeService.CreateMergeDoc"

Dim oInputDoc As Document

Try

Dim oWordsLic As New Aspose.Words.License()

oWordsLic.SetLicense("Aspose.Words.lic")

oWordsLic = Nothing

Dim sInputFolder As String = HttpContext.Current.Server.MapPath(scFOLDER_DOCTEMPLATE)

Dim sOutputFolder As String = HttpContext.Current.Server.MapPath(scFOLDER_DOCOUTPUT & "\" & sCustFolder)

Dim sInputPath As String = sInputFolder & "\" & sTemplateFileName & ".docx"

Dim sOutputPath As String = sOutputFolder & "\" & sOutputFileName & ".docx"

If Not System.IO.Directory.Exists(sOutputFolder) Then

System.IO.Directory.CreateDirectory(sOutputFolder)

End If

'--- replace tags with data

oInputDoc = New Document(sInputPath)

With oInputDoc

Dim oRange As Range = oInputDoc.Range

Dim nTest As Integer

For nCounter = 0 To UBound(asTag)

nTest = oRange.Replace(asTag(nCounter), asData(nCounter), False, False)

Next

'--- do it again, to handle conditional/merge data in the conditional text

For nCounter = 0 To UBound(asTag)

nTest = oRange.Replace(asTag(nCounter), asData(nCounter), False, False)

Next

End With

oInputDoc.Save(sOutputPath, SaveFormat.Docx)

Catch ex As Exception

Debug.WriteLine(sProc & " Error at Counter= " & nCounter.ToString & ", FieldName= " & asTag(nCounter) & " Data= " & asData(nCounter))

Debug.WriteLine(sProc & " Message= " & ex.Message)

Finally

oInputDoc = Nothing

End Try

End Sub

Hi Adam,

I believe that I have the licensing problem figured out. I created a separate web service just to do the licensing, and make a call to that before starting the document manipulations...

Randy

Hi Randy,

It's great you found the solution. If you have any further troubles please feel free to ask and we will assist.

Thanks,