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 > Sample Code
  New Posts New Posts RSS Feed - Vertical position after DrawMultiLineText
  FAQ FAQ  Forum Search   Register Register  Login Login

Vertical position after DrawMultiLineText

 Post Reply Post Reply
Author
Message
FernandoV View Drop Down
Beginner
Beginner
Avatar

Joined: 02 Mar 11
Location: USA
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote FernandoV Quote  Post ReplyReply Direct Link To This Post Topic: Vertical position after DrawMultiLineText
    Posted: 02 Mar 11 at 4:39PM
 
I am trying to accomplishthe following:
 
1.- Placing multilines text in a page. The number of lines is dynamic but for this sample i am using 100 lines.
2.- Place an image just below the last line of text
3.- Add pages automatically as needed to fit the text and image.
 
Please advise
 
Thank You
 
This is what i have so far:
 
************ Sample VB.Net **************
Private Sub Test()
 
Dim qp as New QuickPDFAX????/PDFLibrary
Dim iID as Integer = 0
dim i as Integer = 0
dim sLine as String = String.Empty
 
'This block will just fake multi lines tobe added to the page
For  i = 0 to 100
      sLine += sLine + "Line " + i.ToString + ControlChars.CrLf
Next i
 
qp.SetOrigin(1)
qp.AddStandardFont(8)
qp.SetTextSize(7)
qp.DrawMultiLineText(100, 10, ControlChars.CrLf, sText)
 
'Now i need to add an image below the text
qp.CompressImages(1)
iID = qp.AddImageFromFile("c\test.jpg", 0)
qp.SelectImage(iID)
 
Dm YY as Double = ????    'current Vertical Position,  what is the vertical postion?

qp.DrawscaleImage(200, YY, 0.5)
qp.SaveToFile("c:\test.pdf")
 
 
End Sub
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 13 Oct 11 at 4:27PM
Here is a solution-idea in Delphi. But the intention should come clear.
We need Informations like how much lines and how high. Nothing more. Little bit more is to do, if the text should fit in a given width. This is shown.

The code:

var
  QP: TQuickPDF;
  s: string;
  n: integer;
  hb, h, sizey: double;
begin
  QP := TQuickPDF.Create;
  QP.UnlockKey('your key');
  QP.SetOrigin(1);                // topleft
  QP.SetMeasurementUnits(1);      // millimeters
  QP.SetPageDimensions(210, 297); // DIN A4
  QP.AddStandardFont(8);
  QP.SetTextSize(16);
  s := 'This is the Text, which will be wrapped. Therefore we have to find out,'
      +' how much lines are there after wrapping. Then we calc the y-size of a '
      +'textbox.'+#13#10
      +'Here is a new line starting. We may see how high is a line and so we '
      +'find out what we need to know. Now you are able to count how much lines '
      +'fill the place on the page. So build new pages for the remainig lines '
      +'and figure out wether is there enough space for your image or not.'
      +#13#10+#13#10
      +'It is better to use the GetWrappedtext-function to split the text into'
      +' portions of lines depending on the y-size. It makes a little more work.';
  n := QP.GetWrappedTextLineCount(160, s);
  h := QP.GetTextHeight;
  hb := QP.GetTextBound(2);  // height over baseline because baseline is textstart
  sizey := n*h;              // the full text
  QP.DrawWrappedText(25.0, 15.0+hb, 160, s);
  QP.DrawBox(25.0, 15.0, 160.0, sizey, 0);  // show the needed space as box

I hope it helps,

Werner


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