Print Page | Close Window

Probably something simple - but I don't see it

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=1314
Printed Date: 05 May 25 at 8:31AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Probably something simple - but I don't see it
Posted By: lrzak
Subject: Probably something simple - but I don't see it
Date Posted: 17 Jan 10 at 9:01AM
Just bought Quick PDF, my first test. It works to the point that the text1 is displayed properly but text2, text3 and text4 are at the bottom of the page.

Tried doing a version with DrawHtmlTextBox but that doesn't honor the SetTextSpacing.

What am I missing ? And is the Reference Guide the only "manual" right now ?

Thanks.

******************************
Dim qp
Set qp = Server.CreateObject("quickPDFAX0717.PDFLibrary")
if qp.UnlockKey("my key is here")=1 then

    text1 = "This is some text that would go into this paragraph and it would go on and this is some text that would go into this paragraph and it would go on and this is some text that would go into this paragraph and it would go on and this is some text that would go into this paragraph and it would go on "
    text2 =  "but this text would be underlined "
    text3 = "and this would be not underlined but red, and "
    text4 = "this would be back to normal."
    

    qp.SetPageSize "A4"
    qp.AddStandardFont 8
    qp.SetOrigin 1
    tleft = qp.GetPageBox(2, 0) '0
    ttop = qp.GetPageBox(2,1) '0
    twidth = qp.GetPageBox(2,2) '612
    theight = qp.GetPageBox(2,3) '792

    tline = 1.5 * 72 ' start 1.5 inches down
   
    qp.SetTextSize 18  ' make title bigger
    qp.SetTextAlign 1 ' center the title
    qp.DrawTextBox 0, tline, twidth, 72, "MY BIG TEXT TEST", 1
    qp.SetTextAlign 0 ' back to left justified

    tline = tline + 72 ' go down 1 inch

    qp.SetTextSize 12 ' back to 12 point
   
    qp.SetTextSpacing 20 ' change the line/text spacing
   
    ' use 1 inch margins and draw paragraph 1
    qp.DrawWrappedText 72, tline, 612-(2*72), text1

    ' now add paragraph 2 - underlined
    qp.SetTextUnderline 1
    qp.appendtext text2
   
    ' and add paragraph 3 - and no underline
    qp.SetTextUnderline 0
    qp.SetTextColor 1,0,0
    qp.appendtext text3

    ' and add paragraph 4 - back to normal
    qp.SetTextColor 1,1,1
    qp.appendtext text3

    qp.CompressContent
    response.contenttype="application/pdf"
    response.AddHeader "Content-disposition", "attachment; filename=test.pdf"
    response.BinaryWrite qp.savetovariant()
    response.End()
set qp = nothing
end if

******************************



Replies:
Posted By: Ingo
Date Posted: 17 Jan 10 at 11:18AM
Hi!

Did you read here:
http://www.quickpdflibrary.com/help/quickpdf/GetPageBox.php

Cheers and welcome here,
Ingo


Posted By: lrzak
Date Posted: 17 Jan 10 at 2:29PM
Thanks - I did read that - look at my code - I'm using that to get the dimensions.  I've read most of the form messages back to page 21, I've read the reference manual and looked at the samples. Maybe I'm tainted in my thinking because I've been using WebSupergoo's PDF and Latex' too long.

Is there a real manual somewhere that I've not found?  The samples show adding one small line of text and in all the forum related subjects they do the same thing.

What/where is the explanation of what the basic QuickPDF process is (which is what I thought I was doing) that:

1. Defines an area for text
2. Puts some text in it
3. keeps adding text till the text is done.

Do I have to manually keep track of where the lines and words end  and add an x/y position to every statement ?

Is there some documentation I'm missing - point me, I'll read it.

Thanks again Ingo - all help is appreciated.


Posted By: Ingo
Date Posted: 17 Jan 10 at 6:19PM
Hi!

