#1 Re: PDF Engine » jpg to pdf: how to change document resolution? » 2016-08-18 09:49:57

I manually altered the values of 72 to 300 in the file SynPdf.pas in four places, worked.
...
constructor TPdfCanvas.Create(APdfDoc: TPdfDocument);
begin
  FDoc := APdfDoc;
  FFactor := 300/FDoc.FScreenLogPixels; // PDF expect 72 pixels per inch
  FFactorX := FFactor;
  FFactorY := FFactor;
  FDevScale := 1;
  FMappingMode := MM_TEXT;
  fUseMetaFileTextPositioning := tpSetTextJustification;
  fKerningHScaleBottom := 99.0;
  fKerningHScaleTop := 101.0;
end;
...
procedure TPdfCanvas.SetPage(APage: TPdfPage);
begin
  FPage := APage;
  FPageFontList := FPage.GetResources('Font');
  FContents := TPdfStream(FPage.ValueByName('Contents'));
  FFactor := 300/FDoc.FScreenLogPixels; // PDF expect 72 pixels per inch
end;
...
procedure TPdfPageGDI.SetVCLCurrentMetaFile;
var tmp: RawByteString;
    Stream: TStream;
begin
  assert(fVCLCurrentMetaFile=nil);
  fVCLCurrentMetaFile := TMetaFile.Create;
  fVCLCanvasSize.cx := MulDiv(PageWidth,FDoc.FScreenLogPixels,300);
  fVCLCanvasSize.cy := MulDiv(PageHeight,FDoc.FScreenLogPixels,300);
  fVCLCurrentMetaFile.Width  := fVCLCanvasSize.cx;
  fVCLCurrentMetaFile.Height := fVCLCanvasSize.cy;
  if fVCLMetaFileCompressed<>'' then begin
    tmp := fVCLMetaFileCompressed;
    CompressSynLZ(tmp,false);
    Stream := TRawByteStringStream.Create(tmp);
    try
      fVCLCurrentMetaFile.LoadFromStream(Stream);
    finally
      Stream.Free;
    end;
  end;
end;
...

#2 Re: PDF Engine » jpg to pdf: how to change document resolution? » 2016-08-18 08:51:59

P.S. current page size in Adobe Acrobat: 874,9mm x 1237,5mm

#3 PDF Engine » jpg to pdf: how to change document resolution? » 2016-08-18 07:34:56

pivbul
Replies: 3

hello friends.
I created a pdf from jpeg images (300 and 600 dpi), but when printing in acrobat the resolution of the images on each page change. For correct printing in acrobat every time you need to manually select the option to "fit". How can I specify the size of the pdf document such as 300 dpi?

pdfdoc:=TPdfDocument.Create(False, 0, True, Nil);
pdfdoc.DefaultPaperSize:=psA4;
pdfdoc.ForceJPEGCompression:=0;
pdfdoc.CompressionMethod:=cmFlateDecode;
jpg:=tjpegimage.Create;
  try
  jpg.LoadFromFile('c:\1.jpg');
  pdfpage:=pdfdoc.AddPage;
  pdfpage.PageWidth:=jpg.Width;
  pdfpage.PageHeight:=jpg.Height;
  pdfImage:=TPdfImage.Create(pdfDoc,jpg,true);
  pdfdoc.AddXObject('image1', pdfimage);
  pdfdoc.Canvas.DrawXObject(0,0,pdfpage.PageWidth,pdfpage.PageHeight,'image1');
  except end;
//next try...except
jpg.Free;
pdfdoc.SaveToFile('c:\1.pdf');
pdfdoc.Free;

photo sample: https://yadi.sk/i/SH5jpEnduJSPt

Board footer

Powered by FluxBB