I have this code (admittedly the scanning is involved also )
procedure TpsScanner.ConvertToPDF;
var
p: TadvPDFLib;
begin
p := TadvPDFLib.Create;
try
p.BeginDocument(TPath.GetTempPath + 'psScanner.pdf');
p.NewPage;
p.Graphics.DrawImageFromFile(TPath.GetTempPath + 'psScanner.jpg',
PointF(0, 0));
p.EndDocument(False);
finally
p.Free;
end;
end;
The produced pdf only shows the top left quarter of the image. The scanned image looks great. Am I missing some sizing? The scanned image uses letter size.
Must be a scaling issue. Got it working using SynPdf with this code:
procedure TpsCustomScanner.ConvertToSynPDF;
begin
if Assigned(FSynPDFDocument) then
FreeAndNil(FSynPDFDocument);
FSynPDFDocument := TPdfDocumentGDI.Create;
try
var
lPage := FSynPDFDocument.AddPage;
I overlooked your code initially, but it seems that you are drawing the image as-is from the top-left of the PDF. The image is bigger than the initial PDF pixel size, so you need to make sure that you are drawing the image with aspect ratio in a smaller rectangle. You can do this via
If I scan a full size image it does cover the Header and Footer, but an image that is not full page always shows the default 'Header' and 'Footer' text. P22C0001_0001.pdf (1.5 MB)
Still need to account for non standard sizes, and in my case the resolution of the scanned image.
This works, although I have to prompt for the resolution as DelphiTwain does not return the scanner resolution.
For images, this is true, because the DPI used is 72, but the printer DPI is typically higher (300-600). This means that the PDF will indeed be stretched out when printing losing resolution. For all the other primitives this makes no difference as they are vector based.