|
Rank: Newbie Groups: Member
Joined: 12/18/2010 Posts: 8
|
Hi I am new to EO.PDF. I have a VB.Net project that creates a report and prints it to a printer. Now I want to convert it to print to PDF file without loading drivers on the users computer. How do I print text right aligned to the the right margin? Similarly I need to print a footer at the bottom of the page.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, To right align text, you would set the AcmStyle object's HorizontalAlign to Right. For example:
Code: Visual Basic.NET
Dim text As AcmText
text = New AcmText("hello!")
text.Style.HorizontalAlign = AcmHorizontalAlign.Right
Note this only creates a PDF file for you. If your user only wants to view the file, he can view it in a browser or with Adobe PDF reader. If they want to print it, they can do the same within the browser or Adobe PDF reader. Our components only create the PDF file for you. It does not talk with the printer directly. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 12/18/2010 Posts: 8
|
Thanks for the help, I have already tried that but I don't get the results I am looking for. I am trying to put a text field in the top right corner of the page.
How do I determine the width of the text string using different fonts?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Sorry about that. The previous code is wrong. Try the following code:
Code: C#
PdfDocument doc = new PdfDocument();
//Alignment is set on the block
AcmBlock block = new AcmBlock();
block.Style.HorizontalAlign = AcmHorizontalAlign.Right;
//Add the text into the block
AcmText text = new AcmText("hello");
block.Children.Add(text);
//Render the block
AcmRender render = new AcmRender(doc);
render.Render(block);
doc.Save("c:\\test.pdf");
The key is alignment is set on the containing block, not on the text. You do not need to get the width of the text because that is automatically calculated. The default document has an one inch margin on all side. You can change that margin when you create the AcmRender object: http://doc.essentialobjects.com/library/4/advanced%20formatting/page_layout.aspxHope this helps. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 12/18/2010 Posts: 8
|
Thanks - I have managed to print the page with 3 fields on the heading line, aligned left, centre and right. I am using the render.beforerenderpage to process the heading and setting block.top = 0.
My problem is that the heading lines print on line 2, but if I remove the top=0 the first block print in the correct location. Also although I set the font style to bold it prints normal. (this seems to be only with the render.beforerenderpage)
Please advise what I am doing wrong.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Block.Top = 0 has quite some implications because it would float the block. So without seeing your code we can't tell exactly what's wrong. However if you can isolate the problem into a small piece of test code and post the code, we can then run it here and see the result. After that we should be able to tell you why it's behaving that way and what needs to be changed to produce the desired result.
Thanks!
|
|