Title: RE: [iText-questions] Problem with PdfStamper for Version 128

It's a very big bug. Fix in PdfReader:

    public byte[] getPageContent(int pageNum, RandomAccessFileOrArray file) throws IOException{
        PdfDictionary page = getPageN(pageNum);
        if (page == null)
            return null;
        PdfObject contents = getPdfObject(page.get(PdfName.CONTENTS));
        if (contents == null)
            return new byte[0];
        ByteArrayOutputStream bout = null;
        if (contents.isStream()) {
            return getStreamBytes((PRStream)contents, file);
        }
        else if (contents.isArray()) {
            PdfArray array = (PdfArray)contents;
            ArrayList list = array.getArrayList();
            bout = new ByteArrayOutputStream();
            for (int k = 0; k < list.size(); ++k) {
                PdfObject item = getPdfObject((PdfObject)list.get(k));
                if (item == null || !item.isStream()) //here's the ERROR
                    continue;
                byte[] b = getStreamBytes((PRStream)item, file);
                bout.write(b);
                if (k != list.size() - 1)
                    bout.write('\n');
            }
            return bout.toByteArray();
        }
        else
            return new byte[0];
    }

Best Regards,
Paulo Soares

    -----Original Message-----
    From:   wang yun [SMTP:[EMAIL PROTECTED]
    Sent:   Friday, February 06, 2004 20:14
    To:     Paulo Soares
    Subject:        RE: [iText-questions] Problem with PdfStamper for Version 128

    Dear Paulo,

    The attached GovFormSig_comma.pdf is the input file
    while out.pdf is the result file.

    Thanks for your help,

    yun wang






    import java.io.*;
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    import com.sun.java.util.collections.*;

    public class Class1 {
       
        public static void main(String[] args) {

            try
                    {
                    
                    // Get a from from a reader
                            PdfReader reader = new PdfReader( args[0] );
                   
                            PdfStamper stamp = new PdfStamper(reader, new
    FileOutputStream("out.pdf") );
                            PdfContentByte cb = stamp.getUnderContent(1);
                                                           
                            stamp.close();
                           
                    }
            catch (Exception e) {
                e.printStackTrace();
            }
        }

    }  




    --- Paulo Soares <[EMAIL PROTECTED]> wrote:
    > Send me your pdf.
    >
    > Best Regards,
    > Paulo Soares
    >
    > > -----Original Message-----
    > > From:       [EMAIL PROTECTED]
    > [SMTP:[EMAIL PROTECTED]
    > On Behalf Of wang yun
    > > Sent:       Friday, February 06, 2004 15:57
    > > To: [EMAIL PROTECTED]
    > > Subject:    [iText-questions] Problem with PdfStamper
    > for Version 128
    > >
    > > Dear Support,
    > >
    > > I am moving from Vesion 127 to 128 using VJ6.0.
    > >
    > > I have the following code:
    > > 
    > > // Get a from from a reader
    > > PdfReader reader = new PdfReader( args[0] );
    > > PdfStamper stamp = new PdfStamper(reader, new
    > > FileOutputStream("out.pdf") );
    > > PdfContentByte cb = stamp.getUnderContent(1);
    > > stamp.close();
    > >
    > >
    > > IT worked on 127. But on 128, the first page can
    > not
    > > be copied. I got a white page on the first page
    > while
    > > the second page is OK.
    > >
    > > I don't know why.
    > >
    > > Thanks for help,
    > >
    > > yun wang
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    >
    -------------------------------------------------------
    > > The SF.Net email is sponsored by EclipseCon 2004
    > > Premiere Conference on Open Tools Development and
    > Integration
    > > See the breadth of Eclipse activity. February 3-5
    > in Anaheim, CA.
    > > http://www.eclipsecon.org/osdn
    > > _______________________________________________
    > > iText-questions mailing list
    > > [EMAIL PROTECTED]
    > >
    >
    https://lists.sourceforge.net/lists/listinfo/itext-questions
    >  << File: GovFormSig_comma.pdf >>  << File: out.pdf >>

Reply via email to