ABCpdf doesn't work for me!!!!!

Discussion in 'ASP.NET / ASP.NET Core' started by hispanicdre, Jan 23, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Sorry if this has already been answered, but I can't find it!!!!!

    I've got a page that creates the pdf file. This creates the pdf (including the dynamic bits from my database!) but it renders the page wrong!

    I created it by building a standard html page and copied the source of that into the aspx that creates the pdf. I have a variable called theText (following the example code!) that is a string of the html source code including the db stuff. Yet when I view the pdf, I get a series of mis-matched paragraphs rather than a nicely laid out table with styled formatting. I read on the webSupergoo site that it has no concept of referenced files, so I copied my css styles into the page. This made no difference at all!

    The only html it seems to recognise is the </b> tag and the <a href='blah.asp'></a> tag.

    I'd be will to have the babies of the first person to sort this out for me!!! /emoticons/freaked.gif : /emoticons/tongue.gif
     
  2. Bruce

    Bruce DiscountASP.NET Staff

  3. Hi Bruce,

    Code is below (some of it is from the db so you'll need to replace these bits with fixed values if you want to run it).

    Thanks

    Tim

    Code:
    <%@ Page Language='VB' ContentType='text/html' ResponseEncoding='iso-8859-1' debug='true' %>
    <%@ Assembly name='ABCpdf, Version=4.0.1.5, Culture=neutral, PublicKeyToken=a7a0b3f5184f2169' %>
    <%@ import Namespace='WebSupergoo.ABCpdf4' %>
    <%@ import namespace='system.data.sqlclient' %>
    <script language='VBSCRIPT' runat='server' src='vbs/vbadovbs.vbs'></script>
    <script language='VBSCRIPT' runat='server' src='vbs/GlobalFunctions.vbs'></script>
    
    <script runat='server' Language='VB'>
    Sub page_load()
    	Dim dbconn as sqlconnection
    	Dim dbCMD as sqlCommand
    	Dim b as sqldatareader
    	Dim BookingRef as Long
    	
    	BookingRef = 240209
    	
    	dbConn = New SQLConnection ('Data Source=mssql07;Initial Catalog=DB_124220;User ID=hispanicdre;Password=hirabia')
    	dbConn.open()
    	dbCMD = new sqlcommand ('uspGetBooking ' & BookingRef, dbconn)
    	b = dbCMD.executereader()
    	
    	Dim theID As Integer = 0
    	Dim theText As String
    	
    	While b.read()
    		BookingRef = b('BookingRef')
    		theText ='<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>'
    		theText = theText & '<html>'
    		theText = theText & '<head>'
    		theText = theText & '<title>Hispanic Dreams Booking Confirmation (Booking Ref: 240209)</title>'
    		theText = theText & '<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>'
    		theText = theText & '<style>'
    		theText = theText & 'body.pdf {'
    		theText = theText & '	background-color: #FFFFFF;'
    		theText = theText & '	font-family: Verdana, Arial, Helvetica, sans-serif;'
    		theText = theText & '	font-size: 10pt;'
    		theText = theText & '	line-height: 24px;'
    		theText = theText & '	color: #000066;'
    		theText = theText & '}'
    		theText = theText & ''
    		theText = theText & 'td.pdf {'
    		theText = theText & '	font-family: Verdana, Arial, Helvetica, sans-serif;'
    		theText = theText & '	color: #000000;'
    		theText = theText & '	font-size: 10pt;'
    		theText = theText & '}'
    		theText = theText & ''
    		theText = theText & 'td.pdf_heading {'
    		theText = theText & '	font-family: Verdana, Arial, Helvetica, sans-serif;'
    		theText = theText & '	color: #000066;'
    		theText = theText & '	font-size: 10pt;'
    		theText = theText & '	font-weight: bold;'
    		theText = theText & '	background-color: #FF9900;'
    		theText = theText & '}'
    		theText = theText & ''
    		theText = theText & 'a.pdf {'
    		theText = theText & '	font-size: 10pt;'
    		theText = theText & '	font-family: Verdana, Arial, Helvetica, sans-serif;'
    		theText = theText & '	color: #000066;'
    		theText = theText & '	font-weight: bold;'
    		theText = theText & '}'
    		theText = theText & '</style>'
    		theText = theText & '</head>'
    		theText = theText & '[b]'
    		theText = theText & '<table width='80%' border='1' align='center' cellpadding='1' cellspacing='1' bordercolor='#000066'>'
    		theText = theText & '  <tr>'
    		theText = theText & '    <td>'
    		theText = theText & '	<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3'><img src='images/top_banner_index.gif' width='607' height='65'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td width='2%' class='pdf'></td>'
    		theText = theText & '          <td colspan='2' class='pdf'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3' class='pdf'> <p>This is confirmation of your booking '
    		theText = theText & '              of ' & DateDiff('d', b('StartDate'), b('EndDate')) & ' nights at the Hispanic Dreams villa in Merida, Mexico. please '
    		theText = theText & '              read and check this confirmation thoroughly as it forms part of '
    		theText = theText & '              the terms and conditions under which your holiday is allowed.</p>'
    		theText = theText & '            <p> Should you find any errors or have any queries prior to your holiday, '
    		theText = theText & '              please contact us at <a class='pdf' href='mailto:[email protected]'>[email protected]</a>.</p></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td colspan='2'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Penalties &amp; Cancellations</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td colspan='2' class='pdf'><p>Although you have confirmed your booking '
    		theText = theText & '              you may still cancel it without penalty up to 14 days before your scheduled arrival date of '
    		theText = theText & '              ' & LongDateFromUS(b('StartDate')) & '. '
    		theText = theText & '              This means that until ' & LongDateFromUS(DateAdd('d', -14, b('StartDate'))) & ' you may cancel the booking '
    		theText = theText & '              without penalty. Between 14 and 7 days before arrival you may still cancel '
    		theText = theText & '              the booking, but with a 50% penalty. In the final week before your arrival, '
    		theText = theText & '              cancellation will result in 100% penalty.</p>'
    		theText = theText & '           <p>(Penalties for bookings of seven nights or less are subject to '
    		theText = theText & '              100% penalty from 14 days before arrival.)</p>'				
    		Dim Penalty as Integer
    		If DateDiff('d', b('StartDate'), b('EndDate')) + 1 <= 7 Then
    			Penalty = DateDiff('d', b('StartDate'), b('EndDate'))
    		Else
    			Penalty = CInt((DateDiff('d', b('StartDate'), b('EndDate'))) / 2)
    		End If
    		theText = theText & '            <p>[b]In the case of this booking, cancellation between ' & LongDateFromUS(DateAdd('d', -14, b('StartDate')))
    		theText = theText & '              and ' & LongDateFromUS(DateAdd('d', -7, b('StartDate'))) & ' will result in a penalty of ' & Penalty & ' nights.
    '
    		theText = theText & '              Cancellations after ' & LongDateFromUS(DateAdd('d', -7, b('StartDate'))) & ' will result in a penalty of ' 
    		theText = theText & '              ' & DateDiff('d', b('StartDate'), b('EndDate')) & ' nights.</b></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Booking Information</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'>Booking Reference</td>'
    		theText = theText & '          <td class='pdf'>' & BookingRef & ' (Please quote this in all correspondence)</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'></td>'
    		theText = theText & '          <td class='pdf'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td width='39%' class='pdf'>Arrival Date:</td>'
    		theText = theText & '          <td width='59%' class='pdf'>' & LongDateFromUS(b('StartDate')) & '</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td width='39%' class='pdf'> Departure Date:</td>'
    		theText = theText & '          <td width='59%' class='pdf'>' & LongDateFromUS(b('EndDate')) & '</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td width='39%' class='pdf'>Check Out Time:</td>'
    		theText = theText & '          <td width='59%' class='pdf'>12:00 (later check out may be available, '
    		theText = theText & '            please check on arrival)</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td width='39%' class='pdf'>Party Size:</td>'
    		theText = theText & '          <td width='59%' class='pdf'>6 persons maximum</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'></td>'
    		theText = theText & '          <td class='pdf'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Additional Services</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td width='39%' class='pdf'>Car during stay</td>'
    		theText = theText & '          <td width='59%' class='pdf'>No</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'>Daily Maid Service</td>'
    		theText = theText & '          <td class='pdf'>Yes - included as standard</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'>Evening Bar Service</td>'
    		theText = theText & '          <td class='pdf'>Yes - see below for details</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'>All-Inclusive Package</td>'
    		theText = theText & '          <td class='pdf'>No</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Your Responsibilities</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf' colspan='2'>Don't trash it!</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Contact Details in Merida</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf' colspan='2'>Maria &amp; Manuel Hernandez are our representatives '
    		theText = theText & '            in Merida. They live in a house at the rear of the villa and will '
    		theText = theText & '            take care of you whilst you stay with us. The villa has an intercom '
    		theText = theText & '            connection to the Hernandez house.</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'><img src='images/manuel.jpg' width='126' height='83'></td>'
    		theText = theText & '          <td valign='top' class='pdf'>Manuel and Maria have worked with us for '
    		theText = theText & '            some time. Manuel has done most of the building work carried out on '
    		theText = theText & '            the villa in recent months. Manuel speaks fluent Spanish and English '
    		theText = theText & '            and is currently developing his German skills.</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf'><img src='images/maria.jpg' width='78' height='120'></td>'
    		theText = theText & '          <td valign='top' class='pdf'>Maria has been married to Manuel for 2 '
    		theText = theText & '            years and looks after every aspect of the running of the Villa. She '
    		theText = theText & '            is also fluent in Spanish and English and is very proud of the standards '
    		theText = theText & '            she sets at the villa. Please contact either manuel or Maria if you '
    		theText = theText & '            have any requirements you'd like to discuss.</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Contact Details in the UK</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td colspan='2'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Flights &amp; Transfers</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf' colspan='2'><p>Flights from and to your home country '
    		theText = theText & '              are your responsibility.</p>'
    		theText = theText & '            <p>If you have selected to take the option of the car during your '
    		theText = theText & '              stay, you will be met at Merida airport by Manuel with the car. '
    		theText = theText & '              Similarly, on your departure, you may take the car to the airport. '
    		theText = theText & '              Please forward your flight numbers to us prior to arrival in order '
    		theText = theText & '              that we can ensure the car is ready to meet you at Merida airport.</p>'
    		theText = theText & '            <p>If you have not elected to use the car during your stay, you will '
    		theText = theText & '              need to make your own arrangements for your transfers to the house. '
    		theText = theText & '              Although there is a very good bus service, it is generally best '
    		theText = theText & '              to take a taxi from the airport. Taxis are generally safe in Mexico '
    		theText = theText & '              and the trip will cost approximately $20 each way.</p></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td colspan='3'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td class='pdf_heading' colspan='3'>Instructions for your Arrival</td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td class='pdf' colspan='2'><p>On arrival at Merida Airport, please '
    		theText = theText & '              contact our local representatives, Maria and Manuel on 539 657 4876. '
    		theText = theText & '              You will be met at the property and taken through the check in process. '
    		theText = theText & '              During this process you will be asked to accompany Maria on an inventory '
    		theText = theText & '              inspection. After the inspection, you will be required to sign and '
    		theText = theText & '              date the inventory.</p>'
    		theText = theText & '            <p>Maria will give you all the details you require during your stay. '
    		theText = theText & '              Inside the property you will find our guest book. We would ask that '
    		theText = theText & '              you provide feedback regarding your stay. Please feel free to provide '
    		theText = theText & '              critical feedback. We are constantly looking at ways to improve '
    		theText = theText & '              your experience with us and so if you feel we are doing somthing '
    		theText = theText & '              wrong, we'd like to know.</p>'
    		theText = theText & '            <p>Whilst in the Yucatan area you will find many things to see and '
    		theText = theText & '              do. However, if you feel you are at a loss for something to do, '
    		theText = theText & '              we have provided a Guide Book full of suggestions.</p></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '        <tr> '
    		theText = theText & '          <td></td>'
    		theText = theText & '          <td colspan='2'></td>'
    		theText = theText & '        </tr>'
    		theText = theText & '      </table>'
    		theText = theText & ''
    		theText = theText & '	</td>'
    		theText = theText & '  </tr>'
    		theText = theText & '</table>'
    		theText = theText & '</body>'
    		theText = theText & '</html>'
    	End while
    	b.close()
    	dbConn.close()
    	
    	Dim theDoc As Doc = New Doc()
    	theDoc.Width = 2
    	theDoc.FontSize = 12
    	theDoc.Rect.Inset(20, 20)
    
    	theDoc.FrameRect()
    	theID = theDoc.AddHTML(theText)
    
    	theDoc.Save(Server.MapPath('bookings/' & BookingRef & '.pdf'))
    	theDoc.Clear()
    	
    	Response.Redirect('bookings/' & BookingRef & '.pdf')
    End Sub
       
    
    </script>
     
  4. So, this is of interest to us, too.
    Meaning, did you get to adopt any children (or, seriously, how did you resolve this problem)?


    Alex
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page