Leadtools.Documents名前空間 > Documentクラス :SaveToFileメソッド |
public void SaveToFile( string fileName, SaveDocumentOptions options )
'Declaration
Public Sub SaveToFile( _ ByVal fileName As String, _ ByVal options As SaveDocumentOptions _ )
'Usage
Dim instance As Document Dim fileName As String Dim options As SaveDocumentOptions instance.SaveToFile(fileName, options)
public void saveToFile(String fileName, SaveDocumentOptions options)
public: void SaveToFile( String^ fileName, SaveDocumentOptions^ options )
外部ファイルまたはリモートURLにこのドキュメントをエクスポートするために、SaveToFileまたはSaveToUriを使います。
これらのメソッドは、ドキュメントのドキュメントでなくラスター画像形式への保存をサポートします。多くの場合、文書の変換では多くのオプションを指定し、DocumentConverterクラスを使って制御しなければなりません。
文書が変更されている場合、直近の変更を反映して保存します。たとえばオリジナルファイルは4ページありユーザーが1ページ目を削除した場合、保存されるファイルのページ数は3ページになります。同様に、いずれかのページのラスター画像を置換するためにSetImageを呼び出した場合、保存されるファイルには、このページの新しいバージョンが含まれます。
SaveDocumentOptionsが、以下のように使われます:
メンバ | 説明 |
---|---|
形式 |
LEADTOOLSがサポートしているRasterImageFormatの任意の値を使用できます。 この値がデフォルト(RasterImageFormat.Unknown)であるならば、このドキュメントはオリジナルドキュメントの形式を用いて保存されます。 |
BitsPerPixel |
使用する1ピクセルあたりのビット数値形式がサポートするデフォルト値には0を使用します。 |
AnnotationsUri |
nullでない場合、アノテーションファイルが保存される場所までのパスを格納しなければなりません。 |
WebClient |
リモートURLにデータをアップロードする際に使用する.NET WebClientオブジェクト SaveToUriのみで使用。 |
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms.DocumentWriters Imports Leadtools.Svg Imports Leadtools.Documents Imports Leadtools.Caching Imports Leadtools.Annotations.Core Imports Leadtools.Barcode Imports Leadtools.Forms.Ocr <TestMethod()> _ Public Sub DocumentSaveToFileExample() Dim options As New LoadDocumentOptions() options.UseCache = True DocumentFactory.Cache = CreateCache() Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.tif"), options) Dim page As Leadtools.Documents.DocumentPage = document.Pages(0) Dim container As AnnContainer = page.GetAnnotations(True) Dim obj As New AnnEllipseObject() obj.Rect = LeadRectD.Create(0, 0, 1 * 720, 1 * 720) obj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("red"), LeadLengthD.Create(1)) container.Children.Add(obj) page.SetAnnotations(container) Dim outName As String = Path.GetFileName(document.Uri.AbsolutePath).Replace(".", "_") & ".tif" Dim outFileName As String = Path.Combine(ImagesPath.Path, outName) If File.Exists(outFileName) Then File.Delete(outFileName) End If Dim saveOptions As New SaveDocumentOptions() saveOptions.Format = RasterImageFormat.CcittGroup4 saveOptions.BitsPerPixel = 1 Dim annFileName As String = Path.ChangeExtension(outFileName, ".xml") If File.Exists(annFileName) Then File.Delete(annFileName) End If saveOptions.AnnotationsUri = New Uri(annFileName) document.SaveToFile(outFileName, saveOptions) End Using End Sub
using Leadtools; using Leadtools.Codecs; using Leadtools.Forms.DocumentWriters; using Leadtools.Svg; using Leadtools.Documents; using Leadtools.Caching; using Leadtools.Annotations.Core; using Leadtools.Forms.Ocr; using Leadtools.Barcode; [TestMethod] public void DocumentSaveToFileExample() { var options = new LoadDocumentOptions(); options.UseCache = true; DocumentFactory.Cache = CreateCache(); using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.tif"), options)) { var page = document.Pages[1]; var container = page.GetAnnotations(true); var obj = new AnnEllipseObject(); obj.Rect = LeadRectD.Create(0, 0, 1 * 720, 1 * 720); obj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("red"), LeadLengthD.Create(1)); container.Children.Add(obj); page.SetAnnotations(container); var outName = Path.GetFileName(document.Uri.AbsolutePath).Replace(".", "_") + ".tif"; var outFileName = Path.Combine(ImagesPath.Path, outName); if (File.Exists(outFileName)) File.Delete(outFileName); var saveOptions = new SaveDocumentOptions(); saveOptions.Format = RasterImageFormat.CcittGroup4; saveOptions.BitsPerPixel = 1; var annFileName = Path.ChangeExtension(outFileName, ".xml"); if (File.Exists(annFileName)) File.Delete(annFileName); saveOptions.AnnotationsUri = new Uri(annFileName); document.SaveToFile(outFileName, saveOptions); } }