• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

ASP and activePDF (or other PDF Conversion Engine)

Hello.

I'm working with an array of dynamic URLs that I'd like to pass to a PDF Conversion engine. The engine will then take each unique URL, and create a PDF with a unique filename.

I'm currently trying this with activePDF (www.activePDF.com) and having problems with the PDF engine. The 1st URL will render to a PDF, but then the script will timeout and not convert a 2nd URL.

If I try this with two static URLs, this same code works. The script just hangs when dynamic URLs are passed to the engine.

Anyone else have a similar problem or a possible solution for this type of issue? Thus far the vendor's website hasn't been much assistance.

Thanks,
J
0
brownmetals
Asked:
brownmetals
  • 6
  • 6
1 Solution
 
nschaferCommented:
I have no experience with activePDF, however I use a product ABCpdf ( www.websupergoo.com ) that is similar (and much less expensive).  You may wish to try it.  I have created a very simple example of converting a page to HTML on my site here:  http://www.applicationgroup.com/tutorials/asp/webtopdf.asp

Hope this helps,

Neal.
0
 
brownmetalsAuthor Commented:
Hi Neal.

Yes, I'm evaluating ABCpdf as well. I've found that when I use an array of URLs with ABCpdf, the file sizes get bigger with each iteration of the loop. In taking 10 URLs and converting them to PDF using an array, the file sizes started at 50KB and got as large as 445KB. When I did 18 URLs, the file size went as high as 800KB. It was really strange. The good thing about their engine is that it's been the fastest one I've tested. But, if file sizes are reaching 800KB for a document that should not exceed 50KB, that's a grave concern.

Do you convert multiple URLs in an array like this example here? If so, have you had issues with file sizes becoming larger as the loop iterates through?

Thanks,
J
0
 
nschaferCommented:
I generally am only creating one document at a time.  I would be concerned about looping through the creation process as you are mentioning not because of file size, which seems strange to me, but because of the possibility of a timeout it it takes too long to convert all of the URL's in the list.

Might I suggest, that you run the actual conversion process in a seperate page from the loop.  You loop could call the conversion process using the XMLHTTP object.

My guess is that you are creating the ABCpdf document only once, and then creating multiple documents.  I'm not sure about that, just guessing.  In any case if that is what you are doing and you don't want to split the creation process out to a seperate page then try closing and recreating the object.  This might resolve your problem.  Also, make suer you use the flatten method before you save your document.  This will reduce the size of the documents.

If you would like I could put together an example of looping through creating multiple documents using a seperate page to perform the conversion as I suggested above.

Neal.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
brownmetalsAuthor Commented:
Hi Neal.

Thanks for the feedback. I'm going to limit my users to only converting about 5 to 10 documents at a time (need to do more system tests before I decided). There will definitely be a finite number of documents they can convert.

I'm going to try your suggestion of recreating the object within the loop each time to see if that helps. Could you provide a code snippet of the "Flatten" method? That would be helpful.

Thanks,
J
0
 
nschaferCommented:
Sure.

Here's the code from the example on my site.

<html>
<head>
<title>Web to PDF</title>
</head>
<body>
<!-- This section displays the heading -->
<%
vPage = request.form("pg")
if ucase(left(vPage,7)) <> "HTTP://" then
    vPage = "http://" & vPage
end if
%>
<table border=0 width="95%">
<tr>
<td><b><font size=5>Convert web page to PDF</font></b></td>
<%
if request.form("pg") <> "" then
    %>
    <td><%=vPage%></td>
    <td><input type=button value='Go Back' onclick='window.history.go(-1)'></td>
    <%
end if
%>
<td><input type=button value='See Code' onclick='window.open("webtopdf_source.htm")'></td>
</tr>
</table>
<hr>
<%
if request.form("pg") = "" then
    ' This section displays the form
    %>
    <form name=form1 method=post>
    <center>
    Page URL to convert: <input type=text name="pg" size=75>
    <input type=submit value='Submit'>
    </center>
    </form>
    <%
else
    ' This section creates the PDF and displays it in an IFrame
    Set theDoc = Server.CreateObject("ABCpdf4.Doc")
    theDoc.Rect.Inset 15, 15
    theID = theDoc.AddImageUrl(vPage, TRUE, 0, False)
    ' Add a pages as required
    Do
        theDoc.FrameRect
        If theDoc.GetInfo(theID, "Truncated") <> "1" Then Exit Do
        theDoc.Page = theDoc.AddPage()
        theID = theDoc.AddImageToChain(theID)
    Loop
    'Flatten the pages (This reduces size of the generated PDF)
    For i = 1 To theDoc.PageCount
        theDoc.PageNumber = i
        theDoc.Flatten
    Next
    ' Save the PDF File
    vPath = server.mappath("\") & "\asp\pdfs\htmlimage.pdf"
    theDoc.Save(vPath)
    set theDoc = Nothing
    'Display the PDF File
    response.write("<iframe name='I1' width=100% height=500 src='.\pdfs\htmlimage.pdf'>")
end if
%>
</body>
</html>
 

0
 
brownmetalsAuthor Commented:
Thanks, Neal.

That's very helpful. I was noticing that before you call the AddImageURL method, you specify:

theDoc.Rect.Inset 15, 15

Does that specify page margins in your final PDF? That's one thing I've been looking for and have not been able to figure out yet - how to specify the page margins and NOT to print any background colors in table cells.

If you could help me out with that, that would be great.

Thanks,
J
0
 
nschaferCommented:
Yes, that is exaclty right.  I don't really remember what the units are at this point.  I could look it up I suppose, but I found that this was a nice value for converting web pages to pdf.

By the way, I created code to split the processing out to a different page it it doesn't really help with timouts, so you can ignore the comment I made about that .  The pages I generated though are not getting larger as it continues, so I think that closing the ojbect and re-recreating it is probably the answer.

Neal.
0
 
brownmetalsAuthor Commented:
Hi Neal.

I did some testing based on your suggestions and wanted to share the results with you.

• Object created outside the loop and using the Flatten method - files ranged from 50 to 137KB, larger with each iteration

• Object created inside the loop without using the Flatten method - files were between 50 and 54KB.

• Object created within the loop and using the Flatten method - files were about 18KB each!!! Awesome!!

Sometimes it just takes someone else to talk you through programming to realize what's happening in your program.

I'm going to worth with the margins now and see how that comes out. Thanks again for your help.

J
0
 
brownmetalsAuthor Commented:
Off the top of your head, do you remember what the Method might be for telling ABCpdf NOT to print the background colors of a table when converting HTML to PDF?
0
 
nschaferCommented:
I'm afraid I don't know of a method for that.   I'm still running version 4, haven't got around to installing ver 5 yet although I've had the license for quite some time.  Don't fix what isn't broke :)  So possible in version 5 there is an option for that, or possible just one I don't know in the version I'm using.  You might try tech support.  I found them to be very helpful when I was first starting with the product.

The test results are very interesting.  I still don't really know why the output file would keep growing when creating outside the loop.  I'm guessing that not all of the resources are cleared properly at the end of the loop.

Neal.
0
 
brownmetalsAuthor Commented:
Hi Neal.

Yeah, it was strange, but I agree with you - I think the object still contained something in it that would allow each progressive iteration to create larger files. I have a call into their tech support department about the table background color. I still haven't found that method in the documentation.

Thanks again for your input. With your suggestions, I was able to make a lot of progress on this project.

J
0
 
nschaferCommented:
Glad I could Help.

Neal.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now