API reference › Import & Output APIs
pdfImportPDFFile
Import every page of the open import source in one call.
| Exported names | pdfImportPDFFile |
|---|---|
| Note | DestPage/scale parameters are ignored — see Remarks |
Purpose — Import every page of the open import source in one call.
Description — For each source page: appends a new destination page sized to the source page's MediaBox (not the author default), imports the page as a form XObject, places it 1:1 at the origin, and closes the page. The author's default page size is restored afterwards, so subsequent pdfAppend calls are unaffected. Non-widget annotations come across when the ifAllAnnots import flag is set (default — see pdfSetImportFlags).
int32_t __stdcall pdfImportPDFFile(PPDF IPDF, uint32_t DestPage, double ScaleFactX, double ScaleFactY);
function pdfImportPDFFile(const IPDF: PPDF; DestPage: Cardinal;
ScaleFactX, ScaleFactY: Double): Integer; stdcall; external 'LumasPdf.dll';
Return value — Number of pages imported; 0 on failure (no import source open, or the source has no pages).
Remarks — In this engine DestPage, ScaleFactX, and ScaleFactY are accepted for ABI compatibility but ignored: pages are always appended after the current last page at natural size. Requires an open output document (pdfCreateNewPDF… first) and no open page.
Example — merge two PDFs (Delphi)
var
Pdf: PPDF;
begin
Pdf := pdfNewPDF;
try
if not pdfCreateNewPDFW(Pdf, 'merged.pdf') then Abort;
if pdfOpenImportFileW(Pdf, 'a.pdf', 0, nil) < 0 then Abort;
if pdfImportPDFFile(Pdf, 1, 1.0, 1.0) = 0 then Abort;
if pdfOpenImportFileW(Pdf, 'b.pdf', 0, nil) < 0 then Abort; // auto-closes a.pdf
if pdfImportPDFFile(Pdf, 1, 1.0, 1.0) = 0 then Abort;
if not pdfCloseFile(Pdf) then Abort;
finally
pdfDeletePDF(Pdf);
end;
end;
C# (P/Invoke)
public static extern int pdfImportPDFFile(IntPtr IPDF, uint DestPage, double ScaleFactX, double ScaleFactY);
Import
pdfImportPDFFile
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.