本文整理汇总了C#中iTextSharp.tool.xml.pipeline.html.HtmlPipelineContext.SetPageSize方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlPipelineContext.SetPageSize方法的具体用法?C# HtmlPipelineContext.SetPageSize怎么用?C# HtmlPipelineContext.SetPageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.tool.xml.pipeline.html.HtmlPipelineContext
的用法示例。
在下文中一共展示了HtmlPipelineContext.SetPageSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakePdf
protected override void MakePdf(string outPdf) {
Document doc = new Document(PageSize.A4.Rotate());
PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(outPdf, FileMode.Create));
doc.SetMargins(45, 45, 0, 100);
doc.Open();
CssFilesImpl cssFiles = new CssFilesImpl();
cssFiles.Add(
XMLWorkerHelper.GetCSS(
File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
"main.css")));
cssFiles.Add(
XMLWorkerHelper.GetCSS(
File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
"widget082.css")));
StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
HtmlPipelineContext hpc =
new HtmlPipelineContext(
new CssAppliersImpl(new XMLWorkerFontProvider(RESOURCES + @"\tool\xml\examples\fonts")));
hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(Tags.GetHtmlTagProcessorFactory());
hpc.SetImageProvider(new SampleTestImageProvider());
hpc.SetPageSize(doc.PageSize);
HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, pdfWriter));
IPipeline pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser p = new XMLParser(true, worker, Encoding.GetEncoding("UTF-8"));
p.Parse(File.OpenRead(inputHtml), Encoding.GetEncoding("UTF-8"));
doc.Close();
}
示例2: MakePdf
protected override void MakePdf(string outPdf) {
Document doc = new Document(PageSize.A3.Rotate());
PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(outPdf, FileMode.Create));
pdfWriter.CreateXmpMetadata();
doc.SetMargins(200, 200, 0, 0);
doc.Open();
CssFilesImpl cssFiles = new CssFilesImpl();
cssFiles.Add(
XMLWorkerHelper.GetCSS(
File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
"main.css")));
cssFiles.Add(
XMLWorkerHelper.GetCSS(
File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
"widget082.css")));
StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
HtmlPipelineContext hpc =
new HtmlPipelineContext(
new CssAppliersImpl(new XMLWorkerFontProvider(RESOURCES + @"\tool\xml\examples\fonts")));
hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(Tags.GetHtmlTagProcessorFactory());
hpc.SetImageProvider(new SampleTestImageProvider());
hpc.SetPageSize(doc.PageSize);
HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, pdfWriter));
IPipeline pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser p = new XMLParser(true, worker, Encoding.GetEncoding("UTF-8"));
p.Parse(File.OpenRead(inputHtml), Encoding.GetEncoding("UTF-8"));
//ICC_Profile icc = ICC_Profile.getInstance(ComplexDiv01Test.class.getResourceAsStream("sRGB Color Space Profile.icm"));
//pdfWriter.setOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
doc.Close();
}
示例3: Clone
/**
* Create a clone of this HtmlPipelineContext, the clone only contains the
* initial values, not the internal values. Beware, the state of the current
* Context is not copied to the clone. Only the configurational important
* stuff like the LinkProvider (same object), ImageProvider (new
* {@link AbstractImageProvider} with same ImageRootPath) ,
* TagProcessorFactory (same object), acceptUnknown (primitive), charset
* (Charset.forName to get a new charset), autobookmark (primitive) are
* copied.
*/
virtual public object Clone()
{
CssAppliers cloneCssApliers = this.cssAppliers.Clone();
HtmlPipelineContext newCtx = new HtmlPipelineContext(cloneCssApliers);
if (this.imageProvider != null)
{
newCtx.SetImageProvider(imageProvider);
}
if (null != this.charset)
{
newCtx.CharSet(Encoding.GetEncoding(this.charset.CodePage));
}
newCtx.SetPageSize(new Rectangle(this.pageSize)).SetLinkProvider(this.linkprovider)
.SetRootTags(new List<String>(this.roottags)).AutoBookmark(this.autoBookmark)
.SetTagFactory(this.tagFactory).SetAcceptUnknown(this.acceptUnknown);
return newCtx;
}