ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 PDFBuilder - non-english letters problem

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Pawel Posted - Apr 08 2019 : 14:48:31
I try to create a pdf file with Tlabel and Tmemo.
But after create I lost my polish letters

It should look like this:


but I get:


I try to convert to string/ansistring/widestring or use other font charset.

What else I can to do?
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 10 2019 : 21:39:43
Oh, OK. It is much easier with layers. Please try this method:

// Supports TImage, TShape, TLabel, and TMemo
// OutputTextAsImg: Useful to support non-ANSI character sets and custom fonts
function TForm1.OutputPageWithControls(PdfBuilder: TIEPDFBuilder;
                                       Page: TPanel;
                                       PaperSize: TIOPDFPaperSize;
                                       Compression: TIOPDFCompression;
                                       OutputTextAsImg: Boolean): Integer;
const
  Rounding_Error_Prevention = 1.05;
  Text_Margin = 2;
var
  bmp: TIEBitmap;
  borderWidth: Integer;
  bw: Integer;
  destShape: TIEShape;
  I: Integer;
  pageIndex: integer;
  paperSizePts: TPoint;
  objScale: Double;
  lbl: TLabel;
  mem: TMemo;
  img: TImage;
  rct: TRect;
  shp: TShape;
begin
  pageIndex := PdfBuilder.AddPage( PaperSize );
  paperSizePts := IEPaperSizeToPoints( PaperSize );
  objScale := dmin(( paperSizePts.X - 2 * PDF_Page_Margin ) / Page.Width,
                   ( paperSizePts.Y - 2 * PDF_Page_Margin ) / Page.Height );

  for I := 0 to Page.ControlCount - 1 do
    if Page.Controls[I].Visible then
    begin
      // TLABEL
      if Page.Controls[I] is TLabel then
      begin
        lbl := TLabel( Page.Controls[I] );

        if OutputTextAsImg AND lbl.Transparent then
        begin
          // Convert text to image

          bmp := TIEBitmap.Create( lbl.Width, lbl.Height, ie32RGB ); // Use 32bit for RGBA support
          bmp.IECanvas.TextRendering := ietrTextRenderingHintAntiAlias;
          bmp.Fill( clWhite );
          bmp.AlphaChannel.Fill(0);
          bmp.IECanvas.SetCompositingMode(ieCompositingModeSourceOver, ieCompositingQualityDefault);
          bmp.IECanvas.Font.Assign( lbl.Font );
          bmp.IECanvas.DrawText( lbl.Caption, Rect( 0, 0, bmp.Width, bmp.Height ));
          bmp.SynchronizeRGBA( True, True );
          PdfBuilder.AddImage( Round( PDF_Page_Margin + objScale * lbl.Left ),
                               Round( PDF_Page_Margin + objScale * lbl.Top ),
                               Round( objScale * lbl.Width ),
                               Round( objScale * lbl.Height ),
                               bmp,
                               0, 1.0,
                               Compression );
          bmp.Free;
        end
        else

        if OutputTextAsImg then
        begin
          // Convert text to image

          bmp := TIEBitmap.Create( lbl.Width, lbl.Height );
          bmp.Fill( clWhite );
          bmp.IECanvas.Font.Assign( lbl.Font );
          bmp.IECanvas.DrawText( lbl.Caption, Rect( 0, 0, bmp.Width, bmp.Height ));
          PdfBuilder.AddImage( Round( PDF_Page_Margin + objScale * lbl.Left ),
                               Round( PDF_Page_Margin + objScale * lbl.Top ),
                               Round( objScale * lbl.Width ),
                               Round( objScale * lbl.Height ),
                               bmp,
                               0, 1.0,
                               Compression );
          bmp.Free;
        end
        else
        begin
          // Output text

          PdfBuilder.AddText( Rect( Round( PDF_Page_Margin + objScale * lbl.Left ),
                                    Round( PDF_Page_Margin + objScale * lbl.Top ),
                                    Round( PDF_Page_Margin + objScale * ( lbl.Left + lbl.Width * Rounding_Error_Prevention )),
                                    Round( PDF_Page_Margin + objScale * ( lbl.Top + lbl.Height * Rounding_Error_Prevention ))),
                              AnsiString( lbl.Caption ),
                              objScale * lbl.Font.Size * lbl.Font.PixelsPerInch / 72,
                              lbl.Font );
        end;

      end
      // TMEMO
      ELSE
      if Page.Controls[I] is TMemo then
      begin
        mem := TMemo( Page.Controls[I] );

        if OutputTextAsImg then
        begin
          // Convert text to image

          bmp := TIEBitmap.Create( mem.Width, mem.Height );
          bmp.IECanvas.Brush.Color := mem.Color;
          bmp.IECanvas.Pen.Color   := clBlack;
          if mem.BorderStyle <> bsNone then
            bmp.IECanvas.Rectangle( 0, 0, mem.Width, mem.Height )
          else
             bmp.Fill( mem.Color );
          bmp.IECanvas.Font.Assign( mem.Font );
          bmp.IECanvas.DrawText( mem.Text, Rect( Text_Margin, Text_Margin, bmp.Width - Text_Margin, bmp.Height - Text_Margin ));
          PdfBuilder.AddImage( Round( PDF_Page_Margin + objScale * mem.Left ),
                               Round( PDF_Page_Margin + objScale * mem.Top ),
                               Round( objScale * mem.Width ),
                               Round( objScale * mem.Height ),
                               bmp,
                               0, 1.0,
                               Compression );
          bmp.Free;
        end
        else
        begin
          // Output text

          // Background
          bw := 0;
          if mem.BorderStyle <> bsNone then
            bw := 1;
          PdfBuilder.AddShape( PDF_Page_Margin + objScale * mem.Left,
                               PDF_Page_Margin + objScale * mem.Top,
                               PDF_Page_Margin + objScale * ( mem.Left + mem.Width ),
                               PDF_Page_Margin + objScale * ( mem.Top + mem.Height ),
                               iesRectangle,
                               0,
                               clBlack,
                               objScale * bw,
                               1.0,
                               True,
                               mem.Color,
                               1.0 );

          // Text
          PdfBuilder.AddText( Rect( Round( PDF_Page_Margin + objScale * ( mem.Left + 2 * bw )),
                                    Round( PDF_Page_Margin + objScale * ( mem.Top + 2 * bw )),
                                    Round( PDF_Page_Margin + objScale * ( mem.Left + mem.Width - 2 * bw )),
                                    Round( PDF_Page_Margin + objScale * ( mem.Top + mem.Height - 2 * bw ))),
                              AnsiString( mem.Text ),
                              objScale * mem.Font.Size * mem.Font.PixelsPerInch / 72,
                              mem.Font );

        end;
      end
      ELSE
      // TTIMAGE
      if Page.Controls[I] is TImage then
      begin
        img := TImage( Page.Controls[I] );
        bmp := TIEBitmap.create( img.Picture.Bitmap );
        PdfBuilder.AddImage( Round( PDF_Page_Margin + objScale * img.Left ),
                             Round( PDF_Page_Margin + objScale * img.Top ),
                             Round( objScale * img.Width ),
                             Round( objScale * img.Height ),
                             bmp,
                             0, 1.0,
                             Compression );
        bmp.Free;
      end
      ELSE
      if Page.Controls[I] is TShape then
      begin
        shp := TShape( Page.Controls[I] );
        rct := Rect( Round( PDF_Page_Margin + objScale * shp.Left ),
                     Round( PDF_Page_Margin + objScale * shp.Top ),
                     Round( PDF_Page_Margin + objScale * ( shp.Left + shp.Width * Rounding_Error_Prevention )),
                     Round( PDF_Page_Margin + objScale * ( shp.Top + shp.Height * Rounding_Error_Prevention )));
        if shp.Shape in [ stCircle, stSquare, stRoundSquare ] then
          // Make Aspect Ratio 1:1
          rct := GetImageRectWithinArea( 1, 1, rct );

        if shp.Shape in [ stCircle, stEllipse ] then
          destShape := iesEllipse
        else
        if shp.Shape in [ stRoundRect, stRoundSquare ] then
          destShape := iesRoundRect
        else
          destShape := iesRectangle;

        borderWidth := 0;
        if shp.Pen.Style <> psClear then
          borderWidth := shp.Pen.Width;

        PdfBuilder.AddShape( rct.Left, rct.Top, rct.Right, rct.Bottom,
                             destShape, 0, shp.Pen.Color, borderWidth, 1.0,
                             shp.Brush.Style <> bsClear, shp.Brush.Color, 1.0 );
      end
    end;

  result := pageIndex;
end;


Nigel
Xequte Software
www.imageen.com
Pawel Posted - Apr 10 2019 : 11:51:20
But my Tmemo, Tlabel and Tedit objects are placed on panel.
xequte Posted - Apr 09 2019 : 19:21:44
Yes, that is a good idea.

You can call:

https://www.imageen.com/help/TImageEnView.LayersConvertToImageLayers.html

e.g.

for i := 0 to ImageEnView1.LayersCount - 1 do
  if ImageEnView1.Layers[i].Kind = ielkText then
    ImageEnView1.LayersConvertToImageLayers( i );


Call SaveUndo and then Undo to make the change temporary during the PDF generation.

Nigel
Xequte Software
www.imageen.com
Pawel Posted - Apr 09 2019 : 10:29:17
maybe is it possible to add a memo object as an image?
xequte Posted - Apr 09 2019 : 00:30:49
Hi Pawel

Unfortunately at this time, only the ANSI character set it supported. Improvements in this area are on the to-do list.

Nigel
Xequte Software
www.imageen.com