TCPDF - How to generate a TTF file from PHP? - tcpdf

I am using TCPDF 6.0.20, PHP 5.3.8.
Since my PDF will contain some Chinese Character (Simplified and Traditional), I decide to use font name: cid0cs.
Now, since a lot of users replied that they don't have that font installed, I need to embed this font to the PDF.
However, in http://www.tcpdf.org/fonts.php it says how to embed a TTF file using addTTFfont(), but NO WAY to create that font.
The only file that I found in tcpdf/fonts/ is cid0cs.php, which is NOT a TTF file.
I tried to run the script in tcpdf/tools/tcpdf_addfont.php and use the command line below:
c:\tcpdf>php tools/tcpdf_addfont.php -t CID0CS -o . -i fonts/cid0cs.php
and it returns:
--- ERROR: can't add fonts/cid0cs.php
How can I create the cid0cs.ttf file so that I can embed it using addTTFfont()?

I found the solution and record the process in my blog post below:
http://alucard-blog.blogspot.hk/2013/06/tcpdf-how-to-display-chinese-character.html
The key point is: I found the font that can display Traditional and Simplified Chinese.

cmd and run php
run this command : \ABSOLUTE PATH TO\tcpdf_addfont.php -i \ABSOLUTE PATH TO\myfont.ttf
if it works fine, you will find 3 files of myfont in /TCPDF/fonts
you might find some help here : http://queirozf.com/entries/adding-a-custom-font-to-tcpdf

Related

How to set font in Texinfo

