Hi,
Is there a way to change the “temp” folder? Or handle the conversion in memory, rather than saving to disk?
I’m using ASP.NET WebForms, VB.NET. I just want to read an Illustrator file (.AI) and display it in the browser.
Thanks,
Mike
This is my code-behind:
Private Sub IllustratorTest2_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim strTestFile As String = "D:\Data\AI_TEST\test.ai"
Using viewer As New Viewer(strTestFile)
Dim viewOptions As New PngViewOptions()
viewer.View(viewOptions)
End Using
End Sub
Do I need to put a control on the aspx page, or will it just render into the page automatically?
I tried looking at your WebForms sample, but I couldn’t figure out how it worked. I was hoping for a simple example.
Thanks,
Mike
@msatkevich
Sure, you can decide how to handle the conversion by implementing IPageStreamFactory
as it shown in the code snippet:
Imports System.IO
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Interfaces
Imports GroupDocs.Viewer.Options
Module Module1
Sub Main()
Dim strTestFile = "D:\Data\AI_TEST\test.ai"
Dim pageStream = New MemoryStream()
Dim streamFactory = New MemoryPageStreamFactory(pageStream)
Using viewer As New Viewer(strTestFile)
Dim viewOptions As New PngViewOptions(streamFactory)
viewer.View(viewOptions)
End Using
'Return pageStream
End Sub
End Module
Friend Class MemoryPageStreamFactory
Implements IPageStreamFactory
Private ReadOnly _memoryStream As MemoryStream
Public Sub New(memoryStream As MemoryStream)
_memoryStream = memoryStream
End Sub
Public Function CreatePageStream(pageNumber As Integer) As Stream Implements IPageStreamFactory.CreatePageStream
Return _memoryStream
End Function
Public Sub ReleasePageStream(pageNumber As Integer, pageStream As Stream) Implements IPageStreamFactory.ReleasePageStream
'Do not dispose page stream here
End Sub
End Class
Please let us know if it works for you.
Hi,
When I try the code below, the page takes a very long time to load.
And after the page loads, it’s just a small white square on a black background.
Can you tell me if what I have is incorrect?
Thanks,
Mike
Imports System.IO
Imports GroupDocs
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Interfaces
Imports GroupDocs.Viewer.Options
Partial Class Tech_IllustratorTest2
Inherits System.Web.UI.Page
Private Sub Tech_IllustratorTest2_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim strTestFile As String = "D:\Data\AI_TEST\my_file.ai"
Dim pageStream = New MemoryStream()
Dim streamFactory = New MemoryPageStreamFactory(pageStream)
Using viewer As New Viewer(strTestFile)
Dim viewOptions As New PngViewOptions(streamFactory)
viewOptions.Width = 400
' use width Or height To keep proportions
'viewOptions.Height = 300
viewer.View(viewOptions)
Response.Clear()
Context.Response.ContentType = "image/png"
pageStream.CopyTo(Context.Response.OutputStream)
End Using
End Sub
End Class
Friend Class MemoryPageStreamFactory
Implements IPageStreamFactory
Private ReadOnly _memoryStream As MemoryStream
Public Sub New(memoryStream As MemoryStream)
_memoryStream = memoryStream
End Sub
Public Function CreatePageStream(pageNumber As Integer) As Stream Implements
IPageStreamFactory.CreatePageStream
Return _memoryStream
End Function
Public Sub ReleasePageStream(pageNumber As Integer, pageStream As Stream) Implements
IPageStreamFactory.ReleasePageStream
'Do not dispose page stream here
End Sub
End Class
@msatkevich
Please attach the file you’re trying to render we’ll try to reproduce it at our side.
Hi,
Can I attach the file to this e-mail address? The file is somewhat confidential – I’d rather not post to the forum.
Thanks,
Mike
image001.jpg (169 Bytes)
@msatkevich
I’m sorry for the delayed response. I’ve created the private topic AI rendering is slow and output is a white square for this issue. Let’s continue there.