#1 2020-06-16 10:20:51

marsupilami
Member
Registered: 2020-06-16
Posts: 2

ForceJPEGCompression := 90 => no image in PDF

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

Offline

#2 2020-06-16 19:11:39

marsupilami
Member
Registered: 2020-06-16
Posts: 2

Re: ForceJPEGCompression := 90 => no image in PDF

For me this is fixed by a slight modification of SynPdf. See https://github.com/synopse/SynPDF/pull/39

Offline

#3 2020-06-16 20:36:30

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

Re: ForceJPEGCompression := 90 => no image in PDF

Offline

Board footer

Powered by FluxBB