You are not logged in.
Pages: 1
Hi;
First of all, this is a great component. I am new at this component but I have two problem:
1. I am using transparent PNG files but when I add these files to PDF, transparency disappear. Did I do something wrong or there is not transparent PNG support.
2. Is it possible to use CMYK colors and images instead of RGB?
Thanks for your help. Best Regards...
Offline
1. AFAIK transparency is not handled currently.
It sounds like a difficult task:
Transparency in PDF
Starting with version 1.4 of the PDF standard, transparency (including translucency) is supported. This is a very complex model, requiring over 100 pages to document. A key source of complication is that PDF files may contain objects with different color spaces, and blending these is tricky. PDF supports many different blend modes, not just the most common averaging method. In addition, the rules for compositing many overlapping objects allow choices, such as whether a group of objects are blended before being blended with the background, or whether each object in turn is blended into the background.
Adobe Acrobat 5.0 was the first to support PDF 1.4 and, hence, transparent PDF files. Transparency in PDF was carefully designed not to cause errors in PDF viewers that did not understand it, they would simply display all elements as fully opaque. This was a two-edged sword. On the one hand, it reduced errors and complaints about errors; on the other hand it meant people with older viewers, PDF printers, etc. might print something completely different from the original design, increasing complaints about incorrect output. When PDF files are used to prepare work for professional printing, transparency issues could cause millions of printed copies to be incorrect, and have to be destroyed.
Not very encouraging...
One possibility could be to create a wide bitmap including transparent bitmaps drawn over it, computed as a TBitmap using the VCL or Windows API, then draw it in the PDF with the text over it.
Another workaround could be to create a region around your bitmap content, then use it as clipping mask. It should work.
2. CMYK could be handled in PDF generation, but all our bitmap image sources (TGraphic based) are RGB (like in Windows).
It could be possible to overload the TPdfImage.Create constructor to handle CMYK pictures, if the bitmap is provided as C/M/Y/K individual values.
But the PDF reference document doesn't give any sample of such pictures.
Offline
Thanks for the reply. What about CMYK stroke and fill colors?
Eureka. I added two functions to TPdfCanvas:
procedure TPdfCanvas.SetCMYKFillColor(C, M, Y, K: Byte);
begin
if FContents<>nil then
FContents.Writer.AddWithSpace(C/100).AddWithSpace(M/100).AddWithSpace(Y/100).AddWithSpace(K/100).Add('k'#10);
end;
procedure TPdfCanvas.SetCMYKStrokeColor(C, M, Y, K: Byte);
begin
if FContents<>nil then
FContents.Writer.AddWithSpace(C/100).AddWithSpace(M/100).AddWithSpace(Y/100).AddWithSpace(K/100).Add('K'#10);
end;
Last edited by fkaynakli (2011-06-14 19:06:13)
Offline
One possibility could be to create a wide bitmap including transparent bitmaps drawn over it, computed as a TBitmap using the VCL or Windows API, then draw it in the PDF with the text over it.
Another workaround could be to create a region around your bitmap content, then use it as clipping mask. It should work.
How can I achieve clipping with pdfimage? If someone can give a sample code for pdf, I will be very pleased.
Offline
To handle clipping, just define a pdf path, then use the Clip method.
You should use GSave and GRestore method calls.
See for instance, how DrawXObjectEx() method implement a rectangular clipping:
procedure TPdfCanvas.DrawXObjectEx(X, Y, AWidth, AHeight: Single;
ClipX, ClipY, ClipWidth, ClipHeight: Single; const AXObjectName: PDFString);
begin
DrawXObjectPrepare(AXObjectName);
GSave;
Rectangle(ClipX, ClipY, ClipWidth, ClipHeight);
Clip;
NewPath;
ConcatToCTM(AWidth, 0, 0, AHeight, X, Y);
ExecuteXObject(AXObjectName);
GRestore;
end;
Offline
Pages: 1