Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-05-05 Thread 1T3XT info

Daniel Cane wrote:

On to a new challenge -- I'd like to have lists as part of one of the
columnTexts, but have learned that that's unsupported (and I even think I
understand why).


People who have been following this list for a long time,
know that I can react very frustrated at times.
Newbies often don't understand why I react that way.

This is a nice opportunity to explain the origin of this frustration.
You have learned that lists are unsupported in ColumnText.

Where have you learned this?
Who is spreading this kind of desinformation?
Why are you saying this.

In attachment, you can find a very simple example that proves
the opposite of what you've learned.

And more importantly: what is wrong with the documentation???

What is wrong with the second edition of the book that still causes 
misconceptions like this? There are still a couple of months left to 
find a remedy before the book goes to print.

--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info


column_list.pdf
Description: Adobe PDF document
import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.List;
import com.itextpdf.text.pdf.ColumnText;
import com.itextpdf.text.pdf.PdfWriter;


public class ColumnList {

public static void main(String[] args) throws IOException, 
DocumentException {

Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new 
FileOutputStream(column_list.pdf));
// step 3
document.open();
// step 4
ColumnText ct = new ColumnText(writer.getDirectContent());
List list = new List(List.ORDERED);
list.add(item 1);
list.add(item 2);
list.add(item 3);
ct.addElement(list);
ct.setSimpleColumn(36, 36, 559, 806);
ct.go();
// step 5
document.close();
}
}
--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-05-05 Thread Mike Marchywka

 Where have you learned this?
 Who is spreading this kind of desinformation?
 Why are you saying this.

 In attachment, you can find a very simple example that proves
 the opposite of what you've learned.

 And more importantly: what is wrong with the documentation???

 What is wrong with the second edition of the book that still causes
 misconceptions like this? There are still a couple of months left to
 find a remedy before the book goes to print.

Along the lines of your comments, I would guess the
problem would be someone has to read it. Now, before
you dismiss this as a pointless joke, I would just
consider it as Stating the obvious as this
often is a route to great discovery ( you needn't pat
me on the back at this point, I am doing so now).
Stating another obvious, we have computers.
With appropriately formetted electronic publications,
we have tools like grep to help us find what we need
with efficient use of resources. However, often
there is a problem with vocabulary and document
structure for the beginner wishing to become
familiar with a topic. Keywords don't help
if you don't know what they are, if there is
not document structure common word context
is hard to find. So, you can create neologisms
to make searching easier or in the electronic
docs create structure. fwiw.
While Leonard and others keep pointing out
that PDF has structural capabilities, everytime
someone asks here a question that
lends itself to use of these facilities, almost
unanimuous opinion is, sure its
possible but it is too complicated or
hard and no one would use it,
I can grep javadocs and have some idea
of context since the rendered html is
fairly uniform if not intended to be structured.
I can build my own indexes and remove common
words, reducing the time to learn
jargon etc.






  
_
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-05-05 Thread 1T3XT info
Mike Marchywka wrote:
 Along the lines of your comments, I would guess the
 problem would be someone has to read it. Now, before
 you dismiss this as a pointless joke, I would just
 consider it as Stating the obvious as this
 often is a route to great discovery ( you needn't pat
 me on the back at this point, I am doing so now).

Pat on your back anyway.
I think one of the problems is indeed that people start
coding before reading. Everybody thinks it's obvious
that one should have a driver's license before driving
a car, but maybe there should be something like a
driver's license before using a tool like iText ;-)

 Stating another obvious, we have computers.
 With appropriately formetted electronic publications,
 we have tools like grep to help us find what we need
 with efficient use of resources. However, often
 there is a problem with vocabulary and document
 structure for the beginner wishing to become
 familiar with a topic.

That's true. I think the problem of the OP is that
he isn't familiar with the concepts text mode vs
composite mode in ColumnText.

 Keywords don't help
 if you don't know what they are, if there is
 not document structure common word context
 is hard to find. So, you can create neologisms
 to make searching easier or in the electronic
 docs create structure. fwiw.
 While Leonard and others keep pointing out
 that PDF has structural capabilities, everytime
 someone asks here a question that
 lends itself to use of these facilities, almost
 unanimuous opinion is, sure its
 possible but it is too complicated or
 hard and no one would use it,

Note that there are examples in chapter 15 of the book,
explaining how to convert an ordinary PDF to plain text,
and how to convert a tagged PDF to an XML file.
That could be useful if you want to retrieve the content
of a PDF document.

--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-05-05 Thread Daniel Cane
1T3XT info info at 1t3xt.info writes:

 That's true. I think the problem of the OP is that
 he isn't familiar with the concepts text mode vs
 composite mode in ColumnText.

My friend - iText is truly amazing, and I support you!

