Heh, I like the way you guys think! But how the heck are you seeing that text? What I see is compressed.
Anyway, I first tried an idea stemmed from the other email and assigned the font in use to the chunk that is containing the DottedLineSeperator. Hoping that would give it the proper glyph spacing. While when viewed in pitstop I did notice that the selection of the page number text does now correlate with where the text is viewed at. However, it did not fix the problem with using other versions or rips. Next I tried the white dot trick below, that didn't seem to do it either. But the method calls used were a little different than below but I am just guessing that is due to the .net port being slightly different in it's naming. I updated from 5.0.2 to 5.0.5 and created this quick test run below and get the attached resulting output (yeah yeah , I know, it's VB. Sorry). Current;y as a work around I am doing a method that uses getWidthPoint on three chunks while increment the middle one in a loop until the full width is correct and then drawing the line on the middle one as a generic tag. Not as pretty looking and it really slows the process down when it gets to the index at the back of the book. Oh well. I do appreciate the help though. I think you guys know the internals of PDF's better than Adobe :-) Sub Main() Dim d As New Document Dim w As PdfWriter = PdfWriter.GetInstance(d, New FileStream( "c:\DottedLineSeperatorTest.pdf", FileMode.Create)) d.Open() w.Open() With w.DirectContent .SaveState() .BeginText() .SetFontAndSize(BaseFont.CreateFont, 1) .SetColorFill(BaseColor.WHITE) .ShowText(".") .EndText() .RestoreState() End With Dim f As Font = FontFactory.GetFont(BaseFont.HELVETICA, 12) For i As Integer = 1 To 30 Dim p As New Paragraph("line " & i, f) Dim c As New Chunk(New iTextSharp.text.pdf.draw. DottedLineSeparator) c.Font = f p.Add(c) p.Add(New Chunk(i, f)) d.Add(p) Next d.Close() w.Close() End Sub ________________________________________________________________________________________ Jason Leland Pelzel | Digital Print IT | RR Donnelley 5500 12th Avenue East | Shakopee, MN 55337 | (: 952.833.3473 | È: 651.398.6188 | Ê: 952.942.8933 | *: jason.l.pel...@rrd.com "Mark Storer" <msto...@autonomy.com> 12/02/2010 11:16 AM Please respond to Post all your questions about iText here <itext-questions@lists.sourceforge.net> To "Post all your questions about iText here" <itext-questions@lists.sourceforge.net> cc Subject Re: [iText-questions] Help with DottedLineSeperator. 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: jason.l.pel...@rrd.com [mailto:jason.l.pel...@rrd.com] 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 | *: jason.l.pel...@rrd.com "Mark Storer" <msto...@autonomy.com> 12/01/2010 10:51 AM Please respond to Post all your questions about iText here <itext-questions@lists.sourceforge.net> To "Post all your questions about iText here" <itext-questions@lists.sourceforge.net> 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:jason.l.pel...@rrd.com] Sent: Tuesday, November 30, 2010 1:44 PM To: iText-questions@lists.sourceforge.net 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 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net 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 ------------------------------------------------------------------------------ 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 iText-questions@lists.sourceforge.net 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
DottedLineSeperatorTest.pdf
Description: Binary data
DottedLineSeperatorTest_opt.pdf
Description: Binary data
------------------------------------------------------------------------------ What happens now with your Lotus Notes apps - do you make another costly upgrade, or settle for being marooned without product support? Time to move off Lotus Notes and onto the cloud with Force.com, apps are easier to build, use, and manage than apps on traditional platforms. Sign up for the Lotus Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net 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