Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centered text in a PDF file 1

Status
Not open for further replies.

gullipe

Programmer
Oct 5, 2006
139
IS
Hi

I am new to this Acrobat (PDF) forum (but have been occasionally on the Fortran forum for some years now). I am trying to write a PDF code, but I have problems centering text. Below is a short "program" that writes the text "Centered text" starting at position x=100, y=600. But how do I center this text at the position 100,600 ? Can anyone help?


Code:
%PDF-1.4

1 0 obj
   << /Type /Catalog
      /Outlines 2 0 R
      /Pages 3 0 R
   >>
endobj

2 0 obj
   << /Type /Outlines
      /Count 0
   >>
endobj

3 0 obj
   << /Type /Pages
      /Kids [ 4 0 R ]
      /Count 1
   >>
endobj

4 0 obj
   << /Type /Page
      /Parent 3 0 R
      /MediaBox [ 0 0 612 792 ]
      /Contents 5 0 R
      /Resources << /ProcSet 6 0 R
                  /Font << /F1 7 0 R >>
                  >>
   >>
endobj

5 0 obj
   << /Length 73 >>
stream
BT
   /F1 24 Tf
[COLOR=red]   100 600 Td
   ( Centered text ) Tj[/color]
ET
endstream
endobj

6 0 obj
   [ /PDF /Text ]
endobj

7 0 obj
   << /Type /Font
      /Subtype /Type1
      /Name /F1
      /BaseFont /Helvetica
      /Encoding /MacRomanEncoding
   >>
endobj

xref
0 8
0000000000 65535 f
0000000009 00000 n
0000000074 00000 n
0000000120 00000 n
0000000179 00000 n
0000000364 00000 n
0000000466 00000 n
0000000496 00000 n

trailer
   << /Size 8
      /Root 1 0 R
   >>

startxref
625
%%EOF
 
I've never run into anyone trying to create a PDF by coding it - what most of us do is create a document that looks the way we want it to, in Word, Excel, Publisher, whatever, and then 'Print' to Acrobat Distiller or CutePDF or whatever.

Fred Wagner

 
Hi FredWagner

The problem is that the users of the program, that I am modifying do not all have "printers" like Acrobat Distiller, CutePDF or PDFWriter etc.

Anyway I desided to try to make a PDF file myself (with the program), and it has been successful up to now with the help of the PDF Reference manuals from Adobe (can be found on the internet) and the ISO 32000 PDF standard.

But there seems to be no text "centering" possibility in the PDF script (I have not found any yet at least). I thought that someone here might have the solution.
 
Hi MarkWalsh

Thank you for this.
Happy weekend.
gullipe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top