Width property is not parsed inside CSS body
Hello,
Using this code to convert HTML to PDF via SynPdf component, the PNG image is not rendered ; JPG does.
function THtmlPager.SynPdf:TBytes;
label
Clear;
var
OK : Boolean;
Size : TSize;
PDF : TPdfDocumentGDI;
Stream : TMemoryStream;
begin
PDF := nil;
PDF := TPdfDocumentGDI.Create;
OK := True;
Size := FullDisplaySize(Width);
try
{PDF.UseUniscribe := True;}
PDF.DefaultPaperSize := psUserDefined;
PDF.ScreenLogPixels := Screen.PixelsPerInch;
PDF.Info.Author := EditorOrgName;
PDF.Info.CreationDate := Now;
PDF.Info.Creator := ApplicationName;
PDF.Info.Keywords := '';
PDF.GeneratePDF15File := True;
PDF.DefaultPageWidth := Round(Size.cx*72/PDF.ScreenLogPixels);
PDF.DefaultPageHeight := Round(Size.cy*72/PDF.ScreenLogPixels);
PDF.AddPage;
HTMLPaint(PDF.VCLCanvas,Rect(0,0,Size.cx,Size.cy));
except
OK := False;
end;
if (not OK) then goto Clear;
Stream := TMemoryStream.Create;
try
PDF.SaveToStream(Stream);
except
Stream.Clear;
end;
SetLength(Result,Stream.Size);
Stream.Position := 0;
Stream.Read64(Result,0,Length(Result));
FreeAndNil(Stream);
Clear:
if Assigned(PDF) then FreeAndNil(PDF);
end;
Would real rendered Width and Height determined without the default width parameter provided to FullDisplaySize function?
Would margins set to 0 so document and control widths will be identical by introducing paraemetrs to the function:
procedure THtmlViewer.UpdateSize;
begin
if AutoSize then
begin
HScrollBar.Visible := False;
VScrollBar.Visible := False;
SetBounds(Left, Top, ScrollWidth + 2, MaxVertical + 2);
end;
end;
which would be:
procedure THtmlViewer.UpdateSize;
begin
if AutoSize then
begin
HScrollBar.Visible := False;
VScrollBar.Visible := False;
SetBounds(Left, Top, ScrollWidth + WidthMargin, MaxVertical + HeightMargin);
end;
end;
Best regards.
Hello, The Width attribute is not parsed inside CSS body (210mm). The real Width of the html is set ignoring this attribute.
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>Residence information</title>
<style>
body {
font-family: "Courier New", Courier, monospace;
font-size: small;
position: absolute;
width:210mm;
margin:0mm;
}
Please note that the Height is set to its correct value.
Best regards.
Sorry,
The PNG rendering problem is caused by the SynPdf component! https://github.com/synopse/SynPDF
Best regards.