Java/PDF RTF/Viewer Preferences

Материал из Java эксперт
Перейти к: навигация, поиск

Viewer Preferences: DisplayDocTitle

   <source lang="java">

import java.io.FileOutputStream; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; public class ViewerPreferencesDisplayDocTitle {

 public static void main(String[] args) {
   Document document = new Document(PageSize.A6);
   try {
     PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ViewerPreferencesDisplayDocTitle.pdf"));
     writer.setViewerPreferences(PdfWriter.DisplayDocTitle);
     document.addTitle("This is the title.");
     document.open();
     document.add(new Paragraph( "text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ", new Font(Font.HELVETICA, 12)));
   } catch (Exception de) {
     de.printStackTrace();
   }
   document.close();
 }

}

      </source>
   
  
 
  



Viewer Preferences: HideMenubarHideToolbar

   <source lang="java">

import java.io.FileOutputStream; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; public class ViewerPreferencesHideMenubarHideToolbar {

 public static void main(String[] args) {
   Document document = new Document(PageSize.A6);
   try {
     PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ViewerPreferencesHideMenubarHideToolbar.pdf"));
     writer.setViewerPreferences(PdfWriter.HideMenubar | PdfWriter.HideToolbar);
     document.addTitle("This is the title.");
     document.open();
     document.add(new Paragraph( "text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ", new Font(Font.HELVETICA, 12)));
   } catch (Exception de) {
     de.printStackTrace();
   }
   document.close();
 }

}

      </source>
   
  
 
  



Viewer Preferences: PageLayoutTwoColumnLeft

   <source lang="java">

import java.io.FileOutputStream; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; public class ViewerPreferencesPageLayoutTwoColumnLeft {

 public static void main(String[] args) {
   Document document = new Document(PageSize.A6);
   try {
     PdfWriter writer1 = PdfWriter.getInstance(document, new FileOutputStream("ViewerPreferencesPageLayoutTwoColumnLeft.pdf"));
     writer1.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);
     document.addTitle("This is the title.");
     document.open();
     document.add(new Paragraph( "text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ", new Font(Font.HELVETICA, 12)));
   } catch (Exception de) {
     de.printStackTrace();
   }
   document.close();
 }

}

      </source>
   
  
 
  



Viewer Preferences: PageLayout, TwoColumnRight, PageModeFullScreen, NonFullScreen, PageModeUseThumbs

   <source lang="java">

import java.io.FileOutputStream; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; public class ViewerPreferencesPageLayoutTwoColumnRightPageModeFullScreenNonFullScreenPageModeUseThumbs {

 public static void main(String[] args) {
   Document document = new Document(PageSize.A6);
   try {
     PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ViewerPreferencesPageLayoutTwoColumnRightPageModeFullScreenNonFullScreenPageModeUseThumbs.pdf"));
     writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnRight | PdfWriter.PageModeFullScreen | PdfWriter.NonFullScreenPageModeUseThumbs);
     document.addTitle("This is the title.");
     document.open();
     document.add(new Paragraph( "text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ", new Font(Font.HELVETICA, 12)));
   } catch (Exception de) {
     de.printStackTrace();
   }
   document.close();
 }

}

      </source>
   
  
 
  



Viewer Preferences: PrintScalingNone

   <source lang="java">

import java.io.FileOutputStream; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; public class ViewerPreferencesPrintScalingNone {

 public static void main(String[] args) {
   Document document = new Document(PageSize.A6);
   try {
     PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ViewerPreferencesPrintScalingNone.pdf"));
     writer.setViewerPreferences(PdfWriter.PrintScalingNone);
     document.addTitle("This is the title.");
     document.open();
     document.add(new Paragraph( "text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ", new Font(Font.HELVETICA, 12)));
   } catch (Exception de) {
     de.printStackTrace();
   }
   document.close();
 }

}

      </source>