iText中的文字大纲 [英] Text Outlines in iText
问题描述
我正在尝试保存将文本转换为轮廓的PDF(根据打印机的要求),但似乎无法使其正常工作。我在iText的网站上找到了一个例子的参考,但从那时起他们就改变了他们的网站,我现在似乎无法找到它。我目前正在嵌入字体并且效果很好,但不知道如何将其展平以便将文本转换为轮廓。我正在使用iText 5.5.11 for Java。
I'm attempting to save a PDF converting the text to outlines (as required by the printer) but cannot seem to make it work. I found a reference to an example on iText's site, but they have changed their site since then and I can't seem to find it now. I am currently embedding the font and that works great, but have no idea how to flatten it so that the text is converted to outlines. I'm using iText 5.5.11 for Java.
推荐答案
如果你使用的是acrobat和.Net,
你可以使用acrobat iac调用javescript将其保存为eps,这是字体概述。
If you are using acrobat and .Net, you can use acrobat iac to invoke javescript to save it to eps which is font outlined.
请参阅JSObjectControlCS示例和javascript SaveAs参考
See JSObjectControlCS sample and javascript SaveAs Reference
以下是我的工作样本
///fsharp codes
let saveToEPS src dest =
let avDoc = new AcroAVDocClass()
avDoc.Open(src,"") |> ignore
let pdDoc = avDoc.GetPDDoc() :?> CAcroPDDoc
let jsObj = pdDoc.GetJSObject()
let t = jsObj.GetType()
t.InvokeMember(
"saveAs",
BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.Instance,
null,
jsObj,
[|box dest; box "com.adobe.acrobat.eps"|]
)
|> ignore
更新:
保存到eps之前,我们必须添加使用转换字体概述预检
let convertToOutlinesScript = """
var oProfile = Preflight.getProfileByName("Convert fonts to outlines");
var oThermometer = app.thermometer;
var myPreflightResult = this.preflight( oProfile, false, oThermometer);
if( myPreflightResult.numErrors > 0 ) {
console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
} """
t.InvokeMember(
"setAction",
BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.Instance,
null,
jsObj,
[|box "WillSave"; box convertToOutlinesScript|]
) |> ignore
这篇关于iText中的文字大纲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!