Page 1 of 1

Print to Pdf printer and fonts

Posted: 25 May 2010, 18:19
by merco
I can convert dwg into pdf file, but text are not selectable in pdf viewer. I think is a font issue, but how can i set the righe font ? Should i use SHX fonts ?

Code: Select all

_cadImage = CADImage.CreateImageByExtension(_nameFile)
        _cadImage.UseDoubleBuffering = False

        _cadImage.LoadFromFile(_nameFile)


            
        _cadImage.UseSHXFonts = True
        _cadImage.UseTTFFonts = Not _cadImage.UseSHXFonts
        _cadImage.UseMultyTTFFonts = Not _cadImage.UseSHXFonts

        Dim entMText As CADMText = New CADMText
        entMText.Text = "{\fTimes New Roman|b0|i1;\H19;\l\C132;timers\P}"
        entMText.Color = Color.Red
        entMText.Point = New DPoint(100, 100, 0)
        entMText.Height = 10
        entMText.Loaded(_cadImage.Converter)
        _cadImage.Converter.GetSection(FaceModule.ConvSection.Entities).AddEntity(entMText)
        _cadImage.Converter.OnCreate(entMText)
        _cadImage.Converter.Loads(entMText)



        Dim entText As CADText = New CADText

        entText.Color = Color.Green
        entText.Point = New DPoint(-200, -200, 0)
        entText.Height = 12
        entText.FontName = "E:\Documents and Settings\mercanti\Desktop\cadimportnet_07\dwg\dwg\romans.shx"
        entText.Text = entText.FontName
        entText.Loaded(_cadImage.Converter)
        _cadImage.Converter.GetSection(FaceModule.ConvSection.Entities).AddEntity(entText)
        _cadImage.Converter.OnCreate(entText)
        _cadImage.Converter.Loads(entText)



        _cadImage.GetExtents()
        Dim prtForm As CADImport.Printing.PrintingForm
        prtForm = New CADImport.Printing.PrintingForm
        prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
        prtForm.Image = _cadImage
        prtForm.Print(True)

Re: Print to Pdf printer and fonts

Posted: 27 May 2010, 16:30
by support
Hello.
You create the Image object that contain Text and MText objects then print it using virtual printer that creates a PDF document, if I'm understood correctly? Possibly the PDF creator you use doesn't export text objects as texts in PDF.

Alexander.

Re: Print to Pdf printer and fonts

Posted: 27 May 2010, 17:49
by merco
maybe. But why "Trial version" si converted to text ?

Re: Print to Pdf printer and fonts

Posted: 28 May 2010, 15:26
by support
Hello.
Please try create text object with the some specified style within your code. For example:

Code: Select all

...
            CADText entText = new CADText();

            CADStyle txtStyle = new CADStyle();
            txtStyle.Name = "Gothice";
            txtStyle.PrimaryFont = "Gothice";
            this._cadImage.Converter.Styles.Insert(0, txtStyle);

            entText.Style = (CADStyle)this._cadImage.Converter.Styles[0];
            entText.Color = Color.Red; 
            entText.Point = new DPoint(0, 0, 0);
            entText.Height = 20;
            entText.Text = "Hello World!!!";
            entText.LineWeight = 0.1;
            entText.Loaded(this._cadImage.Converter);
            this._cadImage.Converter.OnCreate(entText);
            this._cadImage.CurrentLayout.AddEntity(entText);

            this._cadImage.GetExtents();
...
Also which library version you use?

Alexander.

Re: Print to Pdf printer and fonts

Posted: 28 May 2010, 16:46
by merco
Trying with this code (not working) and version 7.2.2.19035

Code: Select all

        Dim entText As CADText = New CADText
        Dim txtStyle As CADStyle = New CADStyle

        txtStyle.Name = "Arial"
        txtStyle.PrimaryFont = "e:\windows\fonts\Arial.ttf"
        _cadImage.Converter.Styles.Insert(0, txtStyle)
        entText.Style = _cadImage.Converter.Styles(0)
        entText.Color = System.Drawing.Color.Black
        entText.Point = New DPoint(_cadImage.Extents.left, _cadImage.Extents.bottom, 0)
        entText.Height = 20
        entText.Text = "Hello World!!!"
        entText.LineWeight = 0.1
        entText.Loaded(_cadImage.Converter)
        _cadImage.Converter.GetSection(FaceModule.ConvSection.Entities).AddEntity(entText)
        _cadImage.Converter.OnCreate(entText)
        _cadImage.Converter.Loads(entText)

        _cadImage.GetExtents()
With BullZip printer i can't see any font information and the text isn't selectable.

The "Trial version" print PDF generated by demo application is replaced with a font called "TT9A0Ao00". So my question is: what is the name of the font used to write "Trial version" and why that message is selectable ?

Re: Print to Pdf printer and fonts

Posted: 28 May 2010, 16:59
by merco
Another question:
When i define a style:

Code: Select all

 txtStyle.PrimaryFont = "Cour.ttf"
How should i set "PrimaryFont" property:
with name ?
With full path ?
With name.ext seen in %font% directory ?

Re: Print to Pdf printer and fonts

Posted: 28 May 2010, 18:04
by support
please include the following code string:

Code: Select all

_cadImage.DrawTextMeansGDIPlusMethods = true;

Dim entText As CADText = New CADText
Dim txtStyle As CADStyle = New CADStyle
this property specifies drawing the texts using GDI+. I expect the text object will be selectable afterwards.

You can specify the PrimaryFont using name or paph or a file name.

Alexander.

Re: Print to Pdf printer and fonts

Posted: 28 May 2010, 19:30
by merco
it works now ! :P

Re: Print to Pdf printer and fonts

Posted: 31 May 2010, 12:59
by support
Please note, the DrawTextMeansGDIPlusMethods method was removed from library in the version 7.2.5. GDI+ will be used for non-rotated texts automatically. However the rotated texts will be drawn using glyphs.

Alexander.

Re: Print to Pdf printer and fonts

Posted: 31 May 2010, 16:26
by merco
Ok, Thank you.
Now I have one more question to a text problem.
In the pdf the rotated text is not "in line" with the line as in the dwg.
How can i fix it ?

Re: Print to Pdf printer and fonts

Posted: 31 May 2010, 16:39
by merco
So with Version 7.2.5.24180 , how can i manage rotated text to leave it selectable ?
See always the same pdf attached in this thread.

Re: Print to Pdf printer and fonts

Posted: 31 May 2010, 18:30
by support
The DrawTextMeansGDIPlusMethods was removed and rotated texts can't be visualized using GDI+. This mean rotated texts won't be selectable in PDF that is received via visualized image. However, our library doesn't oriented for using with PDF creators. The modification's purpose is more correct visualization of CAD files - AutoCAD draws texts in such manner. So I recommend using version 7.2.2 for your task. We will possibly implement some solution for such situation in the future versions.

Please specify what you meant by
not "in line" with the line as in the dwg
Texts looks identically, except lines thickness. If thi is the problem then you need set SHX fonts using to correct it.

Alexander.

Re: Print to Pdf printer and fonts

Posted: 31 May 2010, 19:23
by merco
For the "In line problem" see the image posted

Re: Print to Pdf printer and fonts

Posted: 01 Jun 2010, 11:56
by support
Hello.
The DrawTextMeansGDIPlusMethods was removed and rotated texts can't be visualized using GDI+ (7.2.5). The modification's purpose is more correct visualization of CAD files
The situation from your picture was one of the reasons for such modification.

Alexander.