Welcome Guest Search | Active Topics | Sign In | Register

Left and Right Align test Options
Cliff
Posted: Saturday, December 18, 2010 8:54:20 AM
Rank: Newbie
Groups: Member

Joined: 12/18/2010
Posts: 8
Code: Visual Basic.NET


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.
eo_support
Posted: Saturday, December 18, 2010 9:45:56 AM
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!

Cliff
Posted: Sunday, December 19, 2010 12:14:00 AM
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?
eo_support
Posted: Sunday, December 19, 2010 10:52:52 AM
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.aspx

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!
Cliff
Posted: Friday, January 14, 2011 11:11:09 PM
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
eo_support
Posted: Saturday, January 15, 2011 9:29:42 AM
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!


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.