本文整理汇总了C#中Doc.GetInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Doc.GetInfo方法的具体用法?C# Doc.GetInfo怎么用?C# Doc.GetInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc.GetInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
// install your own licence
using (Doc doc = new Doc())
{
doc.Read("in.pdf"); // in this PDF the image has an embedded ICC profile, and I must remove them
Console.WriteLine("################################ THROUGH GETINFO ################################");
// Remove the ICC profiles through Get/SetInfo methods
foreach (var item in doc.ObjectSoup)
{
if (item != null && doc.GetInfo(item.ID, "/ColorSpace*[0]*:Name").Equals("ICCBased", StringComparison.InvariantCultureIgnoreCase))
{
int profileId = doc.GetInfoInt(item.ID, "/ColorSpace*[1]:Ref"); // note the [1]: why is it there?
if (profileId != 0)
{
doc.GetInfo(profileId, "Decompress");
string profileData = doc.GetInfo(profileId, "Stream");
// this outputs the ICC profile raw data, with the profile's name somewhere up top
Console.WriteLine(string.Format("ICC profile for object ID {0}: {1}", item.ID, profileData));
doc.SetInfo(profileId, "Stream", string.Empty);
doc.GetInfo(profileId, "Compress");
}
}
}
doc.Save("out-infos.pdf");
doc.Clear();
doc.Read("in.pdf");
Console.WriteLine("################################ THROUGH OBJECTS ################################");
// Remove ICC profiles through the pixmap objects
foreach (var item in doc.ObjectSoup)
{
if (doc.GetInfo(item.ID, "Type") == "jpeg") // only work on PixMaps
{
PixMap pm = (PixMap)item;
if (pm.ColorSpaceType == ColorSpaceType.ICCBased)
{
// pm.ColorSpace.IccProfile is always null so I can't really set it to null or Recolor() it because it would change noting
Console.WriteLine(string.Format("ICC profile for object ID {0}: {1}", item.ID, pm.ColorSpace.IccProfile)); // there should already be an ICC profile (ColorSpaceType = ICCBased) so why does ColorSpace.IccProfile creates one ?
}
}
}
doc.Save("out-objects.pdf");
}
}
示例2: ConvertHTMLToPDF
private void ConvertHTMLToPDF(string htmlString, string fullPDFFilePath)
{
Doc theDoc = new Doc();
//theDoc.HtmlOptions.Engine = EngineType.Gecko;
theDoc.Rect.Inset(8, 8);
int theID = theDoc.AddImageHtml(htmlString, true, 0, true);
while (true)
{
//theDoc.FrameRect();
if (theDoc.GetInfo(theID, "Truncated") != "1")
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
if (File.Exists(fullPDFFilePath))
File.Delete(fullPDFFilePath);
theDoc.Save(fullPDFFilePath);
theDoc.Clear();
}