Re: Paragraph and documentation

"jeffchimene" <jeff-CZn2F6e2yomE/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.pdfapi2
Message-ID <[email protected]>
--- In [email protected], "spinningwebz2002"
<spinningwebz2002@...> wrote:
>
> --- In [email protected], "Mr. Shawn H. Corey" 
> <shawnhcorey@> wrote:
> >
> > spinningwebz2002 wrote:
> > > Thanks for the info. In your other message I also saw the posting 
> > > about bold etc. I will just have to write routines that would 
> process 
> > > the paragraph using text_center, left etc. which would give me 
> more 
> > > control anyways.
> > > 
> > > While working with pdf::api2, what variables do I have access to 
> (is 
> > > there a list)?
> > 
> > You will find that $text->text(...) is the workhorse of PDF::API2. 
> > Every routine that prints (via the text object) uses this routine.
> > 
> > I'm not sure what you mean by variables.  PDF::API2 is object-
> oriented. 
> >   It helps if you know something about Perl objects.  There are a 
> lot of 
> > parameters but few variables (and you shouldn't touch them unless 
> you 
> > really, really know what you're doing).
> > 
> > 
> > -- 
> > Just my 0.00000002 million dollars worth,
> >     Shawn
> > 
> > "For the things we have to learn before we can do them, we learn by 
> > doing them."
> >    Aristotle
> >
> 
> Probably Variables is the wrong word. What I was thinking, if I have 
> to write routines to use the text->text for bold, italic etc, then it 
> would be necessary to know where the line ended so that the next 
> block of text would start after it.
> 
> For the time being I am using text->paragraph and setting it up so it 
> is only one line long, this way I get what was overflowed back and 
> then create the next line below it until all text is done displaying. 
> I did this so I can catch when I reach the bottom of the page and add 
> a new page. It will also allow me to do things like wrap text around 
> a photo, have varying line width etc. 
> 
> Ideally what I think I may end up doing is rewriting the text-
> >paragraph as my own routine that would catch simple html markup 
> (<B><I><U><UL> etc) in a line and handle it automatically.
> 
> One thing I notice is that it takes pdf::api2 a bit to get started, 
> is this due to the use strict;? If so, when my code is done can I 
> remove that to speed up the process? Or, will the pdf::api2 run under 
> mod_perl?
> 
> Bill H
>

Some thoughts:
o Investigate HTML::Parser. I use the results to create two stacks:
font and text. Then, in the rendering phase, I pop those stacks in a
coordinated way to match font and text. This lets me embed bold or
italic font in a single paragraph. PDF can do this, the issue is
getting that to work w/ PDF::API2.

o text->paragraph is subject to random breakage. I'd recommend
insulating yourself from "upgrades" by placing a working version into
a local module that declares itself to be part of package
PDF::API2::Content::Text I've been using PDF::API2 for at least 5 yrs.
now. I came up with this solution when text->paragraph "upgraded" a
few years ago in a way that wasn't backwards compatible.

o I've found the following logic to be quite stable
($idt, $base, @overflow) =
$col->jec_paragraph($layout{margin_left}+$layout{gutter_width}
                    , $base
		    , $layout{width_paragraph}
   		    , &$linect($base,$col->lead)
		    , $idt
		    , $cargo);
while ($#overflow != -1)
{	
  if (&$linect($base, $col->lead) <= 4) # Check lines remaining
	{
	&$newpage($col);
	$base -= $layout{size_default};
	}
   ($idt, $base, @overflow) = 
       $col->jec_paragraph(
             $layout{margin_left}+$layout{gutter_width}
             , $base
	     , $layout{width_paragraph}
	     , &$linect($base,$col->lead)
	     , $idt
	     , join(' ', @overflow));
	} # end while handling overflow text
} # end while processing all items with associated commentary
$base -= $layout{size_default};

o I determine end of page by dividing the current base by the current
leading. If the value is less than lines remaining, I create a new
page: $linect = sub { return abs(ceil($_[0] / $_[1]))};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.