#2 PDF Engine » ForceJPEGCompression := 90 => no image in PDF » 2020-06-16 10:20:51

marsupilami
Replies: 2

Hello,

if I understand this post correctly, using TPdfDocumentGDI with ForceJPEGCompression and the VCLCanvas property should lead to JPEG images in the resulting PDF. Unfortunately that doesn't work for me.

My code basically looks like this:

  PDF := TPdfDocumentGDI.Create(False, 0, true);
  PDF.ForceJPEGCompression := 90;
  PDF.NewDoc;

  PDF.AddPage;
  PrintCanvas := PDF.VCLCanvas;

  x := TRect.Create(0, 0, Image.Width - 1 , Image.Height);
  y := TRect.Create(0, 0, PDF.VCLCanvasSize.cx - 1, PDF.VCLCanvasSize.cy);
  PrintCanvas.CopyMode := cmSrcCopy;
  PrintCanvas.CopyRect(y, Image.Canvas, x);

  PrintCanvas := nil;
  if Assigned(PDF) then FreeAndNil(PDF);

In the resulting PDF file I do find the following part, when setting ForceJPEGCompression to 90:

<</Length 0/Type/XObject/Subtype/Image/ColorSpace/DeviceRGB/Width 0/Height 0/BitsPerComponent 8/Name/SynImg0/Filter/DCTDecode>>
stream

endstream

It seems that no image stream is saved to the PDF file? Any ideas what I am doing wrong?

Best regards,

Jan

Board footer

Powered by FluxBB