本文整理汇总了C#中Doc.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Doc.Save方法的具体用法?C# Doc.Save怎么用?C# Doc.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc.Save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Main
static void Main(string[] args)
{
System.Console.WriteLine("Enter the name of the output pdf file:");
var fileName = System.Console.ReadLine();
fileName = fileName.Replace(".pdf", "");
fileName = fileName.Replace(".PDF", "");
Doc theDoc = new Doc();
theDoc.Rect.Inset(72, 144);
theDoc.HtmlOptions.AddLinks = true;
int theID;
theID = theDoc.AddImageUrl("http://www.yahoo.com/");
while (true)
{
theDoc.FrameRect();
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
theDoc.Save(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), fileName + ".pdf"));
theDoc.Clear();
}
示例3: ExportPdf
public ActionResult ExportPdf()
{
StreamReader sr = new StreamReader(@"D:\Code\C#\SmallDragon\SmallDragon\Temp\HtmlPage3.html");
string html = sr.ReadToEnd();
Doc doc = new Doc();
doc.AddImageHtml(html);
doc.Save(@"C:\Users\GuyFawkes\Desktop\New folder\out.pdf");
doc.Clear();
System.Diagnostics.Process.Start(@"C:\Users\GuyFawkes\Desktop\New folder\out.pdf");
return View("Index");
}
示例4: Control
public void Control()
{
var connectionString = ConfigurationManager.ConnectionStrings["LicenseKey"].ConnectionString;
XSettings.InstallLicense(connectionString);
var theDoc = new Doc { FontSize = 96 };
theDoc.AddText("Control");
Response.ContentType = "application/pdf";
theDoc.Save(Response.OutputStream);
theDoc.Clear();
theDoc.Dispose();
}
示例5: createPdf
public static bool createPdf(long kid,string klotterno,string email)
{
string contents = string.Empty;
MemoryStream ms = new MemoryStream();
try {
int id;
Doc doc = new Doc();
doc.MediaBox.String = "A4";
doc.Rect.String = doc.MediaBox.String;
//doc.Rect. = doc.CropBox;
doc.HtmlOptions.BrowserWidth = 980;
doc.HtmlOptions.FontEmbed = true;
doc.HtmlOptions.FontSubstitute = false;
doc.HtmlOptions.FontProtection = false;
doc.HtmlOptions.ImageQuality = 33;
Random rnd = new Random();
id = doc.AddImageUrl("http://" + HttpContext.Current.Request.Url.Host + "/Documents/klotter_pdf.aspx?id=" + kid.ToString() + "&uid="+ email +"&rnd=" + rnd.Next(50000));
while (true) {
//doc.FrameRect();
if (!doc.Chainable(id)) {
break;
}
doc.Page = doc.AddPage();
id = doc.AddImageToChain(id);
}
for (int i = 0; i < doc.PageCount; i++) {
doc.PageNumber = i;
doc.Flatten();
}
//doc.AddImageHtml(contents);
//doc.Save(Server.MapPath("htmlimport.pdf"));
doc.Save(ms);
//doc.SaveOptions.
doc.Clear();
bool mail = Common.PdfMail(ms, email, "Klotter");
if (mail) {
return AmazonHandler.PutPdfKlotter(ms, klotterno, 0);
}
return false;
//}
} catch (Exception ex) {
return false;
}
}
示例6: createPdf
public static bool createPdf(long jid,string journo,string email)
{
string contents = string.Empty;
MemoryStream ms = new MemoryStream();
try {
int id;
Doc doc = new Doc();
doc.MediaBox.String = "A4";
doc.HtmlOptions.BrowserWidth = 980;
doc.HtmlOptions.FontEmbed = true;
doc.HtmlOptions.FontSubstitute = false;
doc.HtmlOptions.FontProtection = false;
doc.HtmlOptions.ImageQuality = 33;
Random rnd = new Random();
id = doc.AddImageUrl("http://" + HttpContext.Current.Request.Url.Host + "/Documents/jour_pdf.aspx?id=" + jid.ToString() + "&uid="+ email +"&rnd=" + rnd.Next(50000));
while (true) {
//doc.FrameRect();
if (!doc.Chainable(id)) {
break;
}
doc.Page = doc.AddPage();
id = doc.AddImageToChain(id);
}
doc.Rect.String = "10 780 595 840";
doc.HPos = 0.5;
doc.VPos = 0.0;
doc.Color.String = "0 255 0";
doc.FontSize = 36;
for (int i = 1; i <= doc.PageCount; i++) {
doc.PageNumber = i;
id = doc.AddImageUrl("http://" + HttpContext.Current.Request.Url.Host + "/Documents/header.aspx?id=" + jid.ToString() + "&rnd=" + rnd.Next(50000));
}
doc.Rect.String = "10 0 585 100";
doc.HPos = 0.5;
doc.VPos = 1.0;
//doc.FontSize = 36;
//for (int i = 1; i <= doc.PageCount; i++) {
doc.PageNumber = 1;
id = doc.AddImageUrl("http://" + HttpContext.Current.Request.Url.Host + "/Documents/footer.aspx?rnd=" + rnd.Next(50000));
//doc.AddText("Page " + i.ToString() + " of " + doc.PageCount.ToString());
//doc.FrameRect();
//}
for (int i = 0; i < doc.PageCount; i++) {
doc.PageNumber = i;
doc.Flatten();
}
//doc.AddImageHtml(contents);
//doc.Save(Server.MapPath("htmlimport.pdf"));
doc.Save(ms);
//doc.SaveOptions.
doc.Clear();
bool mail = Common.PdfMail(ms, email);
if (mail) {
return AmazonHandler.PutPdfJour(ms, journo);
}
return false;
//}
} catch (Exception ex) {
return false;
}
}
示例7: 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();
}
示例8: printbutton_Click
protected void printbutton_Click(object sender, EventArgs e)
{
//if (pdf_synced) {
//} else {
string contents = string.Empty;
MemoryStream ms = new MemoryStream();
try {
Doc doc = new Doc();
doc.MediaBox.String = "A4";
doc.HtmlOptions.BrowserWidth = 980;
doc.HtmlOptions.FontEmbed = true;
doc.HtmlOptions.FontSubstitute = false;
doc.HtmlOptions.FontProtection = false;
doc.HtmlOptions.ImageQuality = 33;
int id = 0;
Random rnd = new Random();
id = doc.AddImageUrl("http://" + Request.Url.Host + "/Documents/jour_pdf.aspx?id=" + jourid.ToString() + "&rnd=" + rnd.Next(50000));
while (true) {
//doc.FrameRect();
if (!doc.Chainable(id)) {
break;
}
doc.Page = doc.AddPage();
id = doc.AddImageToChain(id);
}
doc.Rect.String = "10 780 595 840";
doc.HPos = 0.5;
doc.VPos = 0.0;
doc.Color.String = "0 255 0";
doc.FontSize = 36;
for (int i = 1; i <= doc.PageCount; i++) {
doc.PageNumber = i;
id = doc.AddImageUrl("http://" + Request.Url.Host + "/Documents/header.aspx?id=" + jourid.ToString() +"&rnd=" + rnd.Next(50000));
}
doc.Rect.String = "10 0 585 100";
doc.HPos = 0.5;
doc.VPos = 1.0;
//doc.FontSize = 36;
//for (int i = 1; i <= doc.PageCount; i++) {
doc.PageNumber = 1;
id = doc.AddImageUrl("http://" + Request.Url.Host + "/Documents/footer.aspx?rnd=" + rnd.Next(50000));
//doc.AddText("Page " + i.ToString() + " of " + doc.PageCount.ToString());
//doc.FrameRect();
//}
for (int i = 0; i < doc.PageCount; i++) {
doc.PageNumber = i;
doc.Flatten();
}
//doc.AddImageHtml(contents);
//doc.Save(Server.MapPath("htmlimport.pdf"));
doc.Save(ms);
//doc.SaveOptions.
doc.Clear();
bool success = AmazonHandler.PutPdfJour(ms, journo);
if (success) {
Response.Write("SUCCESS!!!!");
} else {
Response.Write("FAIL!!!!");
}
//}
} catch (Exception ex) {
Response.Write(ex.Message);
}
//}
}
示例9: CreatePDFFetched
private void CreatePDFFetched(EngineType engine)
{
var connectionString = ConfigurationManager.ConnectionStrings["LicenseKey"].ConnectionString;
XSettings.InstallLicense(connectionString);
var theDoc = new Doc();
theDoc.HtmlOptions.Engine = engine;
theDoc.HtmlOptions.UseScript = false;
theDoc.HtmlOptions.BrowserWidth = 800;
theDoc.HtmlOptions.ForGecko.UseScript = false;
theDoc.Rendering.DotsPerInch = 300;
theDoc.HtmlOptions.ForGecko.InitialWidth = 800;
theDoc.Rect.Inset(18, 18);
theDoc.Page = theDoc.AddPage();
int theID = theDoc.AddImageUrl("http://woot.com/", true, 800, true);
while (true)
{
theDoc.FrameRect(); // add a black border
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
Response.Buffer = false;
Response.AddHeader("Content-Disposition", "inline; filename=\"rept.pdf\"");
Response.ContentType = "application/pdf";
theDoc.Save(Response.OutputStream);
Response.Flush();
}
示例10: printbutton_Click
protected void printbutton_Click(object sender, EventArgs e)
{
string contents = string.Empty;
MemoryStream ms = new MemoryStream();
//using (StringWriter sw = new StringWriter()) {
// Server.Execute("Documents/report.aspx", sw);
// contents = sw.ToString();
// sw.Close();
//}
try {
Doc doc = new Doc();
//int font = doc.EmbedFont(Server.MapPath("Documents/") + "OpenSans-Regular-webfont.ttf", LanguageType.Unicode);
//font = doc.EmbedFont(Server.MapPath("Documents/") + "OpenSans-Light-webfont.ttf", LanguageType.Unicode);
doc.HtmlOptions.BrowserWidth = 960;
doc.HtmlOptions.FontEmbed = true;
doc.HtmlOptions.FontSubstitute = false;
doc.HtmlOptions.FontProtection = false;
int id = 0;
Random rnd = new Random();
//id = doc.AddImageUrl("http://" + Request.Url.Host + "/documents/bygg.aspx?rnd=" + rnd.Next(50000));
id = doc.AddImageUrl("http://localhost:50030/Documents/jour.aspx?rnd=" + rnd.Next(50000));
while (true) {
//doc.FrameRect();
if (!doc.Chainable(id)) {
break;
}
doc.Page = doc.AddPage();
id = doc.AddImageToChain(id);
}
for (int i = 0; i < doc.PageCount; i++) {
doc.PageNumber = i;
doc.Flatten();
}
//doc.AddImageHtml(contents);
//doc.Save(Server.MapPath("htmlimport.pdf"));
doc.Save(ms);
//doc.SaveOptions.
doc.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename=File-{0}.pdf", 1));
Response.BinaryWrite(ms.ToArray());
Response.End();
//}
} catch (Exception ex) {
Response.Write(ex.Message);
}
}