(I have in fact purchased the MEAP version and did search it prior to posting). 

Sometimes google is not our friend. When I searched the book, the examples I

found had lists added to the document, but I did not see one added to a

ColumnText. 

When my initial attempt to simply

addText(paragraphContainingStuffIncludingLists) 

failed I googled for the failure

and found a posting - possibly outdated - which said, you can't do that.

So, I posted here. Forgive my n00biness - I did not mean to upset you by any 
means!

I'm reading up on Composite Mode now and it appears to be the answer. 

He doesn't know how to use the 3 seashells! 

   - Me in an obscure reference to Demolition Man  

Thank you ALL for creating a community for support.


--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-05-05 Thread 1T3XT info
Daniel Cane wrote:
 He doesn't know how to use the 3 seashells! 
 
- Me in an obscure reference to Demolition Man  

That would be a great quote for the book ;-)
Thanks for understanding.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-05-04 Thread Daniel Cane
1T3XT info info at 1t3xt.info writes:

 
 I would work with ColumnText.
 
 For the first page, I would add the first page of the template
 without the fields as the background of my new document.
 I would retrieve the positions of the fixed items, and put them
 on the page using ColumnText.
 
 Then I would create a ColumnText object for the unstructured content;
 I would add the unstructured content using paragraphs, tables,...
 I would also call go() on a regular basis. Whenever a new page is
 needed, I would add a new page with the second page of the template
 as background.


Brilliant,

I ended up using a PdfPageEventHelper to set the template to either first page,
or follow-up page types and then put my content into 2 columnText blocks (for
left and right sides of the page) - since either could be 1 page long.. 

Then I wrote a little block of code to continue to add pages so long as either
columnText had content still to write out:

do
{
int iLeftColHasMore = ct.go();
int iRightColHasMore = ctRight.go();

ct.setSimpleColumn(35.2716f, 105.56f, 137.131f, 704.298f, 12.0f,
Element.ALIGN_LEFT);
ctRight.setSimpleColumn(154.747f, 65.5776f, 577.704f, 703.88f, 12.0f,
Element.ALIGN_LEFT);

if (ColumnText.hasMoreText(iLeftColHasMore) ||
ColumnText.hasMoreText(iRightColHasMore))
{
document.newPage();
Phrase pageNumTitle = new Phrase();
pageNumTitle.add(new Chunk(Page  + iPageNumber, 
PDFNoteUtil.NOTETYPE));
setPageHeader(writer, document, pageNumTitle, 
veVisit.getPatient());
iPageNumber++;
}
}
while (ColumnText.hasMoreText(ct.go()) || ColumnText.hasMoreText(ctRight.go()));

Works GREAT! Thanks for all of your help.

On to a new challenge -- I'd like to have lists as part of one of the
columnTexts, but have learned that that's unsupported (and I even think I
understand why). But I can't seem to hack my way around it. I need the
columnText magic to span pages, but I'd like to take advantage of lists (and
images, etc)...

I can't seem to use any indentation voodoo on the inner paragraphs as well (they
all seem to be ignored when nested inside of CT?) I was thinking of trying to
use a negative indent to fake it, but can't make that work. 

So - how does one have a multipage spanning CT (or the like) and get to use/fake
numbered lists?

Thanks again.

Dan  


--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-04-28 Thread Giovanni Azua
Hello Daniel,

On Apr 28, 2010, at 1:32 AM, Daniel Cane wrote:
 Interesting - could you show me how you define your spot function? The idea of
 simply assembling a 'top' spot, 'left' spot and 'right' spot is appealing, but
 I'm a little lost on how to implement it. Are spots = paragraphs or templates 
 or
 what?
 
 Also, how would this work with a different header / footer on all pages after
 the first page? 
 
 I very much appreciate your suggestion!
 
The Spot is a class or better yet an enum type which has a corresponding stored 
configuration in your preferred configuration format e.g. xml, properties, txt 
etc. The client code can refer to Spots by the appropriate enum instance e.g. 

spot.properties:

TOP_LEFT=23,0,repeat
TOP_RIGHT=250,0,repeat
etc

the client code would look like this:

IBuilder builder = ...
builder.addPdfTemplate(Spot.TOP_LEFT,load(Parts.HEADER));

note that client code does not exactly know what TOP_LEFT details are ...
 
The Spot type could also have some sort of small gap constant value maybe also 
externalized in configuration which would support functions like this:
Spot.TOP_LEFT.right().right() so you would have finer control on the coordinate 
positions but again I would avoid any algorithm that moves things around 
because:
- complexity
- possible lose of predictability of the visual output

From all the ideas I thought of for implementing the layout, this was the 
simplest one ...

HTH,
Best regards,
Giovanni  

--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-04-28 Thread 1T3XT info
Daniel Cane wrote:
 The first page is somewhat more structured than the 
 subsequent pages as it has the patient history, etc. The secondary pages will 
 have any overflow from the first page and include images, etc. I would like 
 all 
 of the secondary pages to have a header, footer, and page number. 
 
 
 My first approach was attempting to create the page from scratch using 
 chunks, paragraphs, etc. This seems to give me a ton of control, but I find 
 myself tinkering (a ton) to get the layout to work. 

Correct.
Using the chunks and paragraphs are ideal to create the flow
of content (from your database), but not for the first page
where you probably have fixed items such as patient name,
birth date,...

 My second approach was to use the PdfStamper with form fields I drew in 
 Acrobat. The merge of the structured fields worked great, but I'm stuck with 
 the unstructured portion of the output getting cut off (since my template 
 is 
 only the first page). 

I would create a two page PDF with Acrobat.
I would use the first page of this template for the first page
of the new document, and the second page for all subsequent pages.
I would use fields to define small rectangles for the fixed items,
and a large rectangle for the unstructured content.

 Question - how can I / can I have a page 1 template, and then a page 2+ 

I would work with ColumnText.

For the first page, I would add the first page of the template
without the fields as the background of my new document.
I would retrieve the positions of the fixed items, and put them
on the page using ColumnText.

Then I would create a ColumnText object for the unstructured content;
I would add the unstructured content using paragraphs, tables,...
I would also call go() on a regular basis. Whenever a new page is
needed, I would add a new page with the second page of the template
as background.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-04-28 Thread Klas Lindbäck
I use page events and the decorator pattern for templates and page 
numbering.
I use template pdf:s for templates. A template pdf contains one or two 
pages
with the template (depending on if I have the same or different 
tempaltes for page one
and for subsequent pages).
If I have a separate template for page one I add it manually.
The decorators are typically added as listeners to the onPageEnd and 
onClose events.

The code has the following structure:

Create Document object and open it.
Load and add the first page template.
Add decorators (template, page numbering, test text).
Add pdf body (whatever you want to include in the pdf).
Close Document.

/Klas


--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-04-28 Thread KSXD 32
Hello,

Klas Lindbäck wrote:
 I use page events and the decorator pattern for templates and 
 page numbering. I use template pdf:s for templates. A template 
 pdf contains one or two pages with the template (depending on 
 if I have the same or different 
 [snip]

Nice. I have also thought about using Composite, having a top component 
interface IPdfElement to build compositions from and at many levels e.g. header 
could be a composite aggregating an Image on the left and PdfText in the 
center-right, and as you mention also have IPdfElement decorators. This IMO 
would provide an all-round design for building layouts too. The layout 
management would be simplified e.g place IPdfElement in relative coordinate 
position rather than absolute positions so the absolute positions would get 
resolved automatically from the containing component taking some predefined 
spacing/padding into account.

As I see it, the goal is basically to abstract from low level framework 
details as much as possible specially in setups like mine where the client 
code are business rules. I really need the simplest possible façade to build 
PDF documents.

Best regards,
Giovanni

==
Please access the attached hyperlink for an important electronic communications 
disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
== 

--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


Re: [iText-questions] Guidance Requested - Generating multipage output with header/footer and pg 1 layout

2010-04-27 Thread Giovanni Azua
Hello Daniel,

Please note that I am a relatively newbie with iText. I have been recently 
faced with similar questions as yours and this is my attempted solution ... 
perhaps it will give you some ideas.

On Apr 27, 2010, at 9:58 PM, Daniel Cane wrote:
 
 My first approach was attempting to create the page from scratch using 
 chunks, paragraphs, etc. This seems to give me a ton of control, but I find 
 myself tinkering (a ton) to get the layout to work. 
 
 

I define templates as simple as a list of coordinate points or hot spots or 
however you want to call them. These points are uniquely keyed by labels e.g. 
TOP_LEFT and they also have a recurrence flag i.e. repeat for all pages. So 
they look like Spot(x,y,TOP_LEFT,repeat). These coordinate tuples are defined 
manually once so that the visual appealingness is well known in advance and 
not computed on the fly by some algorithm where you could lose predictability 
of the visual output. 

Now that's all :) I then use the Builder Design pattern which is one of the few 
interfaces to client code with methods similar to e.g.

IBuilder#addPdfPart(Spot,IPdfPart)
IBuilder#addTable(Spot,ITable)
IBuilder#build()

my Layout Manager does not shift on the x axis but only on the y-axis and 
breaks onto new pages automatically. It also checks or will for overlapping.

This solution resolves the problem of having to deal with the combinatorial 
explosion of PDF templates to maintain ... you keep only metadata list of 
points as template.

HTH,
Best regards,
Giovanni
--
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/