PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Display text absolute position
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1149
Page 1 of 1

Author:  alejandr0 [ Thu Apr 15, 2010 5:32 pm ]
Post subject:  Display text absolute position

Hi,

Im creating a Invoice witch can have one or more pages, I want to display the total at the bottom of the las page. Any ideas?

Thanks,
Alejandro

Author:  Thomas Hoevel [ Mon Apr 19, 2010 7:21 am ]
Post subject:  Re: Display text absolute position

Hi!
Use a TextFrame. The TextFrame will be on the "current" page (i. e. last page) and can have an absolute position.

Author:  AlexB [ Wed Apr 21, 2010 8:56 pm ]
Post subject:  Re: Display text absolute position

Thomas Hoevel wrote:
Hi!
Use a TextFrame. The TextFrame will be on the "current" page (i. e. last page) and can have an absolute position.


Hi,
I am interseted in same ability too, byt because I am new with your program, I do not know where can I find it, could you please do me a favor and give me more information (where is it or do you have a sampe code for it)?
Thank you in advance for your time
Alex

Author:  Thomas Hoevel [ Thu Apr 22, 2010 7:59 am ]
Post subject:  Re: Display text absolute position

AlexB wrote:
I do not know where can I find it

Use the methods called "AddTextFrame". Four classes implement AddTextFrame.
Simply type "AddTextFrame" into the index search of the VS documentation (after installing the PDFsharp help files) or search this forum for "AddTextFrame".

Author:  alejandr0 [ Thu Apr 22, 2010 2:35 pm ]
Post subject:  Re: Display text absolute position

I actually never find out how to set the absolute position, I found out that textFrame only has top and left properties. I would appreciate if someone could give me an example

Author:  Thomas Hoevel [ Mon Apr 26, 2010 7:41 am ]
Post subject:  Re: Display text absolute position

alejandr0 wrote:
I found out that textFrame only has top and left properties

Maybe the names should be vertical and horizontal (instead of top and left).

Here's an example for a right-aligned textframe:
Code:
TextFrame tf = footer.AddTextFrame();
tf.RelativeHorizontal = RelativeHorizontal.Page;
tf.RelativeVertical = RelativeVertical.Paragraph;
tf.Left = ShapePosition.Right;
tf.WrapFormat.Style = WrapStyle.Through;
tf.Width = Unit.FromMillimeter(36);
tf.Height = Unit.FromPoint(12 + 2);

You can also set tf.Top to ShapePosition.Bottom for a bottom-aligned textframe.

Author:  RobertB [ Sun May 09, 2010 4:26 pm ]
Post subject:  Re: Display text absolute position

Hi,
I have same problem and because I am new in C#, I did not understand your instruction, Actually I solved my problem with a silly method. I run my report first and count the actual pages = Z and re-run the report and use Z in second time report.
Could you please help me how can I use "TextFrame".

Thank you in advance
Robert

Author:  Thomas Hoevel [ Mon May 10, 2010 12:25 pm ]
Post subject:  Re: Display text absolute position

RobertB wrote:
I have same problem and because I am new in C#, I did not understand your instruction, Actually I solved my problem with a silly method. I run my report first and count the actual pages = Z and re-run the report and use Z in second time report.

With MigraDoc you can use
Code:
paragraph.AddNumPagesField();

to display the number of pages in a document (MigraDoc does the counting for you).

RobertB wrote:
Could you please help me how can I use "TextFrame".

I'm not sure if I understand that question.
Simply call "AddTextFrame()" to get a new textframe, then set its properties.
AddTextFrame is supported by e. g. Section, HeaderFooter, and Cell.

Author:  RobertB [ Mon May 10, 2010 8:02 pm ]
Post subject:  Re: Display text absolute position

Hi,
Thank you so much for your reply, let me describe my problem,
Suppose that I am going to create a PDF report,
how many page is it? I do not know, but I do need to have page X of Y in my all report's pages, and because I can not go back to the previous pages to write "Page: X of Y", when generating report finished,
I just create a report twice, at first time I generate the report to count number of the pages, with a temp name, then delete report from the my hard disk and again generate the same report, but in second time I do have number of pages (here is Y) and I can write it in my each page. (I know what X is in each page)
I hope, I made it clearly.
of course it takes time to create a report with your program but it is fantastic, because I can control on eveything and I do not depend on any external sotware and its setting up in other computers.
I have recommended it to most of my friends.
by the way if my litreture is not polite, I apologize because English is my second language.
Thank you and good luck
Robert

Author:  Thomas Hoevel [ Tue May 11, 2010 7:22 am ]
Post subject:  Re: Display text absolute position

Hi!
RobertB wrote:
but I do need to have page X of Y in my all report's pages, and because I can not go back to the previous pages to write "Page: X of Y", when generating report finished, [...]

With MigraDoc you use "paragraph.AddNumPagesField();" instead of "Y" and "paragraph.AddPageField();" instead of "X" and MigraDoc does the counting.
And even better: you can add this code once to the page footer (or header) and MigraDoc will repeat it automatically on every page (until a new section with a different header/footer starts).

With PDFsharp, you can keep all pages in an array - and when the document is done you can add "page X of Y" before saving the document.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/