Okay, here's some of the relevant content stream from "toc_sample_ok"
 
BT                    - begin text

36 751 Td         - move to the start of the next line with the given
offsets

0 -16 Td            - err... okay.

/F6 12 Tf            - 12 point, font resource "F6"

(Additional Benefits Contact List)Tj        - display the given text

/F9 12 Tf            - 12 point, font resource F9

[-31165]TJ        - use kerning to adjust the location of the text a
whole bunch

/F6 12 Tf            - 12 point, font F6

(9)Tj                  - display the given text.

0 0 Td                - move to the start...

0 -16 Td            - move to the start...

Okay.  That's funky, but it works.  Ish.  And here's the "optimized"
version:

BT

/T1_0 12 Tf            - they change the font resource name.  No big
deal.

0 Tc 0 Tw 0 Ts 100 Tz 0 Tr 36 735 Td            - set a bunch of
defaults

(Additional Benefits Contact List9)Tj                - never switched to
the other font, never adjusted kerning.  Oops.

0 -16 TD                                                        - next
line, with a tweak

(National Contracted Facility/Vendors10)Tj    - ditto, never switched
fonts, never adjusted kerning.

I suspect that becuase F9 is never used to draw anything, "optimization"
throws it out and (erroneously) eats its kerning info.  That's a good
theory, and I'd wager a beer on it, but it really doesn't help us to
solve the problem... OR DOES IT?!  Okay, ugly hack time.

F9 happens to be helvetica.  You need to draw something, ANYTHING, with
that font.  Draw a background-colored period at 0,0... whatever.  In
doing so, you'll force the optimizer to not discard that font, hopefully
preserving the kerning info and keeping your text where it belongs:

PdfContentByte cb = writer.getDirectContent();

cb.saveState(); // don't change anything that comes after our little
hack job here

cb.beginText();

cb.setFontAndSize( BaseFont.CreateFont(), 1 ); // the default CreateFont
returns winAnsi Helvetica, convenient.

cb.setFillColor( Color.WHITE );

cb.drawText('."); // " " might work too, but an overly clever optimizer
might remove it.

cb.endText();

cb.restoreState(); // clean up our mess.  For every saveState, you MUST
have a restoreState()

 
--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 
 


________________________________

        From: [email protected] [mailto:[email protected]] 
        Sent: Wednesday, December 01, 2010 10:22 AM
        To: Post all your questions about iText here
        Subject: Re: [iText-questions] Help with DottedLineSeperator.
        
        
        Sure thing, 
        
        The attachment toc_sample_ok.pdf views fine for me in using
Acrobat 7. It does not view fine in 5. Other people see different things
depending on their version but I don't have a comprehensive list as to
how each version reacts. 
        
        The second attachment, toc_sample_optimized.pdf, is the result
of optimizing in Acrobat 7. Seems to only get effected like this if the
option 'Convert smooth lines to curves' is selected. However, it is
similar to how other versions view with the two texts concatenated as if
there is no dotted line. Also, as I mentioned before, some versions (as
well as the Rip's on press) view with the page number text at about a
half way point. 
        
        I do notice when trying to select the page numbers in
toc_sample_ok.pdf using Ptistop that they are actually coordinated next
to the listing text but somehow transformed(?) to be viewed over toward
the right.
        
        
        
          
        
________________________________________________________________________
________________ 
        Jason Leland Pelzel | Digital Print IT | RR Donnelley 
        5500 12th Avenue East | Shakopee, MN 55337 | *: 952.833.3473 |
*: 651.398.6188 | *: 952.942.8933 | *: [email protected]
<mailto:[email protected]>  
          
          
        
        
        
"Mark Storer" <[email protected]> 

12/01/2010 10:51 AM 
Please respond to
Post all your questions about iText here
<[email protected]>


To
"Post all your questions about iText here"
<[email protected]> 
cc
Subject
Re: [iText-questions] Help with DottedLineSeperator.

        




        We really need to see the PDF. 
          
        --Mark Storer 
          Senior Software Engineer 
          Cardiff.com 
          
        import legalese.Disclaimer; 
        Disclaimer<Cardiff> DisCard = null; 
          
          
        
        
________________________________

        From: Jason L Pelzel [mailto:[email protected]
<mailto:[email protected]> ] 
        Sent: Tuesday, November 30, 2010 1:44 PM
        To: [email protected]
        Subject: [iText-questions] Help with DottedLineSeperator.
        
        Hi, 
        
        I am using the DottedLineSeperator to build a table of contents
(.net version). The result looks fine in Acrobat 7. It also prints file
if direct from Acrobat 7. 
        
        However, if viewed in other versions, ripped on the printer, or
optimized from 7 the page number loose their position. Sometimes the are
butted up against the left hand text. Other times the are somewhere in
the middle of the line. 
        
        Any hints? Below is the basic code that I am using. 
        
        
         Private Shared Sub ToDocument(ByVal ti As TOCItem, ByVal d As
Document, ByVal f As Font, ByVal level As Integer) 
                If Not ti.Ignore Then 
                    Dim p As New Paragraph 
                    p.IndentationLeft = level * 20 
                    p.Add(New Phrase(ti.Value, f)) 
                    p.Add(New Chunk(New
iTextSharp.text.pdf.draw.DottedLineSeparator)) 
                    p.Add(New Chunk(ti.PageNumber, f)) 
                    d.Add(p) 
                    level += 1 
                End If 
        
                For Each k As String In ti.SubItems.Keys 
                    TOCItem.ToDocument(ti.SubItems(k), d, f, level) 
                Next 
            End
Sub---------------------------------------------------------------------
---------
        Increase Visibility of Your 3D Game App & Earn a Chance To Win
$500!
        Tap into the largest installed PC base & get more eyes on your
game by
        optimizing for Intel(R) Graphics Technology. Get started today
with the
        Intel(R) Software Partner Program. Five $500 cash prizes are up
for grabs.
        http://p.sf.net/sfu/intelisp-dev2dev
<http://p.sf.net/sfu/intelisp-dev2dev>
_______________________________________________
        iText-questions mailing list
        [email protected]
        https://lists.sourceforge.net/lists/listinfo/itext-questions
<https://lists.sourceforge.net/lists/listinfo/itext-questions> 
        
        Many questions posted to this list can (and will) be answered
with a reference to the iText book: http://www.itextpdf.com/book/
<http://www.itextpdf.com/book/> 
        Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php
<http://itextpdf.com/themes/keywords.php>  
        

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to