PDFium Component Docs

SaveAs-metodi

Component: TPdf  ·  Unit: PDFium
Tallentaa PDF-dokumentin kopion määritettyyn virtaan. Jos PdfVersion on pv13:sta pv17:ään, tallennettu tulos normalisoidaan ja validoidaan kyseistä kohdeversiota vasten, mukaan lukien olemassa olevat katalogin /Version-ohitukset inkrementaalisessa tulosteessa. Validoija kattaa koko PDF 1.1–1.7 / ISO 32000-1 -ominaisuushistorian: suodattimet (FlateDecode, JBIG2Decode, JPXDecode), object- ja xref-virrat, läpinäkyvyys (SMask, ca/CA, blend modes), Tagged PDF (StructTreeRoot, MarkInfo), väriavaruudet (ICCBased, DeviceN), sivulaatikot (BleedBox/TrimBox/ArtBox), output intents, optional content, AcroForm, CID/Type 0- ja OpenType-fontit, AES- ja AES-256-salaus (CFM AESV2/AESV3), kaikki versiosidonnaiset annotation-alatyypit (Widget, Sound, Movie, FreeText, Line, Square, Circle, Highlight, Underline, StrikeOut, Stamp, Ink, Popup, FileAttachment, TrapNet, Squiggly, PrinterMark, Polygon, PolyLine, Caret, Screen, Watermark, 3D, Redact), versiosidonnaiset action-tyypit (SubmitForm, ResetForm, ImportData, Hide, Named, JavaScript, Trans, SetState, Rendition, GoToE, GoTo3DView) sekä katalogimerkinnät (Perms, Legal, Collection, Requirements, NeedsRendering). Kaikki, mikä ylittää valitun kohdeversion, aiheuttaa EPdfErrorin. Jos dokumentissa ei ole olemassa olevaa OpenActionia ja kohdeversio tukee sitä, tallennettu PDF aukeaa ensimmäiselle sivulle Fit Height -suurennuksella. Trial-buildit lisäävät trial-vesileiman tallennuksen aikana

Syntax

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

StreamTStream value that receives the PDF data
OptionTSaveOption. Save option: saNone for a normal save, saIncremental for an incremental update, saNoIncremental to force a full rewrite, or saRemoveSecurity to remove security while saving
PdfVersionTPdfVersion target; use pvUnknown to preserve the current version

 

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

FileNamestring. The output file path. A sibling temporary file is completed first, then atomically replaces the destination
OptionTSaveOption. Save option: saNone, saIncremental, saNoIncremental, or saRemoveSecurity
PdfVersionTPdfVersion target; 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 PdfVersion parameter specifies the output PDF version; pass pvUnknown to keep the document's existing version

The Compressed property controls stream compression. Hybrid-reference, xref-stream and object-stream inputs are preserved when a classic-xref rewrite cannot retain their complete cross-reference semantics

Explicit PDF-version checks follow the active cross-reference revision chain and active object-stream members, so stale or unreferenced object bodies do not affect the requested version gate

The file overload leaves an existing destination unchanged if compression, post-processing or version validation fails

Conformance behaviour

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