Prince XML seems like a great product! But I am having difficulty getting one important feature to work. I would like to take a string of XHTML with an embedded stylesheet, convert it to a stream, pass the stream to Prince, and retrieve a stream for the PDF content.
The overloaded version of the Convert method that accepts a System.IO.Stream as input and returns a System.IO.Stream as output seems like it will do exactly what I need. However, when trying to call this method the log file lists the following error:
Wed Aug 29 20:24:54 2007: ---- begin
Wed Aug 29 20:24:54 2007: -: error: could not load input file
Wed Aug 29 20:24:54 2007: error: no input documents to process
Wed Aug 29 20:24:54 2007: finished: failure
Wed Aug 29 20:24:54 2007: ---- end
Maybe I am setting up the code incorrectly? Any guidance would be appreciated. I am using the following VB.NET code:
The overloaded version of the Convert method that accepts a System.IO.Stream as input and returns a System.IO.Stream as output seems like it will do exactly what I need. However, when trying to call this method the log file lists the following error:
Wed Aug 29 20:24:54 2007: ---- begin
Wed Aug 29 20:24:54 2007: -: error: could not load input file
Wed Aug 29 20:24:54 2007: error: no input documents to process
Wed Aug 29 20:24:54 2007: finished: failure
Wed Aug 29 20:24:54 2007: ---- end
Maybe I am setting up the code incorrectly? Any guidance would be appreciated. I am using the following VB.NET code:
Dim oPrince As New Prince("C:\Program Files\Prince\Engine\bin\prince.exe")
Using oInStream As System.IO.Stream = New System.IO.MemoryStream
' Create a byte array from the XHTML string
' and write it to the input memory stream.
Dim enc As New UTF8Encoding
Dim arrBytData() As Byte = enc.GetBytes(sXHTML)
oInStream.Write(arrBytData, 0, arrBytData.Length)
' Create an output memory stream for the PDF output.
Using oOutStream As System.IO.Stream = New System.IO.MemoryStream
oPrince.SetHTML(True)
oPrince.SetLog("c:\inetpub\http\pdf\" & PDFName & ".log")
If Not oPrince.Convert(oInStream, oOutStream) Then
Throw New Exception("There was an error creating the PDF.")
End If
oOutStream.Close()
End Using
oInStream.Close()
End Using