Saves the document as PDF.

 

   

Syntax
 

[C#]
virtual void Save(string path)
virtual void Save(Stream stream)

[Visual Basic]
Overridable Sub Save(path As String)
Overridable Sub Save(stream As Stream)

Throws Exceptions may throw Exception()

 

   

Params
 
Name Description
path

The destination file path.

stream The destination stream.

 

   

Notes
 

Use this method to export the current document as PDF, XPS, or SWF. Any existing file will be overwritten.

XPS is exported only if the supplied path ends with ".xps", and it requires .NET Framework 3.0. The supplied path is used as the destination.

SWF is exported only if the supplied path ends with ".swf". If Doc.SaveOptions.Template is null, the current page is exported with Rect as the bounds of the Flash movie using Doc.SaveOptions.TemplateData.MeasureDpiX and Doc.SaveOptions.TemplateData.MeasureDpiY if specified. Otherwise, Doc.SaveOptions.Template specifies the path to a SWF file. The saved SWF file starts with the template SWF files, and a frame is added for each page in the document. The script added is in ActionScript 2. If the template's version is Flash Player 7 or lower, the saved file's version will be Flash Player 8. For information on the interaction between the added frames and the script from the template, please refer to the example Flash file. Images are output in JPEG if ❶ they are in DeviceGray or DeviceRGB and already in JPEG (without any other compression on top), or ❷ they are not in the indexed color space and both the width and the height are at least 8 pixels. For ❶, the original JPEG data is used so you can control the quality by pre-compressing the images; for ❷, the output will use 80% quality.

When saving to a Stream, XPS and SWF are supported via Doc.SaveOptions.FileExtension. Set this property to either ".xps", "xps", ".swf", or "swf". Otherwise, a PDF output will be generated. This property is ignored when saving to a file where the file extension in the path is used. IMPORTANT: For XPS, streams must be both readable and writable (i.e. FileAccess.ReadWrite, and not simply FileAccess.Write). If not, the operation will fail.

ABCpdf operates an intelligent just-in-time object loading scheme which ensures that only those objects that are required are loaded into memory. This means that if you are modifying large documents then server load will be kept to a minimum. The original PDF document must be available for as long as the Doc object is being used.

As a result you cannot modify or overwrite a PDF file while it is read into a Doc object. You will need to save your PDF to another location and then swap the two files around after the Doc object's use of the PDF is ended (with a call to Clear, Dispose, or Read with another PDF file).

If you need to obtain a PDF as raw data you can use the GetData function.

The Refactor setting determines whether new/modified redundant objects are eliminated when the document is saved. You can use SetInfo to change the setting.

Versions. ABCpdf automatically determines the version depending on the features you use. If you use features from only the 1.1 specification it will write a 1.1 PDF. If you use 1.3 features it will write a 1.3 PDF. If you use 1.4 features it will write a 1.4 PDF. Ditto 1.5 and 1.6.

If you're using a PDF template or drawing from another PDF the final output will be the minimum version used in these templates. In many real world applications this will be the factor which determines the version in the final output produced by ABCpdf.

There is no advantage in producing a 1.6 document if you're not using features from the 1.6 feature set. To do this will simply stop users of older versions of Acrobat from accessing a document which should be available to them.

 

   

Example
 

The following code illustrates how one might add text to a PDF and then save it out.

[C#]
Doc theDoc = new Doc();
theDoc.FontSize = 96;
theDoc.AddText("Hello World");
theDoc.Save(Server.MapPath("docsave.pdf"));
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.FontSize = 96
theDoc.AddText("Hello World")
theDoc.Save(Server.MapPath("docsave.pdf"))
theDoc.Clear()


docsave.pdf