Forum How do I...?

Frustrating ASP issue

psmealey
I suspect that I'm incredibly dense, but I still haven't gotten through my delay issues with respect to getting pdf's out of Prince with ASP.net.

I have confirmed that using the command line on my server is a snap, and generates complex PDFs in seconds, but when I try to run it as a part of my application, it appears to stop short of consuming the source page or its css file.

There's something strange in the way it access web addresses with the full session id's embedded in the URL (due to a number of issues at my client, I have to run the app in a Cookieless state). At any rate, here are what my params look like:

Dim p As Prince = New Prince(PrincePath)
p.ClearStyleSheets()
p.AddStyleSheet(myCssPath1)
p.AddStyleSheet(myCSSPath2)
p.SetLog(myLogPath)
p.SetHTML(True)
p.SetCompress(True)

p.convert(myWebPage, myOutputPDF)

My inputs resemble the following:

myWebPage = "http://www.domain.com:52076/appdir/(S(jxduz52kwutel555ur1e4h55))/Review.aspx"
myOutputPDF = D:\WebMasterSandbox\APPNAME\ShareName\PdfActivity\2010_12022022_ jxduz52kwutel555ur1e4h55.pdf

The value I'm trying to get to in my landing page is what I'm calling

myPDFUri = "http://www.domain.com:52076/appdir/((S(jxduz52kwutel555ur1e4h55))/PdfActivity/2010_12022022_ jxduz52kwutel555ur1e4h55.pdf

The server recognizes the Prince.exe location at
"http://www.domain.com:52076/appdir/(S(jxduz52kwutel555ur1e4h55))/Prince/bin/Prince.exe"

When I run in this manner, the browser looks as if it's loading my aspx page, but my debug efforts reveal that it's doing nothing. And if I cancel the process, the ui will inform me (a few minutes later, after I've already forgotten about it) that my pdf is ready, and so it is.

Totally confounding. Can you offer any help?
mikeday
There are a couple of things I don't understand here. Firstly, what is the prince.exe file doing in a HTTP URL? You don't need to access it over the web, do you? What is the value of PrincePath? Secondly, which aspx page are you going to that takes a long time? Is it supposed to generate the PDF and then redirect to the URL of the PDF file?
psmealey
Thanks again for your timely response, Mike.

Prince doesn't need to be accessed over the web in this case, but via a corporate intranet. To explain, my client has requested that I build a limited use ASP-based solution for their sales people to access the app from their corpnet, generate a one-page report, and create a PDF version of that report at the touch of a button. The PDF could then either be streamed to the browser or downloadable via the server (or even emailed , if that made sense). The method of transmittal doesn't really matter from a requirements perspective, really I was looking for the most graceful way to implement it from a user perspective.

Was Prince not architected to envision such a scenario, or have I got it completely wrong in terms of how Prince needs to be deployed to fit into this workflow.

So to recap, the principal use case: client logs into the solution, hits the IIS server on a file share, puts in a handful of inputs, solution queries the SQL data mart, and data is returned to the browser via aspx page where it is rendered in tables and pie charts (via a 3rd party app provider named Nevron). User is satisfied and then sends the URL to prince to wrap the data in a PDF.

To be sure, I know there are much, much easier ways to do this, but the client has zero confidence in its sales people to be able to execute such a work flow manually and print from the browser to a pdf printer driver.

Thanks again for the help.
psmealey
Sorry, missed one of your questions... the value of PrincePath is the physical path to where the exe is located, in this case: D:\APPName\DirName\Prince\bin\prince.exe
mikeday
Okay, this kind of use case should be no problem for Prince at all. And if you run Prince by hand on the report URL, you say it works fast, no problems. So the only question concerns this part "User is satisfied and then sends the URL to prince to wrap the data in a PDF." So the user has viewed the report as HTML at a certain URL, eg. http://example.com/report.aspx. Now, how do they trigger the printing of the PDF? Do they go to a different URL, like http://example.com/print.aspx, and that page calls Prince?
psmealey
Up to this point, I had been using a button click in an AJAX modal popup to kick off the Prince conversion method, but the way you have posited it below (user previews report on Review.aspx and then goes to Print.aspx) is more along the lines of what I was thinking.
mikeday
Right. This is getting into deep ASP waters where we have less experience; anything that happens before Prince is even called is difficult for us to diagnose remotely.
psmealey
Understood. In general, would it make sense for me to write the ASPX output to html before feeding it to Prince, or does Prince not care whether the form comes in asp.net or html?
mikeday
Prince only processes HTML input, it doesn't execute ASP code itself.
psmealey
It's funny... I have tried multiple techniques of passing the ASP URL to the prince.exe (directly, translating into an HTML stream, an HTML doc, translating it into an XHTML with SgmlReader, likewise an XHTML stream), I just cannot get it to run. But, when I browse to the ASP page, manually save it as an HTML doc to my computer, and run that file through the same process I have written for the web site, it goes through without a problem.

It's still hard for me to get at, but it seems to have something to do with the length or structure of the URL (it's encoded with session information). Even when I try to programmatically write the .aspx file using a HTTPTextWriter, the Httpresponse method hangs.

Thanks again for your help, not sure where next to turn, but at least I've ruled out that the issue has anything to do with Prince.
mikeday
Sounds like a deadlock problem. Are you trying to access an ASP page, from within another ASP page? That will require the ASP code to be re-entrant, which may not work.