Page 8 of 10

Re: [Module] pbPDF-Module

Posted: Fri Sep 17, 2021 11:56 pm
by DeanH
It could be the viewer. I'm using Foxit.

Re: [Module] pbPDF-Module

Posted: Tue Jan 04, 2022 7:55 am
by Little_man
Is there a solution for "unicode"?
Example: "Styczeń" (Polish) is displayed as "SryczeD".

Kind regards,
Little_man

Re: [Module] pbPDF-Module

Posted: Thu Jan 06, 2022 5:50 pm
by loulou2522
Little_man wrote: Tue Jan 04, 2022 7:55 am Is there a solution for "unicode"?
Example: "Styczeń" (Polish) is displayed as "SryczeD".

Kind regards,
Little_man
Maybe you have to load a police which allow this kind of character

Re: [Module] pbPDF-Module

Posted: Sat Dec 17, 2022 3:18 pm
by l1marik
Did you found solution?
Little_man wrote: Tue Jan 04, 2022 7:55 am Is there a solution for "unicode"?
Example: "Styczeń" (Polish) is displayed as "SryczeD".

Kind regards,
Little_man

Re: [Module] pbPDF-Module

Posted: Sat Dec 17, 2022 6:41 pm
by Little_man
I have not found a solution to the problem

Re: [Module] pbPDF-Module

