Max*_*Max 1 pdf flash scripting fonts extract
是否可以使用某个实用程序或脚本将嵌入在PDF文件中的字体提取到外部ttf文件?
如果系统中存在嵌入(或未嵌入)PDF文件的字体.使用swftools中的pdf2swf和swfextract工具,我可以确定PDF文件中使用的字体的名称.然后我可以在运行时编译各自的系统字体,然后加载到我的AIR应用程序.
但如果系统中没有PDF中使用的字体,则有两种可能:
2.1.如果它们在PDF文件中也不存在(未嵌入),我们只能使用基于字体名称的类似系统字体.
2.2.如果它们嵌入在PDF文件中,那么我想知道是否有可能将它们提取到外部ttf文件,以便我可以在运行时编译它们以分离swf文件?
我知道你问这个问题已经有一段时间了,但我想我可以帮忙.
我不知道是否有任何实用程序可以让你解压缩Font文件,但你可以手动完成.
基本上PDF文件是具有不同对象的文本文件.您可以使用任何文本编辑器打开它并查找字体.
字体在FontDescriptor对象中指定,例如:
<</Type/FontDescriptor/FontName/ABCDEE+Algerian ... /FontFile2 24 0 R>>
Run Code Online (Sandbox Code Playgroud)
这基本上说,在对象24上指定了一个名为Algerian的字体.您可以使用"24 0 obj"行在文档中搜索对象24,在此行之后,它会显示带有字体文件的流的属性并在"stream"关键字之后开始(其长度在obj之后的行中定义).
这个流包含压缩的ttf文件,要解压缩它你可以使用这个方法:
private static byte[] DecodeFlateDecodeData(byte[] data)
{
MemoryStream outputStream;
using (outputStream = new MemoryStream())
{
using (var compressedDataStream = new MemoryStream(data))
{
// Remove the first two bytes to skip the header (it isn't recognized by the DeflateStream class)
compressedDataStream.ReadByte();
compressedDataStream.ReadByte();
var deflateStream = new DeflateStream(compressedDataStream, CompressionMode.Decompress, true);
var decompressedBuffer = new byte[1024];
int read;
while ((read = deflateStream.Read(decompressedBuffer, 0, decompressedBuffer.Length)) != 0)
{
outputStream.Write(decompressedBuffer, 0, read);
}
outputStream.Flush();
compressedDataStream.Close();
}
return GetStreamBytes(outputStream);
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这可以帮助你......或者帮助别人