0

Hi guys,

I've just managed to get 99% of a script running for my website. I am creating a system where a user can create an invoice using our billing system, and then download it via PDF.

I am using Persists PDF module and I have got it all working. However, there is just one thing I am unable to figure out. I can't seem to repeat a particular part of the string used by the PDF module. I am using dynamic data successfully to populate the data created in the PDF, but my repeat region refuses to repeat my row in the table.

The first row is shown fine in the PDF, but the subsequent rows fail to show.

My code currently looks like this:

...last part of my string"
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT Products.EOF))
%>
<% Body2 = "<tr><td width=""80%"" class=""PicBorder""><div align=""left"" class=""BodyTextSmaller"">" & Products("Name").Value & " - " & Products("BillingCycle").Value & "</div></td><td width=""20%"" class=""PicBorder""><div align=""left"" class=""BodyTextSmaller"">&pound;" & Products("ProductCost").Value & "</div></td></tr>" 
%>
<%
Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Products.MoveNext()
  Wend 
%>
<%
Doc.ImportFromUrl Body & Body2 + "...last part of my final section of my string

I am using ASP VB and MySQL 4 databases. As I said, I have figured out everything on my own so far, but this one has me stumped!

Thanks in advance,
Adam

Edited by spence89: n/a

4
Contributors
28
Replies
30
Views
6 Years
Discussion Span
Last Post by spence89
0

At what stage is the PDF created? Wouldn't it be better to complete the construction of the invoice data and then send to PDF?

0

Hi there,

Thanks for your reply, but the code does contruct the data first, and then sends it to the PDF create command. The trouble is, I have to break up the string in order to get the repeat region code to work.

Regards,
Adam

0

Hi AS,

The code is normally used to displays the rows in a table, based on the criterea of the recordset. The code usually works when used in normal conditions but not when already in a ASP script that uses a string.

Any ideas? Many thanks.

0

Line 9-12 are unnecessarily complicated. Better to use a simple row return. No increment or count is required...

if not rsProduct.EOF then
   response.write" Your row stuff"
end if
0

Hi AS,

Thanks for your help.

As far as I know the code you suggested wouldn't repeat the rows in the table one after another would it?

The code I'm using is a repeat region, and I want the code to display multiple rows that are based from the criterea in the recordset.

Do we have our wires crossed somewhere? I do appreciate the help though :)

0

It will return every row that meets the criteria. For example...

response.write"<table>"

SQLAuthor = "SELECT * FROM Users Order By ID ASC "
Set rsAuthor = dbConnection.Execute(SQLAuthor)	
if NOT rsAuthor.EOF then

response.write"<tr>"
response.write"<td>" & rsAuthor("ID").value & "</td>"
response.write"<td>" & rsAuthor("Author").value & "</td>"
response.write"<td>" & rsAuthor("Firstname").value & "</td>"
response.write"<td>" & rsAuthor("Lastname").value & "</td>"
response.write"<td>" & rsAuthor("Active").value & "</td>"
response.write"</tr>"

end if
rsAuthor.Close
Set rsAuthor = Nothing

response.write"</table>"

The above example will return a table row for every author in the database.

Edited by ArtistScope: missing code

0

Hi AS,

Would that interfere with the string? The data I have is a string and cannot be broken. That's the trouble with it you see because the whole HTML is a string, the ASP also needs to be put into the string which is causing me problems. If this was a normal page I wouldn't need to ask for help hehe.

I'm trying to get working the ASP PDF component and got everything working dynamically apart from the repeat region.

Many thanks,
Adam

0

This is not a string...

While ((Repeat1__numRows <> 0) AND (NOT Products.EOF))....

But it is a lot of unnecessary code that can be replaced using the simple example that I gave.

Try it.

0

Hi AS,

I tried the code you suggested, but I didn't specify the recordset becuase that has already been done above.

Once I updated the code with your code, no rows appear at all. I now have this code below:

height=""30"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><strong>Amount</strong></div></td></tr>"

While ((Repeat1__numRows <> 0) AND (NOT Products.EOF))

If NOT Products.EOF then

Response.write"<tr>"
Response.write"<td width=""80%"" class=""PicBorder"">"
Response.Write"<div align=""left"" class=""BodyTextSmall"">" & Products.Fields.Item("MoreInfo").Value & " - " & Products.Fields.Item("BillingCycle").Value & "</div>"
Response.write"</td>"
Response.write"<td width=""20%"" class=""PicBorder"">"
Response.write"<div align=""left"" class=""BodyTextSmall"">&pound;" & Products.Fields.Item("ProductCost").Value & "</div>"
Response.write"</td>"
Response.write"</tr>"

