PdfDictionary p = reader.GetPageN(page);
Rectangle rect = reader.GetPageSize(page);
rect.Top = rect.Top + 2 * iTotalAreaAdded;
rect.Right = rect.Right + 2 * iTotalAreaAdded;
p.Put(PdfName.MEDIABOX, new PdfRectangle(rect));
p.Put(PdfName.CROPBOX, new PdfRectangle(rect));
p.Put(PdfName.TRIMBOX, new PdfRectangle(rect));
p.Put(PdfName.ARTBOX, new PdfRectangle(rect));
p.Put(PdfName.BLEEDBOX, new PdfRectangle(rect));
byte[] b = reader.GetPageContent(page);
PdfContentByte cb = new PdfContentByte(null);
cb.ConcatCTM(1,0,0,1,iTotalAreaAdded,iTotalAreaAdded);
cb.InternalBuffer.Append(b);
reader.SetPageContent(page, cb.InternalBuffer.ToByteArray());
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Dean Krueger
> Sent: Wednesday, September 17, 2008 6:47 PM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] PdfContentByte
>
> Hi Paulo
> Could you show me in code? Or point out in the itext book, where I
> might look for an example? Here is what I have code wise for adding
> the space.
>
> private void AddSpace(){
> for(int page = 1;page<=reader.NumberOfPages;page++){
> PdfDictionary p = reader.GetPageN(page); //do it
> for each page
> Rectangle rect = reader.GetPageSize(page);
> rect.Top = rect.Top + iTotalAreaAdded;
> rect.Bottom = rect.Bottom - iTotalAreaAdded;
> rect.Left = rect.Left - iTotalAreaAdded;
> rect.Right = rect.Right + iTotalAreaAdded;
>
> p.Put(PdfName.MEDIABOX, new PdfRectangle(rect));
> p.Put(PdfName.CROPBOX, new PdfRectangle(rect));
> p.Put(PdfName.TRIMBOX, new PdfRectangle(rect));
> p.Put(PdfName.ARTBOX, new PdfRectangle(rect));
> p.Put(PdfName.BLEEDBOX, new PdfRectangle(rect));
> p.Put(PdfName.BBOX, new PdfRectangle(rect));
>
> }
>
> PdfStamper stamper = new PdfStamper(reader, new
> FileStream(sDestinationTempPath,FileMode.Create));
> stamper.Close();
> }
>
>
> Thanks
> Dean
>
> On Thu, Sep 11, 2008 at 2:04 PM, Paulo Soares
> <[EMAIL PROTECTED]> wrote:
> > Apply 72 to the top and right of the rectangle and a
> translation transformation on the content stream. The
> transformation is (1,0,0,1,36,36).
> >
> > Paulo
> >
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED]
> >> [mailto:[EMAIL PROTECTED] On
> >> Behalf Of Dean Krueger
> >> Sent: Thursday, September 11, 2008 6:56 PM
> >> To: Post all your questions about iText here
> >> Subject: Re: [iText-questions] PdfContentByte
> >>
> >> Is there way to reset them back to zero and keep the new
> dimension? So
> >> that the boxes are 0,0, hight, width?
> >>
> >> Dean
> >>
> >> On Thu, Sep 11, 2008 at 1:21 PM, Paulo Soares
> >> <[EMAIL PROTECTED]> wrote:
> >> > The new bottom left position is rect.getLeft(),
> >> rect.getBottom(). These are probably negative.
> >> >
> >> > Paulo
> >> >
> >> >> -----Original Message-----
> >> >> From: [EMAIL PROTECTED]
> >> >> [mailto:[EMAIL PROTECTED] On
> >> >> Behalf Of Dean Krueger
> >> >> Sent: Thursday, September 11, 2008 6:14 PM
> >> >> To: [email protected]
> >> >> Subject: [iText-questions] PdfContentByte
> >> >>
> >> >> Hi,
> >> >> When using a PdfContentByte how can I tell it which box
> >> to use for a
> >> >> starting position? What box does it use by default? I have
> >> a pdf that
> >> >> when using PdfContentByte for putting text on the pdf,
> starts way
> >> >> higher than the 10 pts I tell it to start at. The art,
> >> bleed, media,
> >> >> trim and bbox on those files are set to the size of the
> >> doc. Here is
> >> >> some of the code.
> >> >>
> >> >> The document I am using is one, that I increased the size
> >> of using a
> >> >> PdfStamper in my past question. This how I am setting the box's.
> >> >>
> >> >> p.Put(PdfName.MEDIABOX, new PdfRectangle(rect));
> >> >> p.Put(PdfName.CROPBOX, new PdfRectangle(rect));
> >> >> p.Put(PdfName.TRIMBOX, new PdfRectangle(rect));
> >> >> p.Put(PdfName.ARTBOX, new PdfRectangle(rect));
> >> >> p.Put(PdfName.BLEEDBOX, new PdfRectangle(rect));
> >> >> p.Put(PdfName.BBOX, new PdfRectangle(rect));
> >> >> --------------------------------------------------------------
> >> >> -------------------------
> >> >>
> >> >> cContentByteStream.BeginText();
> >> >> cContentByteStream.SetTextMatrix(172, 10);
> >> >> cContentByteStream.SetCMYKColorFill(255, 255, 255, 255);
> >> >> cContentByteStream.ShowText(TimeStamp());
> >> >> cContentByteStream.EndText();
> >> >>
> >> >> Thanks
> >> >> Dean Krueger
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php