Print Page | Close Window

DrawTextBoxMatrix

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2696
Printed Date: 19 May 24 at 8:25PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: DrawTextBoxMatrix
Posted By: dghoskins
Subject: DrawTextBoxMatrix
Date Posted: 30 Jul 13 at 3:55PM
Hi,
I just purchased the Quick PDF library and am experimenting with it.  Version 9.15 introduced the DrawTextBoxMatrix function.  The following test program (VBA in MS Access) generates a pdf with the DrawText function and the DrawTextBox function producing visible results.  The DrawTextBoxMatrix does not produce a visible result.  The messagbox indicates that the DrawTextBoxMatrix returns a result of 1.  Am I missing something?

Test Program:

Sub MatrixTest()

    Dim folder, fname As String
    folder = CurrentProject.path & "\"
   
    fname = "Matrix Test.pdf"
   
    Dim xpdf As DebenuPDFLibraryAX0915.PDFLibrary
    Dim hfont, result As Long
    Dim title As String
    Dim tw, ang1, ang2, m12, m21 As Double
   
    Set xpdf = CreateObject("DebenuPDFLibraryAX0915.PDFLibrary")
    If xpdf.UnlockKey("xxxxxxxxxxxxxxxxxxxxxxxxx") = 0 Then
        Exit Sub
    End If
   
    xpdf.SetOrigin (1)
   
    hfont = xpdf.AddStandardFont(4)
   
    title = "Matrix Test"
    xpdf.SetTextSize (24)
    tw = xpdf.GetTextWidth(title)
    Call xpdf.DrawText((xpdf.PageWidth - tw) / 2, 35, title)
    xpdf.SetTextSize (18)

    ang1 = 10
    ang2 = 20
    m12 = Tan(D2R(ang1))
    m21 = Tan(D2R(ang2))
    result = xpdf.DrawTextBoxMatrix(200, 50, "TextBoxMatrix", 0, 1, m12, m21, 1, 320, 100)
    Call xpdf.DrawTextBox(320, 300, 200, 50, "TextBox", 0)
    MsgBox ("Result is " + Str$(result))
    Call xpdf.SaveToFile(folder + fname)
    Set xpdf = Nothing
   
End Sub

Function D2R(ByVal deg As Double) As Double
    D2R = deg / 57.29578
End Function

Function R2D(ByVal rad As Double) As Double
    R2D = rad * 57.29578
End Function


Thanks,
Dennis



Replies:
Posted By: kevindebenu
Date Posted: 01 Aug 13 at 8:16AM
Dennis,

For the new DrawTextBoxMatrix and DrawCapturedPageMatrix functions we decided to keep the matrix entries compatible with the existing DrawImageMatrix function.

With an image the graphic element is interpreted as a 1x1 unit and the matrix scales it to the size it needs to be.

This is the reason DrawTextBoxMatrix includes the first two parameters for the width and height of the untransformed text. The textbox is effectively scaled down to a 1x1 unit that can be transformed to any size/rotation/scale.

So a simple change to your example should give the result you're expecting:

result = xpdf.DrawTextBoxMatrix(200, 50, "TextBoxMatrix", 0, 200, m12, m21, 50, 320, 100)

In this case your matrix only included a rotation so it was easy to change the m11 and m22 entries from 1 to the new width/height. For other matrices you'd need to take your original matrix and multiply it by [ width 0 0 height 0 0 ]

As a test you could try the DrawImageMatrix function (to place a background image onto the page) and then use DrawTextBoxMatrix with the same matrix and the textbox should appear scaled to the same bounds as the image.

Regards,
Kevin



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk