I have now created a ComboBox to let the user decide the PDF PaperSize:
var a: TIOPDFPaperSize;
// Fill combobox with available PDF paper sizes:
ComboBoxPdfPaperSizes.Clear;
for a := Low(TIOPDFPaperSize) to High(TIOPDFPaperSize) do
begin
var ThisPaperSizeStr := iepdf.IEPaperSizeToStr(a);
if ThisPaperSizeStr <> '' then // exclude the 'Unknown' PaperSize
ComboBoxPdfPaperSizes.Items.Add(ThisPaperSizeStr);
end;
This is how it looks in my App:
Then, at run-time I select "A4" PaperSize in the Combobox;
Then I save the screenshot as PDF:
IEIO.Params.PDF_PaperSize := IEStrToPaperSize(ComboBoxPdfPaperSizes.Text);
if IEIO.IEBitmap.Height > IEIO.IEBitmap.Width then
IEIO.Params.PDF_PaperLayout := ielPortrait
else
IEIO.Params.PDF_PaperLayout := ielLandscape;
IEIO.SaveToFile(FileName.pdf);
The created PDF file is 297 x 209,9 mm. And this is how it looks in the PDF Viewer:
If I comment out the PDF Layout part:
{if IEIO.IEBitmap.Height > IEIO.IEBitmap.Width then
IEIO.Params.PDF_PaperLayout := ielPortrait
else
IEIO.Params.PDF_PaperLayout := ielLandscape;}
...then the created PDF file is still 209,9 x 297 mm, but it looks totally different in the PDF Viewer (because the default Layout is ielPortrait):
This seems almost correct because A4 is 210 x 297 mm or 297 x 210 mm, respectively.
So setting the PDF Layout with the above method gives correct results.
Also, when printed out on an A4 paper sheet, setting the Layout with this method results in a more efficient paper usage.
BTW, when using the "Auto" (iepAuto) item in the Combobox, the PDF size of the Notepad screenshot results in 155,6 x 105,1 mm - which is smaller than A4.