API referenceImport & Output APIs

pdfSetUseSwapFileEx

Same as [pdfSetUseSwapFile](#api-pdfsetuseswapfile); SwapDir is also ignored.

Same as pdfSetUseSwapFile; SwapDir is also ignored.

C
BOOL32 __stdcall pdfSetUseSwapFileEx(PPDF IPDF, BOOL32 SwapContents, uint32_t SwapLimit, const char* SwapDir);

Example — stamp over imported content safely (Delphi)

Delphi
var
  Pdf: PPDF; Fnt: Integer;
begin
  Pdf := pdfNewPDF;
  try
    if not pdfCreateNewPDFW(Pdf, 'stamped.pdf') then Abort;
    pdfSetUseObjectStreams(Pdf, True);            // compact 1.5 output
    pdfSetImportFlags(Pdf, ifImportAll or ifImportAsPage);
    if pdfOpenImportFileW(Pdf, 'in.pdf', 0, nil) < 0 then Abort;
    if pdfImportPage(Pdf, 1) = 0 then Abort;      // page open + current
    if pdfBalanceContentStream(Pdf) = 0 then Abort;      // repair q/Q first
    if pdfEncapsulateContentStream(Pdf) = 0 then Abort;  // isolate its state
    Fnt := pdfSetFontW(Pdf, 'Helvetica', fsNone, 36, True, cp1252);
    if Fnt <= 0 then Abort;
    pdfWriteTextW(Pdf, 40, 40, 'APPROVED');
    if not pdfEndPage(Pdf) then Abort;
    if not pdfCloseFile(Pdf) then Abort;
  finally
    pdfDeletePDF(Pdf);
  end;
end;

See alsopdfGetBuffer · pdfImportPage · pdfSetCompressionLevel (Volume 3)

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Import & Output APIs
Category

Setters

Exported names

pdfSetUseSwapFileEx

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.