#1 PDF Engine » Pdf made from a Jpeg GrayScale has a red background, instead of white » 2015-11-25 08:40:17

DefendeRRR
Replies: 1

Hello!

I have a document in a JPEG file (grayscale 8bit). When I make a PDF of it I've got a terrible background, red instead of white.

That's what I do:

var
	page: TPdfPage;
	pdfImage: TPdfImage;
	jpeg: SynGdiPlus.TJpegImage;	
	pdfDoc: TPDFDocument;
begin
	pdfDoc := TPDFDocument.Create(false, 0, true, nil);		
	try
		pdfDoc.Info.CreationDate := Now;
		pdfDoc.DefaultPaperSize := psA4;		
	
		jpeg := SynGdiPlus.TJpegImage.Create;
		try
			jpeg.LoadFromFile(FileName);                
			pdfImage := TPdfImage.Create(APdfDocument, jpeg, true)
		finally
			jpeg.Free;
		end;
		
		page := APdfDocument.AddPage;
		APdfDocument.AddXObject(AName, pdfImage);
		APdfDocument.Canvas.DrawXObject(0, 0, page.PageWidth, page.PageHeight, AName);			
		pdfDoc.SaveToStream(AOutStream);
	finally
		pdfDoc.Free;
	end;
end;

Please help me. Whether this is a bug or I do something wrong?

Board footer

Powered by FluxBB