Prepares this document for saving.
public void PrepareToSave()Public Sub PrepareToSave()public:void PrepareToSave()
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.
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.
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 namestring 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 annotationsvar converter = new DocumentConverter();// If we have an OCR engine, use itif (_ocrEngine != null)converter.SetOcrEngineInstance(_ocrEngine, false);var jobData = DocumentConverterJobs.CreateJobData(_documentViewer.Document,outputFileName,DocumentFormat.Pdf);// Embed the annotationsjobData.AnnotationsMode = DocumentConverterAnnotationsMode.Embed;// Create the jobvar job = converter.Jobs.CreateJob(jobData);// Run itconverter.Jobs.RunJob(job);if (job.Status != DocumentConverterJobStatus.Aborted){MessageBox.Show("Document created successfully");System.Diagnostics.Process.Start(outputFileName);}
Imports LeadtoolsImports Leadtools.ControlsImports Leadtools.DocumentsImports Leadtools.Documents.UIImports Leadtools.Documents.ConvertersImports Leadtools.CodecsImports Leadtools.CachingImports Leadtools.Annotations.CoreImports Leadtools.Annotations.AutomationImports Leadtools.Annotations.WinFormsImports Leadtools.Annotations.DesignersImports Leadtools.Forms.DocumentWritersImports Leadtools.Forms.Ocr' Ask for output file nameDim outputFileName As String = NothingUsing dlg As New SaveFileDialog()dlg.Filter = "PDF Files|*.pdf;|All Files|*.*"If dlg.ShowDialog() <> DialogResult.OK Then ReturnoutputFileName = dlg.FileNameEnd 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 annotationsDim converter As New DocumentConverter()' If we have an OCR engine, use itIf Not IsNothing(_ocrEngine) Thenconverter.SetOcrEngineInstance(_ocrEngine, False)End IfDim jobData As DocumentConverterJobData = DocumentConverterJobs.CreateJobData(_documentViewer.Document,outputFileName,DocumentFormat.Pdf)' Embed the annotationsjobData.AnnotationsMode = DocumentConverterAnnotationsMode.Embed' Create the jobDim job As DocumentConverterJob = converter.Jobs.CreateJob(jobData)' Run itconverter.Jobs.RunJob(job)If job.Status <> DocumentConverterJobStatus.Aborted ThenMessageBox.Show("Document created successfully")System.Diagnostics.Process.Start(outputFileName)End If
|
Products |
Support |
Feedback: PrepareToSave Method (DocumentViewer) - Leadtools.Documents.UI |
Introduction |
Help Version 19.0.2017.3.21
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.