How to apply bold to a manually created PDF document text snippet?

Asked

Viewed 4,655 times

0

I am developing a module responsible for generating and exporting PDF documents (Reports). As I did not find any solution third party free, so I’m using a simple VB library, which puts the document header and sets some basic settings like font, paper size and everything else.

Besides, I’m doing it in my hand.

I would like to know, how to apply the bold in just one text snippet of the PDF document. I noticed that people create a kind of source object in the code "PDF/Postscript" however it is tied to other objects and do not know how to create it.

See the PDF class documentation used.

  • Tell us which library you’re using, maybe someone knows it and can help you.

  • I’m actually using a class called VBPDF that I found googling around. It is very simple, actually I only use it because it automatically adds the header codes of a PDF document.

  • 2

    Put the library link in the question, so people can know what it is.

2 answers

2

EDITION:

As explained in the comments, the VB2PDF class, but I’ll leave the example of the library vbPDF if anyone has a question with her.

How to bold VB2PDF:

As can be seen in the site documentation itself, the objects in this class contain a property FontType that suits the formatting of the text, to leave in bold just do as in the example:

Dim objPDF As New VB2PDF
With objPDF
 .PaperSize = pdfA4
 .FileName = "c:\temp\test.pdf"
 .StartPDF
 .WritePDF "Hello world !", True, .pdfBold
 .EndPDF
End With

This example should create Hello world ! text with bold.

How to bold in vbPDF:

It is possible to change font styles as can be seen here, just use the method setFont, for example:

Dim clPDF As New vbPDF 
With clPDF
  .BeginDoc
  If .ErrNumber = 0 then
    .BeginPage
    ' Aqui seta as opções de fonte (Família, tamanho, estilo)'
    .SetFont "Times", 24, .pdfBold
    .DrawText 1, 15, "Hello world !"
    .EndDoc
  End If
End With

I changed a little the example I passed in the link, to include the bold.

  • 1

    Felipe, Grateful for the help. However, I updated the post with the link of the correct class. This class you posted, has the name similar to the one I’m using at the moment.

  • In the same link you sent, there is a property FontType, which has symbolic constants. One of them is pdfBold, what should make font bold.

  • I added how to do in VB2PDF.

  • 1

    Grateful, I managed to find a way! : D

0

I found this page, which is the documentation of a library called VBPDF, is talking about how to use bold, italic and such...

Behold: VBPDF set font

  • I’ve already used this API, it’s aimed at generating PDF documents. Unfortunately, these settings only work in the context of this API, which has nothing to do with the issuance of XLS documents. However, thank you for the strength... grateful!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.