←Select platform

Flip Method

Summary

Flips this page vertically.

Syntax
C#
C++/CLI
Python
public void Flip() 
public:  
   void Flip() 
def Flip(self): 
Remarks

This method changes the value of ViewPerspective based on the previous value.

Refer to Document Page Transformation for more information.

Example
C#
Java
using Leadtools.Document; 
using Leadtools.Document.Converter; 
using Leadtools.Document.Writer; 
 
 
public void DocumentPageRotateExample() 
{ 
   var documentUri = new Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf"); 
   string documentFile = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"); 
 
   // Load this document 
   var loadDocumentOptions = new LoadDocumentOptions(); 
   using (var document = DocumentFactory.LoadFromUri(documentUri, loadDocumentOptions)) 
   { 
      // Documents are read-only by default and we cannot modify them. Fix that 
      document.IsReadOnly = false; 
 
      DocumentPage page; 
 
      // This document has 5 pages 
 
      // Rotate the page by 90 degrees clockwise 
      page = document.Pages[0]; 
      page.Rotate(90); 
      // Flip the second page vertically 
      page = document.Pages[1]; 
      page.Flip(); 
      // Delete the third page 
      page = document.Pages[2]; 
      page.IsDeleted = true; 
      // Reverse the fourth page 
      page = document.Pages[3]; 
      page.Reverse(); 
 
      // Set the view perspective 
      page.ViewPerspective = Leadtools.RasterViewPerspective.TopLeft; 
 
      // we will save it as a new PDF, this file should contain 4 pages with the first rotated by 90 and the second flipped vertically 
      using (var documentConverter = new DocumentConverter()) 
      { 
         var jobData = new DocumentConverterJobData(); 
         // The loaded document is our input 
         jobData.Document = document; 
         // We want PDF as output 
         jobData.DocumentFormat = DocumentFormat.Pdf; 
         // Into this file 
         jobData.OutputDocumentFileName = documentFile; 
 
         var job = documentConverter.Jobs.CreateJob(jobData); 
         documentConverter.Jobs.RunJob(job); 
      } 
   } 
 
   // Show the result 
   Process.Start(documentFile); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.util.concurrent.ExecutorService; 
import java.util.concurrent.Executors; 
 
import static org.junit.Assert.assertTrue; 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
 
import leadtools.LTLibrary; 
import leadtools.Platform; 
import leadtools.RasterDefaults; 
import leadtools.RasterViewPerspective; 
import leadtools.codecs.RasterCodecs; 
import leadtools.document.*; 
import leadtools.document.converter.*; 
import leadtools.document.writer.DocumentFormat; 
 
 
public void documentPageRotateExample() throws IOException, URISyntaxException { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
   Platform.loadLibrary(LTLibrary.DOCUMENT_WRITER); 
   URI documentUri = new URI("https://demo.leadtools.com/images/pdf/leadtools.pdf"); 
   String documentFile = combine(LEAD_VARS_IMAGES_DIR, "PagesModified.pdf"); 
   int availableProcessors = Runtime.getRuntime().availableProcessors(); 
   ExecutorService pool = Executors.newFixedThreadPool(availableProcessors); 
   RasterDefaults.setExecutorService(pool); 
 
   // Load this document 
   LoadDocumentOptions loadDocumentOptions = new LoadDocumentOptions(); 
   LEADDocument document = DocumentFactory.loadFromUri(documentUri, loadDocumentOptions); 
 
   // Documents are read-only by default and we cannot modify them. Fix that 
   document.setReadOnly(false); 
   DocumentPage page; 
 
   // Rotate the page by 90 degrees clockwise 
   page = document.getPages().get(0); 
   page.rotate(90); 
 
   // Flip the second page vertically 
   page = document.getPages().get(1); 
   page.flip(); 
 
   // Delete the third page 
   page = document.getPages().get(2); 
   page.setDeleted(true); 
 
   // Reverse the fourth page 
   page = document.getPages().get(3); 
   page.reverse(); 
 
   // Set the view perspective 
   page.setViewPerspective(RasterViewPerspective.TOP_LEFT); 
 
   // We will save it as a new PDF, this file should contain 4 pages with the first 
   // rotated by 90 and the second flipped vertically 
   DocumentConverter documentConverter = new DocumentConverter(); 
   DocumentConverterJobData jobData = new DocumentConverterJobData(); 
 
   // The loaded document is our input 
   jobData.setDocument(document); 
 
   // We want PDF as output 
   jobData.setDocumentFormat(DocumentFormat.PDF); 
 
   // Into this file 
   jobData.setOutputDocumentFileName(documentFile); 
   DocumentConverterJob job = documentConverter.getJobs().createJob(jobData); 
   documentConverter.getJobs().runJob(job); 
 
   // Show the result 
   if (job.getErrors().isEmpty()) { 
      System.out.println("Converted successfully to " + documentFile); 
   } else { 
      for (DocumentConverterJobError e : job.getErrors()) 
         System.out.println(e.getError()); 
   } 
 
   document.dispose(); 
   documentConverter.dispose(); 
 
   System.out.println("Document pages modified and saved to: " + documentFile); 
   assertTrue(job.getErrors().isEmpty()); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.