[xep-support] XEP Genarating pdfs take long time with .Net interface.

Krishnan, Navaneetha nkrishnan at matlensilver.com
Mon May 24 08:47:48 PDT 2004


Hi, Thanks a lot for you help. I appreciate it.

I am trying XEP - XSL Formatting Engine for Paged Media Developer Stamped Edition Version 3.7.4
COM Wrapper 1.5.

This is the complete source code for the asp file.

<%
	Dim XEP
    Set xep = server.CreateObject("XEP.XEPFormatter")
    xep.setOutputFormat ("PDF")
    XEP.SetStyleSheetFile Server.MapPath("AssetReportSVG.xsl")

	dt = now()
    objRet = XEP.Transform(GetXML())

    strFileName = Server.MapPath(".") & "\MLReport-" & formatdatetime(dt,1) & "-" & Replace(formatdatetime(dt,3), ":", "-") & ".pdf"

	SaveBinaryDataTextStream strFileName,objRet

	Response.write "Created PDF File : " & strFileName
	set xep = nothing


function GetXML()
	dim objDOC
	dim obj
	set objDOC = server.CreateObject("MSXML2.DOMDocument")
	objDoc.load Server.MapPath("AYA_input.xml")
	attachimage objdoc,"Image1",Server.MapPath("BB1-A.SVG")
	GetXML = Stream_StringToBinary(objdoc.xml,"")
end function



Private Sub AttachImage(Doc, ImageName, ImagePath )
    Dim objDom
    Dim objEl
    Dim objParEl
    Set objParEl = Doc.selectSingleNode("Images")
    If objParEl Is Nothing Then
        Set objParEl = Doc.createElement("Images")
        Doc.documentElement.appendChild objParEl
    End If
    Set objEl = Doc.selectSingleNode("Images/Image[@Name='" & ImageName & "']")
    If Not objEl Is Nothing Then
        Doc.documentElement.removeChild objEl
    End If
    Set objEl = Doc.createElement("Image")
    objEl.setAttribute "Name", ImageName
    Set objDoc = Server.CreateObject("MSXML2.DOMDocument")
    objDoc.Load ImagePath
    objEl.appendChild objDoc.documentElement
    objParEl.appendChild objEl
    Set objDoc = Nothing
End Sub


Function Stream_StringToBinary(Text, CharSet)
  Const adTypeText = 2
  Const adTypeBinary = 1

  'Create Stream object
  Dim BinaryStream 'As New Stream
  Set BinaryStream = CreateObject("ADODB.Stream")

  'Specify stream type - we want To save text/string data.
  BinaryStream.Type = adTypeText

  'Specify charset For the source text (unicode) data.
  If Len(CharSet) > 0 Then
    BinaryStream.CharSet = CharSet
  Else
    BinaryStream.CharSet = "us-ascii"
  End If

  'Open the stream And write text/string data To the object
  BinaryStream.Open
  BinaryStream.WriteText Text


  'Change stream type To binary
  BinaryStream.Position = 0
  BinaryStream.Type = adTypeBinary

  'Ignore first two bytes - sign of
  BinaryStream.Position = 0

  'Open the stream And get binary data from the object
  Stream_StringToBinary = BinaryStream.Read
  set BinaryStream = nothing
End Function


Function SaveBinaryDataTextStream(FileName, ByteArray)
  'Create FileSystemObject object
  Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")

  'Create text stream object
  Dim TextStream
  Set TextStream = FS.CreateTextFile(FileName)

  'Convert binary data To text And write them To the file
  TextStream.Write BinaryToString(ByteArray)
  TextStream.close
  set TextStream = nothing
  Set FS = nothing
End Function


Function BinaryToString(Binary)

  Dim cl1, cl2, cl3, pl1, pl2, pl3
  Dim L
  cl1 = 1
  cl2 = 1
  cl3 = 1
  L = LenB(Binary)

  Do While cl1<=L
    pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
    cl1 = cl1 + 1
    cl3 = cl3 + 1
    If cl3>300 Then
      pl2 = pl2 & pl3
      pl3 = ""
      cl3 = 1
      cl2 = cl2 + 1
      If cl2>200 Then
        pl1 = pl1 & pl2
        pl2 = ""
        cl2 = 1
      End If
    End If
  Loop
  BinaryToString = pl1 & pl2 & pl3
End Function

%>


The .Net version takes around 10 minutes to genearte a pdf of around 45KB size. That is why I am trying the asp com arapper way. If you think that I can improve the perfomance with the .Net version, I will go with that.

