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!
Vertical position after DrawMultiLineText |
Post Reply |
Author | |
FernandoV
Beginner Joined: 02 Mar 11 Location: USA Status: Offline Points: 1 |
Post Options
Thanks(0)
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
|
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store