I'm using the GNU texinfo package to generate both PDF and .info files from a .texi file.
I'm trying to update an old .texi file (not changed since 2001) and generate the same PDF output. I've resolved a number of issues, but there are a couple outstanding. In the old PDF, the title was in Helvetica and body text is Liberation Serif. In the new PDF, both are Computer Modern.
I've read everything that I can find about fonts, but I'm not able to change the fonts. Nothing that I do seems to work. Everything I have tried generates errors.
In my .texi file, before any \setfont directives, I have \def\fontprefix{uh} which, if I read the pdftex.map file correctly, should select the NimbusSanL font set (e.g. uhvr8a.pfb). I get the following errors:
mktexnam: Could not map source abbreviation for uhss10.
kpathsea: Running mktexmf uhss10
! I can't find file uhss10'.
<*> ...ljfour; mag:=1; ; nonstopmode; input uhss10`
Does anyone have a example .texi file which sets the font family to use? Or an explanation of what I'm doing wrong?

Dynamically use current date in OUTPUT EXPORT filename

Stripped down example code using a static file name:
OUTPUT EXPORT /CONTENTS EXPORT=ALL /PDF DOCUMENTFILE='example.pdf'
My question is how to generate a datestamped file. I have tried using $DATE, '$DATE' and running it through a macro but can't seem to find the syntax.
Hey this is a really nice Idea for saving backups in a running syntax production - I will use this myself from now on :) .
So the following syntax works for me:
compute tdy= $time.
formats tdy (date11).
temporary.
select if $casenum=1.
write out="somepath\datemacro.sps" /"define !dated__filename () !quote(!concat('YOUR FILE NAME',' ','", tdy, "','.pdf')) !enddefine.".
exe.
Insert file ="somepath\datemacro.sps".
delete vars tdy.
The file name you used in the code above is now stored in a macro with the date added, and you can use it here:
OUTPUT EXPORT /CONTENTS EXPORT=ALL /PDF DOCUMENTFILE= !dated__filename .
Note that you can change "YOUR FILE NAME" into anything you like, including adding a path. And you can also change ".pdf" so save other kinds of files.
EDIT: Also of course change "somepath" to a valid path on your machine.

How to fix internal link issues when publishing a Docusaurus site on GitLab pages

In my Docusaurus project my internal links work on my local environment, but when I push to GitLab they no longer work. Instead of replacing the original doc title with the new one it adds it to the url at the end ('https://username.io/test-site/docs/overview/add-a-category.html'). I looked over my config file, but I do not understand why this is happening.
I tried updating the id in the front matter for the page, and making sure it matches the id in the sidebars.json file. I have also added customDocsPath and set it to 'docs/' in the config file, though that is supposed to be the default.
---
id: "process-designer-overview"
title: "Process Designer Overview"
sidebar_label: "Overview"
---
# Process Designer
The Process Designer is a collaborative business process modeling and
design workspace for the business processes, scenarios, roles and tasks
that make up governed data processes.
Use the Process Designer to:
- [Add a Category](add-a-category.html)
- [Add a Process or Scenario](Add%20a%20Process%20or%20Scenario.html)
- [Edit a Process or Scenario](Edit%20a%20Process%20or%20Scenario.html)
I updated the add a category link in parenthesis to an md extension, but that broke the link on my local and it still didn't work on GitLab. I would expect that when a user clicks on the link it would replace the doc title in the url with the new doc title ('https://username.gitlab.io/docs/add-a-category.html') but instead it just tacks it on to the end ('https://username.gitlab.io/docs/process-designer-overview/add-a-category.html') and so the link is broken as that is not where the doc is located.
There were several issues with my links. First, I converted these files from html to markdown using Pandoc and did not add front matter - relying instead on the file name to connect my files to the sidebars. This was fine, except almost all of the file names had spaces in them, which you can see in my code example above. This was causing real issues, so I found a Bash script to replace all of the spaces in my file names with underscores, but now all of my links were broken. I updated all of the links in my files with a search and replace in my code editor, replacing "%20" with "_". I also needed to replace the ".html" extension with ".md" or my project would no longer work locally. Again, I did this with a search and replace in my code editor.
Finally, I ended up adding the front matter because otherwise my sidebar titles were all covered in underscores. Since I was working with 90 files, I didn't want to do this manually. I looked for a while and found a great gist by thebearJew and adjusted it so that it would take the file name and add it as the id, and the first heading and add it as the title and sidebar_label, since as it happens that works for our project. Here is the Bash script I found online to convert the spaces in my file names to underscores if interested:
find $1 -name "* *.md" -type f -print0 | \
while read -d $'\0' f; do mv -v "$f" "${f// /_}"; done
Here is the script I ended up with if anyone else has a similar setup and doesn't want to update a huge amount of files with front matter:
# Given a file path as an argument
# 1. get the file name
# 2. prepend template string to the top of the source file
# 3. resave original source file
# command: find . -name "*.md" -print0 | xargs -0 -I file ./prepend.sh file
filepath="$1"
file_name=$("basename" -a "$filepath")
# Getting the file name (title)
md='.md'
title=${file_name%$md}
heading=$(grep -r "^# \b" ~/Documents/docs/$title.md)
heading1=${heading#*\#}
# Prepend front-matter to files
TEMPLATE="---
id: $title
title: $heading1
sidebar_label: $heading1
---
"
echo "$TEMPLATE" | cat - "$filepath" > temp && mv temp "$filepath"

How bobril translation import/export works in bobril-build?

How bb translation works together?
When I used bb b -l 1 worked fine but there is still needed to rewrite all strings for other languages.
bb t -a adds new language, e.g. "cs-CZ" and creates json file with language code.
The question is how can I export/import all strings into json file to translation?
bb t -e - fileName is json or js in dist? Export doesn't work in my case no strings are exported.
bb t -e filename.txt -l cs-CZ is correct way to export untranslated strings to text file with very simple structure. After it will get back from translation agency you can just import it by bb t -i filename.txt -l cs-CS.
Before exporting always update translation files by bb b -l 1 -u 1 as you already find out. Actual JSON files in translations directory contains array of arrays of 3 or 4 items [original, hint, 0/1 - with/out parameters, translation]. So you can directly translate them if you will create some editor for these...
Also please update bobril-build to 0.56.1, I just fixed wrong error message in export even-though everything was ok. Maybe that confuse you so you have to ask, sorry for that.

Compare tool with command line for mac

I am looking for command line tool to do diff between two HTML files.
I have analysed kdiff3/command line of bbedit but my problem is dont want to open any GUI.
I want to write a java program to call command line options of the diff program to compare html files and save result in a different file or probably show in a report file.
Any pointers will be very helpful
Thanks
Vishal
If you have xcode installed, you can call up opendiff, it's a (graphical) compare tool from the command line. From it's man page:
opendiff file1 file2 [-ancestor ancestorFile] [-merge mergeFile]
opendiff dir1 dir2 [-ancestor ancestorDirectory] [-merge mergeDirectory]
I thought mac had diff built in. Have you tried using diff from the mac terminal?

Resources