Kan ikke få en sub til at fungere
Hejsa eksperter,Jeg laver i nedenstående script en PDF hvor jeg har to kolonner. Dog kan jeg ikke få mit:
Call GeneratePdf() til at fungere???
Det skal lige siges at jeg har modificeret et fungerende script så det kan godt være der er noget helt galt.. men jeg er meget ny i Subs
Tror det er i denne funktion "Sub GeneratePdf()" men ved ikke hvor problemet er ???
Den fejl jeg får er "Object required: 'PdfPage' " jeg har markeret linien med fejlen i scriptet forneden med ' ########
Håber der er nogle som kan hjælpe.
<!--#include file="../Connections/pdfdatabase.asp" -->
<%
'on error resume next
Dim Pdf
Dim Doc
Dim PdfPage
Dim PdfFont
Dim PdfBarcodeFont
Dim CurrYPos
Dim CurrPageNo
Set Pdf = Server.CreateObject("Persits.Pdf")
'Pdf.RegKey = "IWez+gzm9x8nIAcKfuBAC41g1Fp/aN+p8i0OGrbw8J1mVYKz9MyyaZgJiUzoRCwy4RbkYcSkyQE7"
Call GeneratePdf()
'-----------------------------------------------------------------------------------------------------------
'Build the PDF dynamically and send the Pdf content as the page response
'MmodelnrList = a list of comma delimited Mmodelnr's
Sub GeneratePdf()
Dim Counter
Dim Conn
Dim ConnStr
Dim Sql
'create the pdf document
Set Doc = Pdf.CreateDocument
'init document properties
Doc.Title = "Pro Design Denmark"
Doc.Creator = "Pro Design Denmark"
Doc.CreationDate = Now
Doc.Author = "Pro Design Denmark"
'init the font to be used for text
Set PdfFont = Doc.Fonts("Arial")
'init the font to be used for text
Set PdfBarcodeFont = Doc.Fonts.LoadFromFile(Server.MapPath(".") & "\V100020_.TTF")
'open an ADO connection to the database
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open MM_pdfdatabase_STRING
'create the recordset for the items query
Dim Rs
Set Rs = Server.CreateObject("ADODB.Recordset")
'Items query
Sql = "SELECT * from Booklettemple order by Tmodelnr ASC"
Call Rs.Open(Sql, Conn, 3) 'adOpenStatic
'loop thru all the items
Counter = 0
While Not Rs.EOF
Counter = Counter + 1
'handle page break
'If PrevMmodelnr <> CurrMmodelnr Or Counter > 18 Then
If Counter > 18 Then
Set PdfPage = Doc.Pages.Add
PrevCounter = CurrCounter
Counter = 1
End If
If Counter Mod 2 <> 0 Then
Call PrintItem(Rs, 1)
Else
Call PrintItem(Rs, 2)
End If
Rs.MoveNext
Wend
'clean up
Rs.Close
Conn.Close
'save to HTTP stream
Response.Buffer = True
Response.Clear
Call Doc.SaveHttp("attachment;filename=booklet.pdf")
Response.End
End Sub
'-----------------------------------------------------------------------------------------------------------
'Print an individual item placed on the left or right column
Sub PrintItem(RS, Column)
Dim XPos
Dim YPos
If Column = 1 Then Pos = 0.95 Else Pos = 5.25
Call PdfPage.Canvas.DrawRect(X(Pos), Y(CurrYPos + 1.0), CPoints(1.9), CPoints(0.65)) ' ########
Params = "x=" & CvStr(X(Pos + 0.30)) & ", y=" & CvStr(Y(CurrYPos + 0.35)) & ", size=30, color=black"
usethisbarcode = Rs("Tbarcode")
usethisbarcode = "*"&usethisbarcode&"*"
Call PdfPage.Canvas.DrawText(usethisbarcode, Params, PdfBarCodeFont)
Params = "x=" & CvStr(X(Pos)) & ", y=" & CvStr(Y(CurrYPos + 1.10)) & ", size=8, color=black"
Call PdfPage.Canvas.DrawText(Rs("Tvariantnr"), Params, PdfFont)
Params = "x=" & CvStr(X(Pos)) & ", y=" & CvStr(Y(CurrYPos + 1.23)) & ", size=8, color=black"
Call PdfPage.Canvas.DrawText("Size: " & Rs("Tsize"), Params, PdfFont)
If Column = 1 Then Pos = 2.86 Else Pos = 7.16
thisisthecolor = Rs("Tcolor")
if thisisthecolor <> "" then
thisisthecolor = replace(thisisthecolor, " ", "")
thisisthecolor = "#" & thisisthecolor
else
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#cludes" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#5,23e+059" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#5,7e+069" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#7,11e+021" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#5,04e+037" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#XXXXXX" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#7,9e+027" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#7e+037" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#5,32e+030" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#6,24e+028" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#7,74e+040" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#5,83e+043" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#6,52e+031" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#6,14e+049" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#6,24e+047" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#4,56e+079" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#5,73e+043" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#3,82e+039" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#75966-" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#8E4E1-" then
thisisthecolor = "#FFFFFF"
end if
if thisisthecolor = "#E4E4E-" then
thisisthecolor = "#FFFFFF"
end if
'response.write Rs("vcolor") & " | "
Call PdfPage.Canvas.SetParams("FillColor=" & thisisthecolor)
Call PdfPage.Canvas.FillRect(X(Pos), Y(CurrYPos + 1.0), CPoints(0.50), CPoints(0.25))
If Column = 2 Then
CurrYPos = CurrYPos + 1.15
End If
End Sub
'-----------------------------------------------------------------------------------------------------------
'AspPDF coordinates are always in points (72 points / inch) and the
'coordinate space has the origin in the lower-left corner of the page with the
'X axis extending horizontally to the right, and the Y axis vertically upwards.
'
'Points are not natural to work with so the following functions
'are simply helper functions to work in inches instead of points
'and from a top-bottom coordinate system.
'-----------------------------------------------------------------------------------------------------------
'-----------------------------------------------------------------------------------------------------------
'Y value in inches from top of page
Function Y(ByVal Inches)
Y = CPoints(Round(11 - Inches, 4))
End Function
'-----------------------------------------------------------------------------------------------------------
'X value in inches from left of page
Function X(ByVal Inches)
X = CPoints(Inches)
End Function
'-----------------------------------------------------------------------------------------------------------
'Converts inches to points (72 points / inch)
Function CPoints(ByVal Inches)
CPoints = Inches * 72
End Function
'-----------------------------------------------------------------------------------------------------------
'Converts points to inches (72 points / inch)
Function CInches(ByVal Points)
CInches = Points / 72
End Function
'-----------------------------------------------------------------------------------------------------------
'Converts a numeric value to a string with the correct decimal point
Function CvStr(ByVal Value)
CvStr = Replace(Value, ",", ".")
End Function
%>
