Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - HTMLTextBox ending y calculation
  FAQ FAQ  Forum Search   Register Register  Login Login

HTMLTextBox ending y calculation

 Post Reply Post Reply
Author
Message
rdmstrs View Drop Down
Beginner
Beginner


Joined: 07 Mar 11
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdmstrs Quote  Post ReplyReply Direct Link To This Post Topic: HTMLTextBox ending y calculation
    Posted: 07 Mar 11 at 10:33PM
I am sure this is easier than I am making it. I am dynamically making an HTMLTextBox that can be on 1 page or infinite pages everything for that is working great, however I need to add some text and an image after the last box. I am having the toughest time calculating the y pos at the end of the box. I am using the line count and then multiplying that by my best guess at font height, however it is very inconsistent. Any ideas? I am working in vb.net with the activeX
Back to Top
rdmstrs View Drop Down
Beginner
Beginner


Joined: 07 Mar 11
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdmstrs Quote  Post ReplyReply Direct Link To This Post Posted: 07 Mar 11 at 10:37PM
I went back to the documentation after posting this just to make sure I didn't miss a function that returns text height and there it was. I will try it again using that.
Back to Top
rdmstrs View Drop Down
Beginner
Beginner


Joined: 07 Mar 11
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdmstrs Quote  Post ReplyReply Direct Link To This Post Posted: 07 Mar 11 at 10:46PM
That didn't do the trick either.
Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Posted: 08 Mar 11 at 10:21AM
Can you post the code that you've got so far? Perhaps we'll be able to provide some tips on how to improve it.
Back to Top
rdmstrs View Drop Down
Beginner
Beginner


Joined: 07 Mar 11
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdmstrs Quote  Post ReplyReply Direct Link To This Post Posted: 09 Mar 11 at 5:09PM

Here is the code, thanks for any help.

    Public Sub CreateDoc()
        Dim PDFLibrary As QuickPDFAX0723.PDFLibrary
        PDFLibrary = CType(CreateObject("QuickPDFAX0723.PDFLibrary"), QuickPDFAX0723.PDFLibrary)
        If PDFLibrary.UnlockKey("Unlock Key") = 1 Then
            PDFLibrary.AddImageFromFile(Application.StartupPath & "\Images\1.jpg", 0)
            PDFLibrary = WriteHeader(PDFLibrary)
            Dim Content As String = PDFLibrary.DrawHTMLTextBox(40, 635, 540, 570, Text(PDFLibrary))
            Dim LastPgContent As String = Content
            Dim hTBWidth As Double = PDFLibrary.GetHTMLTextWidth(540, Text(PDFLibrary))
            Dim hTBLineCount As Long = PDFLibrary.GetHTMLTextLineCount(hTBWidth, Text(PDFLibrary))
            Dim TextHeight As Double = PDFLibrary.GetHTMLTextHeight(540, Text(PDFLibrary))
            Dim MultiPg As Boolean = False
            PDFLibrary = WriteFooter(PDFLibrary)
            Do Until Content = ""
                PDFLibrary.NewPage()
                PDFLibrary = WriteHeader(PDFLibrary)
                If PDFLibrary.GetHTMLTextLineCount(540, Content) < 49 Then
                    LastPgContent = Content
                End If
                Content = PDFLibrary.DrawHTMLTextBox(40, 635, 540, 570, Content)
                PDFLibrary = WriteFooter(PDFLibrary)
                MultiPg = True
            Loop
            If MultiPg Then
                hTBWidth = PDFLibrary.GetHTMLTextWidth(540, LastPgContent)
                hTBLineCount = PDFLibrary.GetHTMLTextLineCount(hTBWidth, LastPgContent)
                TextHeight = PDFLibrary.GetHTMLTextHeight(540, LastPgContent)
            End If
            Dim y As Double = 1
            y = hTBLineCount * (TextHeight / hTBLineCount)
            PDFLibrary = WriteSig(PDFLibrary, y, 40)
            For i = 1 To PDFLibrary.PageCount
                PDFLibrary.SelectPage(i)
                PDFLibrary.DrawHTMLText(480, 775, 250, "<font size=""3""><b>Page " & i & " of " & PDFLibrary.PageCount & "</b></font>")
            Next
#If DEBUG Then
            PDFLibrary.SaveToFile("C:\Docs\Doc.pdf")
            'Dim PrintOp As Integer = PDFLibrary.PrintOptions(0, 0, "Doc")
            'PDFLibrary.PrintDocument("myPrinter", 1, PDFLibrary.PageCount, PrintOp)
#Else
            'Send file to server
#End If
        End If
        PDFLibrary = Nothing
    End Sub
    Function Text(ByVal myPdfLib As QuickPDFAX0723.PDFLibrary) As String
        Dim sText As String = "Some Strings"
        Return sText
    End Function
    Private Function WriteSig(ByVal oPDF As QuickPDFAX0723.PDFLibrary, ByVal y As Double, Optional ByVal left As Integer = 210) As QuickPDFAX0723.PDFLibrary
        Dim Last As String = "Last"
        If Last = "LastName" Or Last = "Other Lastname" Then
            oPDF.AddImageFromFile(Application.StartupPath & "\Images\Sig.jpg", 0)
            oPDF.DrawImage(left, (725 - y), 150, 45)
            Dim Sig As String = ""
            Sig = "Name<br>Title"
            oPDF.DrawHTMLTextBox(left, (725 - y) - 50, 375, 75, Sig)
        End If
        Return oPDF
    End Function
    Private Function WriteHeader(ByVal oPDF As QuickPDFAX0723.PDFLibrary) As QuickPDFAX0723.PDFLibrary
        oPDF.DrawImage(450, 750, 126, 94)
        oPDF.DrawLine(32, 760, 580, 760)
        oPDF.DrawLine(32, 645, 580, 645)
        oPDF.DrawHTMLText(480, 640, 250, "<font size=""6""><b>Title</b></font>")
        Return oPDF
    End Function
    Private Function WriteFooter(ByVal oPDF As QuickPDFAX0723.PDFLibrary) As QuickPDFAX0723.PDFLibrary
        oPDF.DrawLine(32, 45, 580, 45)
        Dim sFooter As String = "Address"
        oPDF.DrawHTMLText(32, 35, 548, "<p align=""center"">" & sFooter & "</Align>")
        Return oPDF
    End Function
 
Back to Top
rdmstrs View Drop Down
Beginner
Beginner


Joined: 07 Mar 11
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdmstrs Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 11 at 10:12PM
I was right, I was definitely making this more difficult than necessary. Just wanted to post what finally worked. getHTMLTextHeight does give you the correct amount of space taken and you simply subtract it from the top of your HTMLTextbox and there is your y value. I wasn't passing the correct html to the function when I tried testing it previously.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store