You are not logged in.
Pages: 1
Hello:
Very confused at this point about how to do this. Saw post from Lesh11 back in 2014. The link is no longer good. His final "got it to work using VCL.Canvas" did nothing to help.
I am working with Lut at QuickReports (v6) to output a vertical text in a column header on a report. QR's PDF export filter does not work with their rotated text TQRPLabel.
He suggested the use of SynPDF to do this since it supports rotated text, but nothing that we are trying seems to work.
Below is the code I am using to convert an existing vertical label to a plain TQRLabel with an assigned TTFont which has rotation. Turns out SynPDF does not even recognize TQRPLabel and when I add the new TQRLabel with rotated text the only way it comes out is horizontal when using SynPDF. The QR preview shows it vertical.
Can you direct me to how I can export vertical text via SynPDF?
The font I am using for the original label is Calibri, 10. I am using Delphi 10.2 in Windows 10. Degree = 900 i.e. 90.0 degrees
Thank you for any help or direction you may give,
Chuck
procedure ExpandToVerticalVertical( Qrep : TCustomquickrep; aband : TQRCustomband; alabel : TQRPLabel);
var
lf : TLogFont;
tf : TFont;
newLabel : TQRLabel;
begin
newLabel := TQRLabel.Create(application);
tf := TFont.Create;
with newLabel do
begin
Font := alabel.Font;
Caption := alabel.Caption;
Top := alabel.Top;
Height := alabel.Height;
Width := alabel.Width;
Left := alabel.Left;
Color := alabel.Color;
VerticalAlignment := alabel.VerticalAlignment;
Parent := aband;
end;
tf.Assign(newlabel.Font);
GetObject(tf.Handle, SizeOf(lf), @lf);
lf.lfEscapement := alabel.Degree;
lf.lfOrientation := alabel.Degree;
tf.Handle := CreateFontIndirect(lf);
newLabel.Font.Assign(tf);
tf.Free;
// alabel.Visible := false; //this does not work for tqrplabel
alabel.Font.Color := clWhite;
alabel.Update;
end;
and the code to output the PDF (first a Preview)
procedure TMainunit.SpeedButton1Click(Sender: TObject);
var //for using SynPDF
spdf : TQRSynPDFDocumentFilter;
begin
ExpandToVerticalVertical( Form1.QuickRep1, Form1.TitleBand1, Form1.QRPLabel1 );
//using SynPDF:
spdf := TQRSynPDFDocumentFilter.Create('synpdftest.pdf');
spdf.HideMenubar := false;
spdf.CompressionOn := true;
spdf.HideToolbar := true;
spdf.FontHandling := TQSFonthandling.AutoEmbed;
// for more available permission sets see synpdf.pas line 2867
spdf.Permissions := PDF_PERMISSION_NOCOPYNORPRINT;
spdf.UseSecurity := true;
spdf.ViewPassword := 'showme';
spdf.ModifyPassword := 'canchange';
form1.QuickRep1.Preview;
form1.QuickRep1.ExportToFilter(spdf); //repaform
spdf.Free;
ShellExecute(self.handle, 'open','synpdftest.pdf','','', 5);
end;
Offline
on reviewing the QRSynPDFDocumentFilter code, I see the following that might help:
my question about this code is does the assigned font to the the QRLabel, that has been rotated (in the above post), get properly assigned to the pdfdoc.canvas? What more needs to be done to do this?
see: pdfdoc.Canvas.SetFont(itemobj.itemrec.FontName, itemobj.itemrec.FontSize, textstyle) line.
Thank you,
Chuck
textitems := TStringList(FPDF.pagetextfiles.Objects[J]);
for k := 0 to textitems.Count-1 do
begin
itemobj := TQRPDFItemobj(textitems.objects[k]);
ostr := itemobj.itemrec.FText;
//finalDoc.add( ' ' + ostr);
textstyle := [];
if itemobj.itemrec.fbold then textstyle := textstyle + [TPdfFontstyle.pfsBold];
if itemobj.itemrec.fItalic then textstyle := textstyle + [TPdfFontstyle.pfsItalic];
pdfdoc.Canvas.SetFont(itemobj.itemrec.FontName, itemobj.itemrec.FontSize, textstyle);
fillcolor := itemobj.itemrec.RGBFColor;
textc := RGB(fillcolor.Red,fillcolor.Green,fillcolor.Blue )+$7F000000;
pdfdoc.Canvas.SetRGBFillColor( textc);
xp := itemobj.itemrec.XPos;
yp := itemobj.itemrec.YPos;
pdfdoc.Canvas.TextOut( xp, yp, ostr);
end;
Offline
Ok, I am much closer now that I have spent time with the QuckReport QRPDFSynPDFFilter.pas.
I am forwarding what I found to Lut at QR so that he can finalize the changes.
They essentially include making pdfdoc TPdfDocumentGDI, not TPDFDocument to get the VCLCanvas property (as mentioned by Lesh11). Once you have that, you need to pass the TFont that was created with rotated text as part of the object record that is used (itemobj in above code).
pdfdoc.Canvas.SetFont(itemobj.itemrec.FontName, itemobj.itemrec.FontSize, textstyle);
becomes
pdfDoc.VCLCanvas.Font.Assign(itemobj.itemrec.Font);
the Canvas.TextOut now requires integer xp, yp values. So make sure those are passed to the object.
Offline
Pages: 1