> -----Original Message-----
> From: Leonard Rosenthol [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 02, 2002 16:27
> To:   Paulo Soares; [EMAIL PROTECTED]
> Subject:      RE: [iText-questions] iText design question
> 
> At 10:51 AM +0100 5/2/02, Paulo Soares wrote:
> >  > 1) Why the are two different types of low level PDF objects?
> >>  PRObject vs. PDFObject, etc.
> >>
> >     The original objects (PdfObject) where designed to output PDF and as
> >such contain additional information that cannot be extracted from the
> read
> >pdf. The case of PdfString/PRString is paradigmatic. A PdfString contains
> a
> >Unicode string and an encoding. When this object is output to the pdf the
> >string is converted to a byte array depending on the encoding. The
> PRString
> >contains only a byte array disguised as a string that when output to the
> pdf
> >is only converted with direct byte casting. It's impossible to know what
> was
> >the original encoding. PdfStream contains the entire stream and PRStream
> >contains pointers to the file to save memory space. At the time this was
> >what I thought was the straightforward way to do things, maybe something
> can
> >be merged and changed to have an unified approach.
> 
>       And it looks like there is a simple/transparent conversion 
> between the two using the getPdfObject method of PdfReader.  As such, 
> that's fine since as I improve/enhance the pdfReader, I'll keep 
> working with the PR objects and just make sure to convert them to the 
> PdfObjects on their back to the caller.
> 
> 
> >  > 2) Why are both these sets of objects private to their package,
> >>  thereby disallowing "low level" access to applications?
> >>
> >     This was essentially to protect the user from doing wrong things.
> >The structure of iText also doesn't allow to generate an arbitrary
> document
> >like PJ so it wasn't very important to expose the classes.
> 
>       Right.   But that's exactly what I am trying to do - give 
> iText capabilities ala PJ.  As such, I now need those PdfObjects 
> exposed...
> 
> 
> >     For me they can all be public. I'm preparing a new release with
> >shading patterns and I'll make those classes public. I'll also see if
> some
> >of the PRObject can be eliminated and merged with the PdfObject.
> >
> 
>       Let's leave the two sets of classes, and just publicly expose 
> the PdfObjects.  I think that's a better approach for now.
> 
        I'm transforming the PRObjects in PdfObjects. It turns out that most
of the initial restriction were not real or could be circumvented with small
changes in the PdfObjects. The only problem is PRStream that doesn't really
have the stream inside, only pointers to the data and I don't know if it's
wise to open up, decompress and store in memory the stream when most of the
time this is not needed. On the other hand if you are doing stream
manipulation this work will have to be done. It probably needs a mixed mode
to be discussed later.

>       Can't wait to see shading patterns!   How many of the 
> different types did you do?  I found that the simple linear and 
> radial gradients were pretty easy to implement - but the more complex 
> ones just required too many programmatic values to be viable.
> 
        Well, I'm supporting all types but the problem of too many values
remain. It's doable but I suspect that type 4 and bigger were created for
the benefit of Photoshop. Just to give you a flavor of the implementation
here's the type 3 example from the pdf reference 1.3.

        import java.awt.Color;
        import java.io.*;
        import com.lowagie.text.*;
        import com.lowagie.text.pdf.*;

        public class shading {

            public static void main(String[] args) {
                Document document = new Document(PageSize.A4, 50, 50, 50,
50);
                Document.compress = false;
                try {
                    PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("c:\\shading.pdf"));
                    document.open();

                    PdfFunction function1 = PdfFunction.type2(writer, new
float[]{0, 1}, null,
                        new float[]{.929f, .357f, 1, .298f}, new
float[]{.631f, .278f, 1, .027f}, 1.048f);
                    PdfFunction function2 = PdfFunction.type2(writer, new
float[]{0, 1}, null,
                        new float[]{.929f, .357f, 1, .298f}, new
float[]{.941f, .4f, 1, .102f}, 1.374f);
                    PdfFunction function3 = PdfFunction.type3(writer, new
float[]{0, 1}, null,
                        new PdfFunction[]{function1, function2}, new
float[]{.708f}, new float[]{1, 0, 0, 1});
                    PdfShadingPattern shading =
PdfShadingPattern.type3(writer, new CMYKColor(0, 0, 0, 0),
                        new float[]{0, 0, .096f, 0, 0, 1}, null, function3,
new boolean[]{true, true});
                    
                    PdfContentByte cb = writer.getDirectContent();
                    cb.moveTo(316.789f, 140.311f);
                    cb.curveTo(303.222f, 146.388f, 282.966f, 136.518f,
279.122f, 121.983f);
                    cb.lineTo(277.322f, 120.182f);
                    cb.curveTo(285.125f, 122.688f, 291.441f, 121.716f,
298.156f, 119.386f);
                    cb.lineTo(336.448f, 119.386f);
                    cb.curveTo(331.072f, 128.643f, 323.346f, 137.376f,
316.789f, 140.311f);
                    cb.clip();
                    cb.newPath();
                    cb.saveState();
                    cb.concatCTM(27.7843f, 0, 0, -27.7843f, 310.2461f,
121.1521f);
                    cb.paintShading(shading);
                    cb.restoreState();
                    document.close();
                    System.out.println("The End");
                }
                catch (Exception de) {
                    de.printStackTrace();
                }
            }
        }

> Leonard
> -- 
> --------------------------------------------------------------------------
> -
> Leonard Rosenthol
> <mailto:[EMAIL PROTECTED]>
> Chief Technical Officer                      <http://www.pdfsages.com>
> PDF Sages, Inc.                              215-629-3700 (voice)

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to