Print to Pdf printer and fonts

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
merco
Posts: 28
Joined: 25 May 2010, 10:03

Print to Pdf printer and fonts

Post by merco » 25 May 2010, 18:19

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)

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Print to Pdf printer and fonts

Post by support » 27 May 2010, 16:30

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Print to Pdf printer and fonts

Post by merco » 27 May 2010, 17:49

maybe. But why "Trial version" si converted to text ?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Print to Pdf printer and fonts

Post by support » 28 May 2010, 15:26

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Print to Pdf printer and fonts

Post by merco » 28 May 2010, 16:46

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 ?

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Print to Pdf printer and fonts

Post by merco » 28 May 2010, 16:59

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 ?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Print to Pdf printer and fonts

Post by support » 28 May 2010, 18:04

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Print to Pdf printer and fonts

Post by merco » 28 May 2010, 19:30

it works now ! :P

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Print to Pdf printer and fonts

Post by support » 31 May 2010, 12:59

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Print to Pdf printer and fonts

Post by merco » 31 May 2010, 16:26

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 ?
Attachments
e1926p.zip
pdf and dwg
(71.74 KiB) Downloaded 1439 times

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Print to Pdf printer and fonts

Post by merco » 31 May 2010, 16:39

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.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Print to Pdf printer and fonts

Post by support » 31 May 2010, 18:30

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Print to Pdf printer and fonts

Post by merco » 31 May 2010, 19:23

For the "In line problem" see the image posted
Attachments
screen shot from Cad & pdf reader
screen shot from Cad & pdf reader
notlinLine.jpg (52.24 KiB) Viewed 65733 times

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Print to Pdf printer and fonts

Post by support » 01 Jun 2010, 11:56

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply