#1 2020-10-27 14:47:44

fantoni
Member
Registered: 2011-02-25
Posts: 16

How to reduce pdf file size

Hi everyone, i need help to create small pdf files with synpdf.
I use this Delphi code to transform scanned .jpg images into a single pdf :

pdfDoc := TPdfDocument.Create(false,0,false,TPdfEncryption.New(elRC4_128,LabeledEditPdfPw.text,LabeledEditPdfPw.text,PDF_PERMISSION_NOCOPYNORPRINT))
else
pdfDoc :=TPdfDocument.Create;
pdfDoc.Info.Author:='';
pdfDoc.Info.Creator:='';
pdfDoc.DefaultPaperSize:=psA4;
pdfDoc.DefaultPageLandscape:=PdfLandscape;
pdfDoc.CompressionMethod:=cmFlateDecode;
pdfDoc.ForceJPEGCompression:=Qualitapdf;
Sb.Panels[0].Text:='Create pdf wait...';

for i := 0 to ListBox1.Count - 1 do
begin

JpegImage:=TJpegImage.create;
Nomefile:=dir+ListBox1.Items.Strings[i];
JpegImage.LoadFromFile(nomefile);
pdfpage := pdfDoc.AddPage;
pdfImage := TPdfImage.Create(pdfDoc,jpegimage,true);
JpegImage.Free;
pdfDoc.AddXObject('image'+inttostr(i), pdfimage);
pdfDoc.Canvas.DrawXObject(0,0,pdfpage.PageWidth,pdfpage.PageHeight,'image'+inttostr(i));

 ListBox1.Selected[i] := true;
Sb.Panels[0].Text:='Process page '+inttostr(i)+' of '+inttostr(ListBox1.Count)+' wait...';
 Application.ProcessMessages;
// pdfImage.CleanupInstance;
 end;

The pdf file I get is still too big... how can I minimize the outupt file size?

Thanks for the attention.

Offline

#2 2021-01-02 10:58:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: How to reduce pdf file size

Reduce the JPG resolution?

Offline

Board footer

Powered by FluxBB