» Author Archive

Font CharSet and Encoding

Wednesday, July 16th, 2008 by rubypdf

yesterday, A Chinese developer sent me WMF with Chinese character, and the FontFace name is also Chinese, he said the iTextSharp could convert the WMF to PDF correctly. so I try to debug into the source code, and find MetaFont only support ASCII.

try {
faceName = System.Text.Encoding.GetEncoding(1252).GetString(name, 0, k);
}
catch {
faceName = System.Text.ASCIIEncoding.ASCII.GetString(name, 0, k);
}

but charset of Chinese font(GB2312) is 134, so I think the source code needs to get encoding from charset, and then get the right faceName.
Finally, I get the following codes,

public enum FontCharSet : byte
{
ANSI_CHARSET = 0,// ANSI charset (Windows-1252)
DEFAULT_CHARSET = 1,
SYMBOL_CHARSET = 2,
MAC_CHARSET = 77,
SHIFTJIS_CHARSET = 128,// Shift JIS charset (Windows-932)
HANGEUL_CHARSET = 129,// Hangeul charset (Windows-949)
HANGUL_CHARSET = 129,
JOHAB_CHARSET = 130, // Johab charset (Windows-1361)
GB2312_CHARSET = 134,// GB2312 charset (Windows-936)
CHINESEBIG5_CHARSET = 136,// Chinese Big5 charset (Windows-950)
GREEK_CHARSET = 161, // Greek charset (Windows-1253)
TURKISH_CHARSET = 162,// Turkish charset (Windows-1254)
VIETNAMESE_CHARSET = 163,// Vietnamese charset (Windows-1258)
HEBREW_CHARSET = 177,// Hebrew charset (Windows-1255)
ARABIC_CHARSET = 178,// Arabic charset (Windows-1256)
BALTIC_CHARSET = 186,// Baltic charset (Windows-1257)
RUSSIAN_CHARSET = 204,// Cyrillic charset (Windows-1251)
THAI_CHARSET = 222,// Thai charset (Windows-874)
EASTEUROPE_CHARSET = 238, // Eastern european charset (Windows-1250)
OEM_CHARSET = 255,
}

and some very useful source codes( WMFUtilities.java and WMFConstants.java ) file from Apache Batik, it has implement the charset issue.

BTW, iText also has the same issue,

187 try {
188 font = BaseFont.createFont(fontName, "Cp1252", false);
189 }
190 catch (Exception e) {
191 throw new ExceptionConverter(e);
192 }

Download Adobe Acrobat 9 Pro Extended Trail Now

Thursday, July 3rd, 2008 by rubypdf

Adobe Acrobat 9 Pro Extended and Adobe Acrobat 9 Pro are out, you can download it now.

Adobe Acrobat 9 Pro Extended is the complete PDF solution for business and technical professionals. It includes all the features and functionality of Acrobat 9 Pro, plus the ability to unify the widest range of content in a PDF Portfolio, create interactive presentations with Adobe Presenter software, easily convert and share video in PDF, create PDF maps, convert virtually any 2D and 3D designs to PDF, and enjoy expanded 3D capabilities with the new Adobe 3D Reviewer.
Adobe Acrobat 9 Pro helps business and creative professionals communicate and collaborate more effectively and securely with virtually anyone, anywhere. Unify a wide range of content in a single organized PDF Portfolio. Collaborate through electronic document reviews. Create and manage dynamic forms. And help protect sensitive information. Acrobat 9 Pro includes Adobe LiveCycle® Designer ES software for advanced form creation.

Download now
Adobe Acrobat 9 Pro

Batch Import XML to MS Access Database

Wednesday, July 2nd, 2008 by rubypdf

A requirement of my customer is as follow,

In access there’s the possibilities to import an xml file into a table but the problem is that the procedure is manual and is possible to import a file once a time. I ask you if you can develop a VB utility trough out I can select a list of XML files and append them to a specific table.

After researched, i knew, he means ImportXML Method,

Imports data and/or presentation information for a Microsoft Access object from an XML file or files.

expression.ImportXML(DataSource, DataTransform, OtherFlags)

expression   Required. An expression that returns an Application object.

DataSource  Required String. The name and path of the XML file to import.

DataTransform  Optional String. The name of the XSL file to apply to the incoming XML data.

OtherFlags  Optional Long. A bit mask which specifies other behaviors associated with importing from XML. The following table describes the behavior that results from specific values; values can be added to specify a combination of behaviors.

Value Description
1 Overwrite  The import file silently overwrites the target should it already exist.
2 Don’t create structure  By default, new structures are created. If Overwrite is not set, an alert asks the user for permission to overwrite.
4 Don’t import data  By default, data is imported when a data document is used to create a schema.

Example

The following example imports an XML file representing a table called Invoices into the current database. Access overwrites the Invoices table if it already exists.

Application.ImportXML _
    DataSource:=”C:\XMLData\Invoices.xml”, _
    OtherFlags:=1

It is very easy to implement, but any way, it is a very useful utility.