←Select platform

ImageOverText Property

Summary
Indicates whether to use a raster image overlay on top of the resulting PDF document.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool ImageOverText {get; set;} 
@property (nonatomic, assign) BOOL imageOverText; 
public boolean getImageOverText()  
public void setImageOverText(boolean imageOverText) 
public: 
property bool ImageOverText { 
   bool get(); 
   void set (    bool ); 
} 
ImageOverText # get and set (PdfDocumentOptions) 

Property Value

true to use a raster image overlay on top of the resulting PDF document; otherwise, false. The default value is false.

Remarks

PdfDocumentOptions.ImageOverText is used when creating a searchable PDF document that is required to look the same as the original. When true, an image of the original file will be saved over the entire PDF document as an overlay. When using the resulting document in a PDF viewer, you can still search the text underneath the overlay image and still maintain the look of the original document.

The DocumentWriter.AddPage method and the DocumentWriterPage structure provide more information on how to create a PDF file that uses overlay images.

Use the ImageOverTextSize property to control the quality of the overlay image.

Use the ImageOverTextMode property to control if and how grayscale images are treated in the final document.

Use CodecsPdfLoadOptions.DropImageOverText to control whether the overlay image is dropped when loading the PDF page as a raster or an SVG image.

Example
C#
Java
using Leadtools.Document.Writer; 
using Leadtools.Ocr; 
using Leadtools; 
using Leadtools.Codecs; 
 
 
public void PdfDocumentOptionsExample() 
{ 
   var inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "test.docx"); 
   var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf"); 
 
   // Setup a new RasterCodecs object 
   var codecs = new RasterCodecs(); 
   codecs.Options.RasterizeDocument.Load.Resolution = 300; 
 
   // Get the number of pages in the input document 
   var pageCount = codecs.GetTotalPages(inputFileName); 
 
   // Create a new instance of the LEADTOOLS Document Writer 
   var docWriter = new DocumentWriter(); 
 
   // Change the PDF options 
   var pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; 
   pdfOptions.DocumentType = PdfDocumentType.Pdf; 
   pdfOptions.FontEmbedMode = DocumentFontEmbedMode.None; 
   pdfOptions.ImageOverText = false; 
   pdfOptions.Linearized = false; 
   pdfOptions.Title = "Add your title here"; 
   pdfOptions.Subject = "Add your subject here"; 
   pdfOptions.Keywords = "Add your keywords here"; 
   pdfOptions.Author = "Add author name here"; 
   pdfOptions.Protected = true; 
   pdfOptions.UserPassword = "User password"; 
   pdfOptions.OwnerPassword = "Owner password"; 
   pdfOptions.EncryptionMode = PdfDocumentEncryptionMode.RC128Bit; 
   pdfOptions.PrintEnabled = false; 
   pdfOptions.HighQualityPrintEnabled = true; 
   pdfOptions.CopyEnabled = false; 
   pdfOptions.EditEnabled = true; 
   pdfOptions.AnnotationsEnabled = true; 
   pdfOptions.AssemblyEnabled = false; 
   pdfOptions.OneBitImageCompression = OneBitImageCompressionType.Flate; 
   pdfOptions.ColoredImageCompression = ColoredImageCompressionType.FlateJpeg; 
   pdfOptions.QualityFactor = 2; 
 
   // Use default resolution 
   pdfOptions.DocumentResolution = 0; 
   pdfOptions.PageRestriction = DocumentPageRestriction.Relaxed; 
 
   // Setup empty page size (Letter size) 
   pdfOptions.EmptyPageWidth = 8.5; 
   pdfOptions.EmptyPageHeight = 11; 
   pdfOptions.EmptyPageResolution = 300; 
 
   docWriter.SetOptions(DocumentFormat.Pdf, pdfOptions); 
 
   // Create a new PDF document 
   Debug.WriteLine("Creating new PDF document: {0}", outputFileName); 
   docWriter.BeginDocument(outputFileName, DocumentFormat.Pdf); 
 
   // Loop through all the pages 
   for (var pageNumber = 1; pageNumber <= pageCount; pageNumber++) 
   { 
      // Get the page as SVG 
      Debug.WriteLine("Loading page {0}", pageNumber); 
      var page = new DocumentWriterSvgPage(); 
      page.SvgDocument = codecs.LoadSvg(inputFileName, pageNumber, null); 
 
      // Add the page 
      Debug.WriteLine("Adding page {0}", pageNumber); 
      docWriter.AddPage(page); 
 
      page.SvgDocument.Dispose(); 
   } 
 
   // Finally finish writing the PDF file on disk 
   docWriter.EndDocument(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.document.writer.*; 
import leadtools.ocr.*; 
 
 
public void pdfDocumentOptionsExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
   String inputFileName = combine(LEAD_VARS_IMAGES_DIR, "LEADTOOLSEditor.docx"); 
   String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "Example.pdf"); 
 
   // Setup a new RasterCodecs object 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.getOptions().getRasterizeDocument().getLoad().setResolution(300); 
 
   // Get the number of pages in the input document 
   int pageCount = codecs.getTotalPages(inputFileName); 
 
   // Create a new instance of the LEADTOOLS Document Writer 
   DocumentWriter docWriter = new DocumentWriter(); 
 
   // Change the PDF options 
   PdfDocumentOptions pdfOptions = (PdfDocumentOptions) docWriter.getOptions(DocumentFormat.PDF); 
   pdfOptions.setDocumentType(PdfDocumentType.PDF); 
   pdfOptions.setFontEmbedMode(DocumentFontEmbedMode.NONE); 
   pdfOptions.setImageOverText(false); 
   pdfOptions.setLinearized(false); 
   pdfOptions.setTitle("Add your title here"); 
   pdfOptions.setSubject("Add your subject here"); 
   pdfOptions.setKeywords("Add your keywords here"); 
   pdfOptions.setAuthor("Add author name here"); 
   pdfOptions.setProtected(true); 
   pdfOptions.setUserPassword("User password"); 
   pdfOptions.setOwnerPassword("Owner password"); 
   pdfOptions.setEncryptionMode(PdfDocumentEncryptionMode.RC128BIT); 
   pdfOptions.setPrintEnabled(false); 
   pdfOptions.setHighQualityPrintEnabled(true); 
   pdfOptions.setCopyEnabled(false); 
   pdfOptions.setEditEnabled(true); 
   pdfOptions.setAnnotationsEnabled(true); 
   pdfOptions.setAssemblyEnabled(false); 
   pdfOptions.setOneBitImageCompression(OneBitImageCompressionType.FLATE); 
   pdfOptions.setColoredImageCompression(ColoredImageCompressionType.FLATE_JPEG); 
   pdfOptions.setQualityFactor(2); 
 
   // Use default resolution 
   pdfOptions.setDocumentResolution(0); 
   pdfOptions.setPageRestriction(DocumentPageRestriction.RELAXED); 
 
   // Setup empty page size (Letter size) 
   pdfOptions.setEmptyPageWidth(8.5); 
   pdfOptions.setEmptyPageHeight(11); 
   pdfOptions.setEmptyPageResolution(300); 
 
   docWriter.setOptions(DocumentFormat.PDF, pdfOptions); 
 
   // Create a new PDF document 
   System.out.printf("Creating new PDF document: %s%n", outputFileName); 
   docWriter.beginDocument(outputFileName, DocumentFormat.PDF); 
 
   // Loop through all the pages 
   for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++) { 
 
      // Get the page as SVG 
      System.out.printf("Loading page %s%n", pageNumber); 
      DocumentWriterSvgPage page = new DocumentWriterSvgPage(); 
      page.setSvgDocument(codecs.loadSvg(inputFileName, pageNumber, null)); 
 
      // Add the page 
      System.out.printf("Adding page %s%n", pageNumber); 
      docWriter.addPage(page); 
 
      page.getSvgDocument().dispose(); 
   } 
 
   // Finally finish writing the PDF file on disk 
   docWriter.endDocument(); 
   codecs.dispose(); 
   System.out.println("no exceptions or errors. Program run successfully"); 
} 
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.Writer Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.