Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
13.5
Statistic
FMM
Blog
Renders a page to an image.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
WinPDF | 13.2 | ❌ No | ✅ Yes | ❌ No | ✅ Yes, on Windows | ❌ No |
Parameter | Description | Example | Flags |
---|---|---|---|
PDFRef | The reference number for the PDF document. | ||
Page | The page index. Zero based. |
0 | |
Width | The page width to use. If zero, we calculate it proportionally from the height. |
800 | |
Height | The page height to use. If zero, we calculate it proportionally from the width. |
600 | |
ImageType | The desired image type. JPEG, PNG, BMP, TIFF, GIF or HEIF. Default is JPEG. |
"JPEG" | Optional |
FileName | The file name to use for the returned image. | "page.jpg" | Optional |
Returns container value or error.
Make preview of page:
If [ MBS("IsWindows") ]
Set Variable [ $pdf ; Value: MBS( "WinPDF.LoadContainer"; Get Preview::Input) ]
If [ MBS("IsError") = 0 ]
Set Variable [ $NewImage ; Value: MBS( "WinPDF.PageImageAtSize"; $pdf; 0; 0; 600; "JPEG"; "page.jpg") ]
If [ MBS("IsError") = 0 ]
Set Field [ Get Preview::Preview ; $NewImage ]
Set Field [ Get Preview::Made using ; "WinPDF" ]
Set Variable [ $r ; Value: MBS( "WinPDF.Release"; $pdf) ]
Exit Script [ Text Result: ]
End If
Set Variable [ $r ; Value: MBS( "WinPDF.Release"; $pdf) ]
End If
Else If [ MBS("IsMacOS") or MBS("IsIOS") ]
Set Variable [ $preview ; Value: MBS( "PDFKit.GetPDFPageImage"; $Input; 0; "JPEG"; "input.jpg"; 72) ]
If [ MBS("IsError") = 0 ]
Set Field [ Get Preview::Preview ; $preview ]
Set Field [ Get Preview::Made using ; "PDFKit" ]
Exit Script [ Text Result: ]
End If
End If
Render preview in one Let statement:
Let([
// open from container value in variable
pdf = MBS( "WinPDF.LoadContainer"; $Container );
e1 = MBS("isError");
page = 0;
// render preview
image = If(e1; ""; MBS( "WinPDF.PageImageAtSize"; pdf; page; 0; 600; "JPEG"; "preview.jpg"));
e2 = MBS("isError");
// free resources
r = MBS( "WinPDF.Release"; pdf)
];
// if no error, return image
If(e2; ""; image))
This function checks for a license.
Created 8th March 2023, last changed 16th April 2023