Details of error.
I am running this test on Windows XP professional. Pentium IV with 512MB ram.

It generates aroung 75 pdfs and after that I am getting "Error Encountered in COM surrogate process." Windows Errors.
Encountered unexpected error in dllhost. Cannot read memory at location XXXXX.

Thanks for you help.

Nav


-----Original Message-----
From: Alexander Peshkov [mailto:peshkov at renderx.com]
Sent: Monday, May 24, 2004 3:34 AM
To: Krishnan, Navaneetha
Cc: support at renderx.com
Subject: Re[2]: [xep-support] XEP Genarating pdfs take long time with
.Net interface.


Hello Nav,

I'm not an expert in ASP, but I knew that some of our clients
successfully use COM wrapper in their ASP projects for a long time.
Your problem still looks like a memory leak for me. Could it be that
your function SaveBinaryDataTextStream do not free some resources? Are
you using ASP.NET and latest version of XEP COM wrapper (1.5)?
Could you post complete code of your example?

Best regards,
Alexander Peshkov                             mailto:peshkov at renderx.com
RenderX

KN> Hi Alexander, 

KN> Thanks for your reply. I suspected that this could be a problem with .Net.

KN> So creted a simple asp page which creates pdf from xml and xsl. 

KN> When i tried to run it with WAS to load test it fails after few minutes. Initially it creates pdf for every three scond after 3 minutes it takes 15-20 secs and after a minute it throws the error.

KN> I have the code and the error message too. Any help will be appreciated.


KN> CODE : I did not include the code for function SaveBinaryDataTextStream 

KN>         Dim XEP
KN>     Set xep = CreateObject("XEP.XEPFormatter")
KN>     xep.setOutputFormat ("PDF")
KN>     XEP.SetStyleSheetFile Server.MapPath("AssetReport.xsl")

KN>         dt = now()
KN>     objRet = XEP.TransformFile(Server.MapPath("AYA_input.xml"))
KN>     strFileName = Server.MapPath(".") & "\MLReport-" & formatdatetime(dt,1) & "-" & Replace(formatdatetime(dt,3), ":", "-") & ".pdf"

KN>         SaveBinaryDataTextStream strFileName,objRet

KN>         Response.write "Created PDF File : " & strFileName
KN>         set xep = nothing

KN> ERROR:
KN> Error Type:
KN> method setStylesheetFile() in XEP.IXEPFormatter (0x80004005)
KN> Can't set stylesheet
KN> /xslfopetest/createXEPpdf.asp, line 5

KN> Thanks

KN> Nav



KN> -----Original Message-----
KN> From: Alexander Peshkov [mailto:peshkov at renderx.com]
KN> Sent: Friday, May 21, 2004 4:33 AM
KN> To: Krishnan, Navaneetha
KN> Subject: Re: [xep-support] XEP Genarating pdfs take long time with .Net
KN> interface.


KN> Hello Nav,

KN> As Nikolai has admitted in his recent post: http://xep.xattic.com/lists/xep-support/2045.html
KN> performance of XEP.Net is lower than of its Java counterpart, because
KN> of .Net version is a port of Java one it's efficiency is lower.
KN> As for the problems with COM wrapper - judging on the symptoms you
KN> describe it's a typical memory leak. We believe that our COM
KN> wrapper does not have such leaks itself (it was thoroughly tested in
KN> this respect) thus I suppose that the source of the problem may be in
KN> your code or it maybe a case of .Net-COM inter-operability issue. It
KN> definitely looks like XEP COM wrapper instances are not released by .Net.

KN> Best regards,
KN> Alexander Peshkov                             mailto:peshkov at renderx.com
KN> RenderX


KN>> Hi ,

KN>> Generating PDF with the .Net library takes a long time compared to the Java version.

KN>> If we use the COM library provided by XEP it is faster than the .Net version. But on a server it gets slower and slower and fails after a while saying cannot set stylesheet.

KN>> Any alternate or workaround to this problem.

KN>> Thanks in advance

KN>> -Nav



KN>> -------------------
KN>> (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
KN>> in the body of the message to majordomo at renderx.com from the address
KN>> you are subscribed from.
KN>> (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html


KN> -------------------
KN> (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
KN> in the body of the message to majordomo at renderx.com from the address
KN> you are subscribed from.
KN> (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

KN> -------------------
KN> (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
KN> in the body of the message to majordomo at renderx.com from the address
KN> you are subscribed from.
KN> (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html


-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo at renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo at renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html



More information about the Xep-support mailing list