end if
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Products.MoveNext()
Wend 

Doc.ImportFromUrl Body & Body2 + "</table><img src=""http://www.silverlinewe

Any ideas? Have I done something wrong?

Edited by spence89: n/a

0

Hi,

This is the code I have now. As I said I do not need the code for the recordset as it has already been defined above the code.

</div></td></tr>"

If NOT Products.EOF then

Response.write"<tr>"
Response.write"<td width=""80%"" class=""PicBorder"">"
Response.Write"<div align=""left"" class=""BodyTextSmall"">" & Products.Fields.Item("MoreInfo").Value & " - " & Products.Fields.Item("BillingCycle").Value & "</div>"
Response.write"</td>"
Response.write"<td width=""20%"" class=""PicBorder"">"
Response.write"<div align=""left"" class=""BodyTextSmall"">&pound;" & Products.Fields.Item("ProductCost").Value & "</div>"
Response.write"</td>"
Response.write"</tr>"

end if

Doc.ImportFromUrl Body + "</table>

I appreciate your help.

Edited by spence89: n/a

0

how i can do for you, but 顶……

Sorry?

Your post makes no sense.

0

Hi,

Does any one have a solution? I am still searching for a way to get this working. Will no one else help me? Any suggestions, please?

Regards,
Adam

0

Hi,

Does any one have a solution? I am still searching for a way to get this working. Will no one else help me? Any suggestions, please?

Regards,
Adam

0

If this problem is no longer related to the original post (create PDF from data and save to disk, then send email with PDF attached), can you redefine the problem in detail.

0

ArtistScope,

The problem I am having still stands. I am unable to repeat the rows in my recordset when creating a PDF document. The PDF document is dynamically populated, and then sent to the browser for download. The PDF is properly formatted how I want it to be, and all data is correctly created, however, the repeat region is not working properly and if multiple rows are found for the criteria then only one row is generated, thus ignoring the rest.

See my previous replies for the details on this problem. Simply put, everything is working apart from the fact that only one row is printed on the PDF, rather than 3 or 4 if required.

Am I making sense? I do appreciate all the help.

Kind Regards,
Adam

0

Apparently you are creating a PDF (1) and sending by email (2) and making it available for download (3)?

It may help you to clarify things by keeping these operations separate:

1. Create the PDF and save to disk using a unique name (invoice number?).
2. Send the email with the PDF as an attachment.
3. Provide a download link on the page pointing to the PDF.

Starting with step 1, why do you need to use a repeat region?

0

Hi,

The process is almost there, but instead of saving the PDF to disk, I am automatically sending the PDF for download once it is created. Nothing is emailed (although it might become a possibilty if I wanted it to).

The reason for using a repeat region is to be able to display products in an invoice. The first row generated by the recordset is fine, but the subsequent rows simply do not show.

I am happy to post all my code if required.

Thanks,
Adam

0

You cannot download a file unless it exists, so you need to save it to disk, and then provide a link to it.

Yes, post your current code.

I'll be offline for a few hours but can look at it later.

0

Hi AS,

Sorry I didn't post back for a long time, I've been busy with other websites and I've also recently moved house.

Here is my code for the whole script. Bare in mind that the recordset works fine, and the dynamic text works perfectly, only the repeat region doesn't.

<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Products_numRows = Products_numRows + Repeat1__numRows
%>
<% 
Dim Body2

While ((Repeat1__numRows <> 0) AND (NOT Products.EOF)) 

Body2 = "<tr><td width=""80%"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall"">" & Products.Fields.Item("MoreInfo").Value & " - " & Products.Fields.Item("BillingCycle").Value & "</div></td><td width=""20%"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall"">&pound;" & Products.Fields.Item("ProductCost").Value & "</div></td></tr>"

  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Products.MoveNext()
Wend