Posted: Sat Dec 17, 2022 8:47 pm
by normeus
This is usually related to the font you are using. For coding I use a free font which happens to also have the character you need.
For my example, first download "Fira code" font from github : https://github.com/tonsky/FiraCode
( if you have a font that contains the character you need, use that font, but you have to make sure pbPDF finds it like I am doing with the example with Fira Code or it will use the default font and you'll see a "D")

Code: Select all

XIncludeFile "..\pbPDFModule.pbi"

Define File$="pbPDF-Example_Unicode_v1.pdf"
#PDF = 1
;  Create an instance of PDF
If PDF::Create(#PDF)
    ;  Always add a page to create a PDF or you'll get an error
  ;  Page size and orientation is optional, I like to add it because you can have multiple page sizes in a PDF   
  PDF::AddPage(#PDF,PDF::#Landscape,PDF::#format_letter)
  
  ; specialty unicode font, which contains the character you need
  PDF::EMbedFont(#PDF, "C:\WINDOWS\Fonts\FIRACODE-REGULAR.TTF","FiraCode","",PDF::#Unicode)
  
    PDF::SetFont(#PDF, "FiraCode", "", 14)
  PDF::PlaceText(#PDF, "This is an embedded Unicode-font (Fira Code) Styczeń  or using chr($0144) = "+Chr($0144), 10, 50)
  
    PDF::Close(#PDF, File$)
  
EndIf

RunProgram(File$)
I hope this helps.
Norm

Re: [Module] pbPDF-Module

Posted: Sun Dec 18, 2022 7:30 pm
by Little_man
Normeus,

Thank you for the code but then I have another question; how to remove the square in front of the text.

Kind regards,
Little_man

Re: [Module] pbPDF-Module

Posted: Sun Dec 18, 2022 8:16 pm
by normeus
Make sure you have the latest pbPDF-Module.
pbPDF-Module

Code: Select all

;/ [ PB V5.7x / All OS ]
;/
;/  © 2022 Thorsten1867 (12/2018)
;/ ( based on 'PurePDF' by LuckyLuke / ABBKlaus / normeus )
;/

; Last Update: 04.05.2022
[edit: figured out that to add images the URL has to end in an actual png or jpg file. It can not be an econded name like "Tq6cC"]
here's a link to an img with the results I don't get a square, with the sample code I posted:
Image

Norm.

Re: [Module] pbPDF-Module

Posted: Mon Dec 19, 2022 6:31 pm
by Little_man
Normeus,

Problem solved, there was an issue with me !!..

Kind regards,
Little_man

Re: [Module] pbPDF-Module

Posted: Thu Jul 20, 2023 5:40 pm
by skinkairewalker
have a way to import other pdf and edit it ?

Re: [Module] pbPDF-Module

Posted: Thu Jul 20, 2023 6:05 pm
by normeus
Infratec has some code, using PDFium.dll that might do what you need here:

viewtopic.php?p=553210#p553210

Norm

Re: [Module] pbPDF-Module

Posted: Thu Jul 20, 2023 9:20 pm
by skinkairewalker
I would like to add text, images and etc to an existing pdf exported from an office [ word ]

Re: [Module] pbPDF-Module

Posted: Tue Oct 17, 2023 4:39 pm
by normeus
PB ide v6.03 has a new check for invalid Chr() numbers. You get a compile error, @idle placed a request to change the error to a warning on October 16, 20023. viewtopic.php?p=609396#p609396

If you compile pbPDF-Module and you get an error Chr() out of range, alternative is to compile from the command line. If you are using English for the pdfs you create with pbPDF-Module then you can do the following change to be able to compile from IDE:

Code: Select all

;around line 5893
              For i=0 To 65535
                If i >= 55296 And i<=57343 ; skip the chraracters ide now marks as error
                Continue
                Else
                If FindMapElement(PDF()\Fonts()\CharWidth(), Chr(i))
                  objStrg + Str(i) + " [" + Str(PDF()\Fonts()\CharWidth(Chr(i))) + "] "
                EndIf
                EndIf
              Next   
It might work for other languages, but I only tried it using English.
Here is a link to @idle's UTF16 module:(it's a nice read, for people using different languages of the world in their programs)
viewtopic.php?p=592461#p592461

Thank you.
Norm.

Re: [Module] pbPDF-Module

Posted: Thu Nov 16, 2023 1:18 pm
by Jan2004
Thorsten1867 thank you for a great library. I am interested in the use of Polish letters. The example provided by normeus works very well. For several days I tried to use other fonts, Windows system fonts and the Lato font. However, this did not produce the expected result. Maybe my dear colleagues will tell how to use Windows system fonts for polish letters and why the example below, based on normeus example, with Lato fonts does not work. Lato fonts can be downloaded here:
https://www.latofonts.com/lato-free-fonts/

Code: Select all

XIncludeFile "..\pbPDFModule.pbi"

Define File$="pbPDF-Example_forLato.pdf"
#PDF = 1
;  Create an instance of PDF
If PDF::Create(#PDF)
  ;  Always add a page to create a PDF or you'll get an error
  ;  Page size and orientation is optional, I like to add it because you can have multiple page sizes in a PDF   
  PDF::AddPage(#PDF,PDF::#Landscape,PDF::#format_letter)
  
  ; specialty unicode font, which contains the character you need
  PDF::EMbedFont(#PDF, "C:\WINDOWS\Fonts\Lato-Light.ttF","Lato","",PDF::#Unicode)
  
  PDF::SetFont(#PDF, "lato", "", 14)
  PDF::PlaceText(#PDF, "This is font Lato for Styczeń  or other polish letters: ŻŹĆŃŁÓĄŚĘĘ żźćńłóśąę", 10, 50)
  
  PDF::Close(#PDF, File$)
  
EndIf

RunProgram(File$)

Re: [Module] pbPDF-Module

Posted: Thu Nov 16, 2023 7:24 pm
by normeus
Sorry that was part of the code I added. It should give you an error with font file not found. That's the problem, the file is not there. I'll have time to look at the code later today, I hope, meantime try this:

Code: Select all

  PDF::EMbedFont(#PDF,"c:/Users/"+UserName()+"/appdata/local/microsoft/windows/fonts/LATO-BLACK.TTF","Lato","",PDF::#Unicode)
  
  PDF::SetFont(#PDF, "Lato", "", 14)
Notice that I used Lato black because Lato-Light does not show the special characters, you can also just unzip the fonts to a folder and call them for that folder.

Norm