Error processing SSI file
LEADTOOLS Leadtools.Documents.UI (Leadtools.Documents.UI assembly)

Show in webframe

PrepareToSave Method






Prepares this document for saving.
Syntax
public void PrepareToSave()
'Declaration
 
Public Sub PrepareToSave() 
'Usage
 
Dim instance As DocumentViewer
 
instance.PrepareToSave()
public:
void PrepareToSave(); 
Remarks

This method must be called before the Document currently in the viewer is saved or passed to a DocumentConverter instance for conversion to a new format.

The method will update all the data that might have been changed by the user including the text or annotations containers.

Example

Start with the example created in DocumentViewerAnnotations, remove all the code in the Example function and add the code below.

When the user clicks the Example button, the document is saved to a new PDF file.

Copy Code  
Imports Leadtools
      Imports Leadtools.Controls
      Imports Leadtools.Documents
      Imports Leadtools.Documents.UI
      Imports Leadtools.Documents.Converters
      Imports Leadtools.Codecs
      Imports Leadtools.Caching
      Imports Leadtools.Annotations.Core
      Imports Leadtools.Annotations.Automation
      Imports Leadtools.Annotations.WinForms
      Imports Leadtools.Annotations.Designers
      Imports Leadtools.Forms.DocumentWriters
      Imports Leadtools.Forms.Ocr

      ' Ask for output file name
      Dim outputFileName As String = Nothing
      Using dlg As New SaveFileDialog()
         dlg.Filter = "PDF Files|*.pdf;|All Files|*.*"
         If dlg.ShowDialog() <> DialogResult.OK Then Return
         outputFileName = dlg.FileName
      End Using
      ' Before we save, we must save any data being cached such as the annotations
      _documentViewer.PrepareToSave()

      ' If we have an OCR engine, use it
      ' Ready, use Document Converter to save the document with its annotations
      Dim converter As New DocumentConverter()
      ' If we have an OCR engine, use it
      If Not IsNothing(_ocrEngine) Then
         converter.SetOcrEngineInstance(_ocrEngine, False)
      End If

      Dim jobData As DocumentConverterJobData = DocumentConverterJobs.CreateJobData( _
         _documentViewer.Document, _
         outputFileName, _
         DocumentFormat.Pdf)
      ' Embed the annotations
      jobData.AnnotationsMode = DocumentConverterAnnotationsMode.Embed

      ' Create the job
      Dim job As DocumentConverterJob = converter.Jobs.CreateJob(jobData)

      ' Run it
      converter.Jobs.RunJob(job)

      If job.Status <> DocumentConverterJobStatus.Aborted Then
         MessageBox.Show("Document created successfully")
         System.Diagnostics.Process.Start(outputFileName)
      End If
   End Sub
End Class
using Leadtools;
   using Leadtools.Controls;
   using Leadtools.Documents;
   using Leadtools.Documents.UI;
   using Leadtools.Documents.Converters;
   using Leadtools.Codecs;
   using Leadtools.Caching;
   using Leadtools.Annotations.Core;
   using Leadtools.Annotations.Automation;
   using Leadtools.Annotations.WinForms;
   using Leadtools.Annotations.Designers;
   using Leadtools.Forms.DocumentWriters;
   using Leadtools.Forms.Ocr;

   // Ask for output file name
   string outputFileName = null;
   using (var dlg = new SaveFileDialog())
   {
      dlg.Filter = "PDF Files|*.pdf;|All Files|*.*";
      if (dlg.ShowDialog() != DialogResult.OK)
         return;
      outputFileName = dlg.FileName;
   }
   // Before we save, we must save any data being cached such as the annotations
   _documentViewer.PrepareToSave();

   // If we have an OCR engine, use it
   // Ready, use Document Converter to save the document with its annotations
   var converter = new DocumentConverter();
   // If we have an OCR engine, use it
   if (_ocrEngine != null)
      converter.SetOcrEngineInstance(_ocrEngine, false);

   var jobData = DocumentConverterJobs.CreateJobData(
      _documentViewer.Document,
      outputFileName,
      DocumentFormat.Pdf);
   // Embed the annotations
   jobData.AnnotationsMode = DocumentConverterAnnotationsMode.Embed;

   // Create the job
   var job = converter.Jobs.CreateJob(jobData);

   // Run it
   converter.Jobs.RunJob(job);

   if (job.Status != DocumentConverterJobStatus.Aborted)
   {
      MessageBox.Show("Document created successfully");
      System.Diagnostics.Process.Start(outputFileName);
   }
}
Requirements

Target Platforms

See Also

Reference

DocumentViewer Class
DocumentViewer Members

Error processing SSI file
Leadtools.Documents.UI requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features