PDFiumVCL Docs

SaveAs method

Denna API-post behåller identifierare, signaturer, kodblock och PDF-termer i ursprunglig form.
Component: TPdf  ·  Unit: PDFium
Saves the copy of PDF document to the specified stream. If PdfVersion is pv13 through pv17, the saved output is normalized and validated for that target version, including existing catalog /Version overrides in incremental output. The validator covers the full PDF 1.1–1.7 / ISO 32000-1 feature timeline: filters (FlateDecode, JBIG2Decode, JPXDecode), object & xref streams, transparency (SMask, ca/CA, blend modes), Tagged PDF (StructTreeRoot, MarkInfo), color spaces (ICCBased, DeviceN), page boxes (BleedBox/TrimBox/ArtBox), output intents, optional content, AcroForm, CID/Type 0 and OpenType fonts, AES & AES-256 encryption (CFM AESV2/AESV3), all version-restricted annotation subtypes (Widget, Sound, Movie, FreeText, Line, Square, Circle, Highlight, Underline, StrikeOut, Stamp, Ink, Popup, FileAttachment, TrapNet, Squiggly, PrinterMark, Polygon, PolyLine, Caret, Screen, Watermark, 3D, Redact), version-restricted action types (SubmitForm, ResetForm, ImportData, Hide, Named, JavaScript, Trans, SetState, Rendition, GoToE, GoTo3DView), and catalog entries (Perms, Legal, Collection, Requirements, NeedsRendering). Anything that exceeds the chosen target version raises EPdfError. If the document has no existing OpenAction and the target version supports it, the saved PDF opens on the first page with Fit Height zoom. Trial builds apply the trial watermark during save.

Syntax

function SaveAs(Stream: TStream; Option: TSaveOption = saNone; PdfVersion: TPdfVersion = pvUnknown): Boolean;

StreamTStream. A TStream to write the PDF data into.
OptionTSaveOption. Save option: soNone for a full rewrite, or soIncremental for an incremental update appended to the file.
PdfVersionTPdfVersion. Target PDF version. Use pvUnknown to preserve the current version.

 

function SaveAs(const FileName: string; Option: TSaveOption = saNone; PdfVersion: TPdfVersion = pvUnknown): Boolean;

FileNamestring. The output file path. The file is created or overwritten.
OptionTSaveOption. Save option: soNone for a full rewrite, or soIncremental for an incremental update appended to the file.
PdfVersionTPdfVersion. Target PDF version. Use pvUnknown to preserve the current version.

Return Value

Returns True if the document was saved successfully, or False on failure.

Description

Saves the current document to a file path or a TStream. The Option parameter controls the save mode: soNone performs a complete file rewrite, while soIncremental appends only the changes made since the document was last saved (smaller output, but grows over repeated saves).

The PdfVersion parameter specifies the output PDF version; pass pvUnknown to keep the document's existing version.

The Compressed property controls whether object-stream compression is applied during the save.

Example

// Save to file
Pdf.SaveAs('output.pdf');

// Save to stream
var MS: TMemoryStream;
MS := TMemoryStream.Create;
try
  Pdf.SaveAs(MS);
  MS.SaveToFile('output.pdf');
finally
  MS.Free;
end;

See Also

LoadDocument, Compressed, CreateDocument