Problems with Aspose.Words running on server

Received : 2007/12/13 14:17:42
Message : Hi, I have problems with Aspose.Words running on server.
Here is my code:
=============================================
Sub DoWord(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strValue As String strValue = "

Some Text

"
Dim doc As Document = New Document()
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
builder.InsertHtml(strValue)
doc.Save(“test.doc”, SaveFormat.Doc, SaveType.OpenInBrowser, Response)
End Sub
=============================================
If I press the button to generate the word file I get the error message that I could not download the file. The internetsite could not be opened. It is either not available or could not be found.
What did I wrong?
On localhost it works fine!!
Thanks for an answer.
Kindly regards, Andreas (from Germany)

This message was posted using Aspose.Live 2 Forum

Hi

Thanks for your request. Your code is correct and it should work fine. Maybe problem is in security settings. Can you download anything from this site? You can try using the following code for testing.

Dim bytes As Byte() = System.IO.File.ReadAllBytes(Server.MapPath(“test.doc”))

Response.Clear()

'Specify the document type.

Response.ContentType = “application/msword”

'Other options:

'Response.ContentType = “text/plain”

'Response.ContentType = “text/html”

'Specify how the document is sent to the browser.

Response.AddHeader(“content-disposition”, “attachment; filename=test.doc”)

'Another option could be:

'Response.AddHeader “content-disposition”,“inline; filename=MyDocument.doc”;

'Get data bytes from the stream and send it to the response.

Response.BinaryWrite(bytes)

Response.End()

Best regards.

Hi,

thanks for the answer. I bind the aspose word component in an user control (ascx). I tried to inherit it in a normal aspx site and now it works!! Thanks for the help.

But now I have a problem with the aspose pdf component. And again it works on localhost machine but not running on web server. The code line “doc.Save(stream, SaveFormat.AsposePdf)” causes the general error page of .NET.

Here is the code:

Sub CreatePDFFile()

Dim doc As Document = New Document()

Dim builder As DocumentBuilder = New DocumentBuilder(doc)

builder.InsertHtml("…some html code…")

Dim stream As MemoryStream = New MemoryStream()

‘========!!! here is the code broken:

doc.Save(stream, SaveFormat.AsposePdf)

stream.Seek(0, SeekOrigin.Begin)

Dim xmlDoc As XmlDocument = New XmlDocument()

xmlDoc.Load(stream)

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()

pdf.BindXML(xmlDoc, Nothing)

pdf.IsTruetypeFontMapCached = True

pdf.TruetypeFontMapPath = System.IO.Path.GetTempPath()

pdf.Save(“Aspose.Word.Demo.pdf”, Aspose.Pdf.SaveType.OpenInAcrobat, Response)

End Sub

I gave writing rights to the folder in which is the site with the pdf component. Is it possible that there’s full trust necessary? Our web hoster only offers medium trust level.

Thanks for an answer.

Andreas (Germany)

Hi

Does this problem occur only if you use SaveFormat.AsposePdf? I can’t reproduce this on my side. Also provide me error details.

Best regards.

Hi,

here is the error message:

Fehler bei der Anforderung des Berechtigungstyps

(on english: error by request of a type of authorization)

System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.

Thanks for an answer.

Kindly regards, Andreas

Hi

Thanks for additional information. I think that this is a security issue.

Best regards.