You don't need PdfWriter, all you need is PdfStamper. Don't worry with the toolbars 
for the moment.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Sugita Takashi [mailto:[EMAIL PROTECTED] 
> Sent: Friday, June 18, 2004 11:20 AM
> To: Paulo Soares; [EMAIL PROTECTED]
> Subject: RE: [iText-questions] Rotate Pages from existing PDF 
> file with watermark and text without manubar etc.
> 
> Hello,
>  I am sorry for my poor coding. I still have error when I execute it.
> The code is the following:
> 
> #################################################
> import java.util.*;
> import java.io.*;
> import com.lowagie.text.*;
> import com.lowagie.text.pdf.*;
> 
>       public class question
>       {
>               public static void main(String[] args) 
>               {
>                       try 
>                       {
>                               PdfReader reader = new 
> PdfReader("before.pdf");
> 
>                                 for (int k = 1; k <= 
> reader.getNumberOfPages(); ++k) {
>                                     
> reader.getPageN(k).put(PdfName.ROTATE, 
> new PdfNumber(90));
>                                 }
> 
>                               int n = reader.getNumberOfPages();
> 
>                               Rectangle psize = reader.getPageSize(1);
>                               float width = psize.width();
>                               float height = psize.height();
>   
>                               Document document = new 
> Document(psize, 50, 50, 50, 50);
> 
>                                 FileOutputStream fos = new 
> FileOutputStream("after.pdf");
> 
>                                 PdfWriter writer = 
> PdfWriter.getInstance(document, fos); 
> 
>                                 
> writer.setEncryption(PdfWriter.STRENGTH128BITS, null, null, 0);
>                                 
> writer.setViewerPreferences(PdfWriter.HideToolbar | 
> PdfWriter.HideMenubar | 
> PdfWriter.PageModeUseThumbs) ; 
> 
>                                 PdfStamper stp = new 
> PdfStamper(reader, 
> fos);
>                                 stp.close();
> 
>                               try 
>                               {
>                                         Image image = 
> Image.getInstance("Watermark.jpg");
>                                         float imageWidth = 
> image.plainWidth();
>                                         float imageHeight = 
> image.plainHeight(); 
> 
>                                         Watermark watermark = new 
> Watermark(image, (width - imageWidth) / 2, (height - 
> imageHeight) / 2);
>                                         document.add(watermark);
>                               }
>                               catch(Exception e) 
>                               {
>                                       System.out.println("Are 
> you sure you have the file 'watermark.jpg' in 
> the right path?");
>                               }
> 
>                               document.open();
> 
>                               PdfContentByte cb = 
> writer.getDirectContent();
>                               int i = 0;
> 
>                               while (i < n) 
>                               {
>                                       document.newPage();
>                                       i++;
>                                       PdfImportedPage page1 = 
> writer.getImportedPage(reader, i);
>                                       cb.addTemplate(page1, 0, 0);
> 
>                                       BaseFont bfHeader = 
> BaseFont.createFont("HeiseiMin-W3", 
> "UniJIS-UCS2-HW-H", false);
>                                       cb.beginText();
>                                       cb.setFontAndSize(bfHeader, 10);
>                                       
> cb.showTextAligned(PdfContentByte.ALIGN_CENTER, 
> "aaaaaaaaaaaaa", width 
> * 1 / 2, height - 20, 0);
>                                               cb.endText();
>                               }
>                               document.close();
>                       }
>                       catch (Exception e) 
>                       {
>                               e.printStackTrace();
>                       }
>               }
>       }
> #################################################
> 
> Thank you very, very much for your help. I really appreciate it.
> 
> Takashi Sugita.
> 
> 
> 
> >From: "Paulo Soares" <[EMAIL PROTECTED]>
> >To: "Sugita Takashi" 
> <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
> >Subject: RE: [iText-questions] Rotate Pages from existing 
> PDF file with 
> watermark and text without manubar etc.
> >Date: Fri, 18 Jun 2004 10:02:58 +0100
> >
> >What code are you using?
> >
> >Best Regards,
> >Paulo Soares
> >
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On
> > > Behalf Of Sugita Takashi
> > > Sent: Friday, June 18, 2004 5:32 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [iText-questions] Rotate Pages from existing PDF
> > > file with watermark and text without manubar etc.
> > >
> > > Hello,
> > >
> > >  I have a similar problem with Markus whose answer he got on
> > > April 30,
> > > 2004. (following mail.)
> > > I exactly have the same problem as he has.
> > > But in my case, I also would like to put watermark and a text
> > > on each page
> > > without showing menubar and toolbar of the acrobat reader.
> > > (the watermark and the text are the same on each page.)
> > >
> > >  When I used PdfStamper, I could rotate the existing PDF
> > > file, but the
> > > watermark or text cannot be seen, and the menubar and the
> > > toolbar of the
> > > acrobat reader can be seen.
> > >
> > >  Could anyone help me, please? Any help would be very
> > > appreciated. Thank
> > > you in advance.
> > >
> > > Takashi Sugita.
> > >
> > >
> > >
> > > Markus" answer he got on April 30, 2004.
> > > ######################################
> > >  ----- Original Message -----
> > >  From: "Paulo Soares" <[EMAIL PROTECTED]>
> > >  To: "= k3Rn =" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > >  Sent: Friday, April 30, 2004 1:27 PM
> > >  Subject: RE: [iText-questions] Rotate Pages from 
> existing PDF files
> > >
> > >
> > >  That"s dead easy.
> > >
> > >  PdfReader reader = new PdfReader(...);
> > >  for (int k = 1; k <= reader.getNumberOfPages(); ++k) {
> > >      reader.getPageN(k).put(PdfName.ROTATE, new PdfNumber(90));
> > >  }
> > >  PdfStamper stp = new PdfStamper(reader, ...);
> > >  stp.close();
> > >
> > >  Best Regards,
> > >  Paulo Soares
> > >
> > >  > -----Original Message-----
> > >  > From: [EMAIL PROTECTED]
> > >  > [mailto:[EMAIL PROTECTED] On
> > >  > Behalf Of = k3Rn =
> > >  > Sent: Thursday, April 29, 2004 7:03 PM
> > >  > To: [EMAIL PROTECTED]
> > >  > Subject: Re: [iText-questions] Rotate Pages from 
> existing PDF files
> > >  >
> > >  > From: "Bruno" <[EMAIL PROTECTED]>
> > >  > To: "= k3Rn =" <[EMAIL PROTECTED]>
> > >  > > Quoting = k3Rn = <[EMAIL PROTECTED]>:
> > >  > >
> > >  > > > I"d want to simply rotate all pages of an existing pdf
> > > 90 degrees
> > >  > > > to the right - from portait to landscape orientation.
> > >  > >
> > >  > > This can be done with iText.
> > >  > >
> > >  > > > In my case i would need that to rotate pdf pages 
> that are in
> > >  > > > portrait orientation, but the text is vertically
> > > printed (because
> > >  > > > it used to be a landscape printout).
> > >  > >
> > >  > > I"m not sure what you mean. If you say the pages are in
> > >  > > portrait now but people have to turn their heads 90 degrees
> > >  > > to read the text on a screen, then you can use iText.
> > >  >
> > >  > Thats exactly what i want to do.
> > >  > I"ll attach a small example pdf i would like to rotate.
> > >  > May you give me a hint on how complex the itext code would be
> > >  > to do that rotation? Can this be done in some rows of code?
> > >  >
> > >  > Thx for you support!
> > >  > Greetings
> > >  > Markus
> > >  >
> > > ######################################
> > >
> > > _________________________________________________________________
> > > メッセンジャーで総額1億円プレゼント! http://im.msn.co.jp/home.htm
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> > > Learn from the experts at JavaOne(SM), Sun's Worldwide 
> Java Developer
> > > Conference, June 28 - July 1 at the Moscone Center in San
> > > Francisco, CA
> > > REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority
> > > Code NWMGYKND
> > > _______________________________________________
> > > iText-questions mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/itext-questions
> > >
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> >Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> >Conference, June 28 - July 1 at the Moscone Center in San 
> Francisco, CA
> >REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority 
> Code NWMGYKND
> >_______________________________________________
> >iText-questions mailing list
> >[EMAIL PROTECTED]
> >https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> _________________________________________________________________
> メッセンジャーで総額1億円プレゼント! http://im.msn.co.jp/home.htm 
> 
> 


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to