%>
<%
Set Pdf = Server.CreateObject("Persits.Pdf")
' Use direct HTML feed. The argument string must contain "<html>"
Set Doc = Pdf.CreateDocument
Body = "<html xmlns=""http://www.w3.org/1999/xhtml""><head><meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" /><title>Invoice</title><link href=""http://www.silverlinewebsolutions.co.uk/CSS.css"" rel=""stylesheet"" type=""text/css"" /><link href=""http://www.silverlinewebsolutions.co.uk/Text.css"" rel=""stylesheet"" type=""text/css"" /></head><body><table width=""85%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0""><tr><td width=""10%"" height=""130"" valign=""top""><img src=""http://www.silverlinewebsolutions.co.uk/Images/Logo.jpg"" alt=""Silverline Web Solutions"" width=""120"" height=""120"" /></td><td width=""45%"" height=""130"" valign=""top""><div align=""left""><p><span class=""BodyTextLarge""><strong>Silverline Web Solutions</strong></span><br /><span class=""BodyTextSmall"">103 Norwich Road<br />Wroxham<br />Norwich, Norfolk<br />NR12 8RY<br />United Kingdom</span></p></div></td><td width=""45%"" valign=""top""><table width=""100%"" border=""0"" class=""InvoiceBorder"" align=""right"" cellpadding=""0"" cellspacing=""0""><tr><td class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><strong>Invoice Date </strong></div></td><td class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><strong>Invoice Number </strong></div></td></tr><tr><td class=""PicBorder""><div align=""center"" class=""BodyTextSmaller""><div align=""left"">" & InvoiceDetails("StartDate").Value & "</div></div></td><td class=""PicBorder""><div align=""center"" class=""BodyTextSmaller""><div align=""left"">" & InvoiceDetails("InvoiceID").Value & "</div></div></td></tr><tr><td class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><strong>Payment Status </strong></div></td><td class=""PicBorder""><div align=""left"" class=""BodyTextSmall"">" & InvoiceDetails("Status").Value & "<br /><span class=""BodyTextSmaller"">" & InvoiceDetails("DatePaid").Value & "</div></td></tr><tr><td height=""40"" colspan=""2"" valign=""bottom"" class=""BodyTextSmall"">&nbsp;</td></tr></table></td></tr><tr><td colspan=""3""><img src=""http://www.silverlinewebsolutions.co.uk/Images/spacer.gif"" alt=""Invoice Details"" width=""100%"" height=""20"" /><table width=""100%"" border=""0"" cellpadding=""4"" cellspacing=""0"" class=""PicBorder""><tr><td width=""30"" class=""BodyTextSmall""><div align=""left""><strong>Invoice To: </strong></div></td><td class=""BodyTextSmall""><div align=""left""><strong>Notes:</strong></div></td></tr><tr><td width=""60%"" class=""BodyTextSmall""><div align=""left"">" & User("FName").Value & "&nbsp;" & User("LName").Value & "<br />" & User("Address1").Value & "," & User("Address2").Value & "<br />" & User("Town").Value & ",&nbsp;" & User("County").Value & "<br />" & User("Postcode").Value & "<br />" & User("Country").Value & "</div></td><td width=""40%"" valign=""top"" class=""BodyTextSmaller""><div align=""left"">None</div></td></tr></table><img src=""http://www.silverlinewebsolutions.co.uk/Images/spacer.gif"" alt=""Invoice Details"" width=""100%"" height=""20"" /><table width=""100%"" border=""0"" cellpadding=""4"" cellspacing=""0""><tr><td width=""80%"" height=""30"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><strong>Product Description </strong></div></td><td width=""20%"" height=""30"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><strong>Amount</strong></div></td></tr>"

Body3 = "</table><img src=""http://www.silverlinewebsolutions.co.uk/Images/spacer.gif"" alt=""Invoice Details"" width=""100%"" height=""20"" /></td></tr><tr><td colspan=""3""><div align=""right"" class=""BodyTextSmall""><table width=""100%"" border=""0"" cellpadding=""4"" cellspacing=""0""><tr><td width=""60%"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><div align=""left"" class=""BodyTextSmaller""><p>If you have any questions or queries about payment this invoice please don't hesitate to contact us. Either visit our website at www.silverlinewebsolutions.co.uk or email us at admin@silverlinewebsolutions.co.uk.</p><p class=""BodyTextSmaller""><strong>Note: </strong>invoices must be settled on or before the invoice date to avoid late payment charges.</p></div></div></td><td width=""20%"" valign=""top"" class=""PicBorder""><div class=""BodyTextSmall"" align=""right""><p>&nbsp;</p><p><strong> Total:</strong></p></div></td><td width=""20%"" valign=""top"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><p>&nbsp;</p><p>&pound;" & InvoiceDetails("Total").Value & "</p></div></td></tr></table></div></td></tr></table></body></html>"

Dim All

All = Body & Body2 & Body3

Doc.ImportFromUrl All

Filename = Doc.Savehttp("attachment;filename=Invoice ("& InvoiceDetails("InvoiceID") & ").pdf")
%>

Thank you again for the help!

Adam

0

Repeat1__numRows=Repeat1__numRows-1
Why is this value decreasing? It already starts at -1?

0

Hi Flood,

Not sure, it was the code that was generated by Dreamweaver. It seems to work on the asp vb page, so I copied the code and tried to use it in my script, but with no luck :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.