Here's an old sample having to do with table-creation but DrawTextBox is used, too:

  Call QP.UnlockKey(" - your license key here - ")
  Call QP.SetMeasurementUnits(1)   ' Millimetres
  Call QP.SetOrigin(1)             ' Top left corner
  Call QP.SetPageSize("A4")        ' A4 portrait paper
 
  Dim Row As Long                  ' Current row
  Dim Col As Long                  ' Current column
  Dim RowCount As Long             ' Total number of rows
  Dim RowHeight As Double          ' Height of each row
  Dim YPos As Double               ' Current vertical position
  Dim XPos As Double               ' Current horizontal position
  Dim DrawHeaders As Boolean       ' Must the headers be drawn?
  Dim ColCount As Long             ' Number of columns
  Dim ColWidths() As Double        ' Column widths
  Dim ColTitles() As String        ' Column titles
  Dim CellData() As String         ' Cell data
  Dim TableTop As Double           ' Vertical position of table
  Dim TableLeft As Double          ' Horizontal position of table
  Dim HeaderFont As Long           ' FontID of header
  Dim BodyFont As Long             ' FontID of body

  ' Add the fonts
  HeaderFont = QP.AddStandardFont(5)  ' Helvetica bold
  BodyFont = QP.AddStandardFont(4)    ' Helvetica

  ' Setup the rows
  RowCount = 50
  RowHeight = 20

  ' Setup the table
  TableLeft = 20
  TableTop = 20

  ' Setup the columns
  ColCount = 3
  ReDim ColWidths(ColCount) As Double
  ReDim ColTitles(ColCount) As String
  ColWidths(0) = 20
  ColWidths(1) = 100
  ColWidths(2) = 50
  ColTitles(0) = "ID"
  ColTitles(1) = "Description"
  ColTitles(2) = "Total"

  ' Populate some dummy data
  ReDim CellData(RowCount, ColCount) As String
  For Row = 1 To RowCount
    For Col = 1 To ColCount
      CellData(Row - 1, Col - 1) = Row & "-" & Col
    Next Col
  Next Row

  YPos = TableTop
  DrawHeaders = True

  For Row = 1 To RowCount

    If DrawHeaders Then

      Call QP.SelectFont(HeaderFont)
      Call QP.SetTextSize(12)
      Call QP.SetTextAlign(1)
      XPos = TableLeft
      For Col = 1 To ColCount
        Call QP.SetLineWidth(0.5)
        Call QP.SetLineColor(0, 0, 0)
        Call QP.SetFillColor(0, 0.2, 0.8)
        Call QP.DrawBox(XPos, YPos, ColWidths(Col - 1), RowHeight, 2)
        Call QP.SetTextColor(1, 1, 1)
        Call QP.DrawTextBox(XPos, YPos, ColWidths(Col - 1), _
          RowHeight, ColTitles(Col - 1), 0)
        XPos = XPos + ColWidths(Col - 1)
      Next Col
      YPos = YPos + RowHeight

      DrawHeaders = False

    End If

    Call QP.SelectFont(BodyFont)
    Call QP.SetTextSize(10)
    Call QP.SetTextAlign(0)
    XPos = TableLeft
    For Col = 1 To ColCount
      Call QP.SetLineWidth(0.5)
      Call QP.SetLineColor(0, 0, 0)
      Call QP.SetFillColor(1, 1, 1)
      Call QP.DrawBox(XPos, YPos, ColWidths(Col - 1), RowHeight, 2)
      Call QP.SetTextColor(0, 0, 0)
      Call QP.DrawTextBox(XPos + 1, YPos, ColWidths(Col - 1) - 2, _
        RowHeight, CellData(Row - 1, Col - 1), 0)
      XPos = XPos + ColWidths(Col - 1)
    Next Col
    YPos = YPos + RowHeight

    If (YPos + RowHeight > (QP.PageHeight - TableTop)) And (Row < RowCount) Then
      QP.NewPage
      YPos = TableTop
      DrawHeaders = True
    End If

  Next Row

  Call QP.SaveToFile("c:\table.pdf")

  Set QP = Nothing 


Cheers, Ingo


Posted By: lrzak
Date Posted: 19 Jan 10 at 5:19AM
I must not be asking the question correctly, let me try another example of what I'm after and if someone would direct me where to learn or show me an example of how to do this - 

On a A4 page with 144 point top border, 72 point left and 72 point right borders, I want to print this text "This is some text going into this paragraph and it is just some random text that will wrap to a second line in this page. Then "

Then I want this text to immediately follow but in red " this part of the line is in red "

Then I want this text to immediately follow but back in black " and this is back in black but bold."

I want it in 12 point with 20 point line spacing and I don't want to use any of the drawhtml functions - they don't support the line spacing.

It would look something like this but with the above borders:

This is some text going into this
paragraph and it is just some random
text that will wrap to a second line in
this page. Then this part of the line is
in red
and this is back in black but
bold.


My first thought of the flow would be this simple:
set font size
set font color
draw bounding box
put part 1 text
set color to red
put part 2 text
set color to black
set bold on
put part 3 text
etc...

Any ideas will be appreciated.
Thank you.



Posted By: Ingo
Date Posted: 19 Jan 10 at 6:31AM
Hi!

It's not possible to change fonttype, color, ... inside one textbox.
What is linespacing for you? With the html-functions you can use the break-tag "<br>" for a new line and you can use the space-tag "&nbsp". In the normal TextBox for a space you can use "Chr(160)" (and not Chr(32)). You can try Chr(10)+Chr(13) for a linebreak, too.
If you want to make more tests you should try the QuickPDF library demo, too.

Cheers, Ingo



Posted By: lrzak
Date Posted: 19 Jan 10 at 6:44AM
Hello -

If I am using 12 point type and set the line spacing to 25, the bottom of line 1 will be 25 points away from the bottom of line2, 50 points from the bottom of line 3, etc. So line spacing is the distance from one line to another regardless of the type point size.

I saw the Chr(160) in one of the previous forum posts. I did look at the library demo, didn't see an answer there.

How would you recommend doing what I mentioned in the previous post ?

thanks,
leon ...


Posted By: DELBEKE
Date Posted: 19 Jan 10 at 8:14AM
Hi, perhaps you cn do it with a richtextbox.
I have shown a code sample to draw a rtfBox on a Pdf
http://www.quickpdf.org/forum/convert-rtf-to-pdf_topic1266.html - http://www.quickpdf.org/forum/convert-rtf-to-pdf_topic1266.html



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