嗨,我正在使用PDFsharp和MigraDoc生成柱形图.我想知道,如果我可以将x轴标签旋转到90度,那么它们就像垂直而不是水平.有什么机构有任何想法吗?如果没有,有人可以告诉我任何其他我可以用于同一目的的图书馆吗?
有什么办法设置字体样式ItalicUnderline或BoldItalicUnderline?

谢谢
我可以像这样在Migradoc中创建一个标题:
//Create Header
Paragraph paragraph = section.Headers.Primary.AddParagraph();
paragraph.AddText("Roto");
paragraph.Format.Font.Size = 9;
paragraph.Format.Alignment = ParagraphAlignment.Center;
Run Code Online (Sandbox Code Playgroud)
我可以制作一个这样的简单表格:
// Create the HEADER table for the top of every page
this.table = section.AddTable();
this.table.Style = "Table";
this.table.Borders.Color = TableBorder;
this.table.Borders.Width = 0.25;
this.table.Borders.Left.Width = 0.5;
this.table.Borders.Right.Width = 0.5;
this.table.Rows.LeftIndent = 0;
Column column = this.table.AddColumn("8cm");
column.Format.Alignment = ParagraphAlignment.Center;
column = this.table.AddColumn("8cm");
column.Format.Alignment = ParagraphAlignment.Center;
// Create the header of the table
Row row = table.AddRow();
//row = table.AddRow();
row.HeadingFormat = true;
row.Format.Alignment = ParagraphAlignment.Center; …Run Code Online (Sandbox Code Playgroud) 我正在一个需要创建Word文件的项目中工作。为此,我将MigraDoc库用于C#。
使用此库,我可以通过编写以下代码轻松生成RTF文件:
Document document = CreateDocument();
RtfDocumentRenderer rtf = new RtfDocumentRenderer();
rtf.Render(document, "test.rtf", null);
Process.Start("test.rtf");
Run Code Online (Sandbox Code Playgroud)
但是要求现在要求我获取DOC或DOCX文件而不是RTF文件。有没有一种使用MigraDoc生成DOC或DOCX文件的方法?如果是这样,我该如何实现?
我想创建一个在背景图像上有文本的封面.这可能在MigraDoc/PDFsharp中吗?
我有一个带有单元格的表格,我想要两个文本,第一个在左边对齐,第二个在右边,在同一个单元格中,在同一行上.
我试图用MigraDoc重现这个细胞而没有成功.我只能添加两个左右对齐但不在同一行的文本.
这是我的代码:
Cell cellFooter1 = rowFooter.Cells[0];
Paragraph paraphTot = new Paragraph();
paraphTot.Format.Alignment = ParagraphAlignment.Left;
paraphTot.AddText("Left text");
cellFooter1.Add(paraphTot);
Paragraph paraphDetails = new Paragraph();
paraphDetails.Format.Alignment = ParagraphAlignment.Right;
paraphDetails.AddText("Right text");
cellFooter1.Add(paraphDetails);
Run Code Online (Sandbox Code Playgroud)
这里提供了一个解决方案(http://forum.pdfsharp.net/viewtopic.php?f=2&t=2373),但我无法对我的表做同样的事情.我不明白它是如何工作的.
编辑:部分解决方案:
在努力了解它是如何工作之后,我的代码部分正常工作.部分因为我发现右对齐的唯一方法是创建一个具有近似值的TabStop ...不好.
Table table = new Table();
table.Borders.Width = 0.75;
Column myColumn = table.AddColumn(Unit.FromCentimeter(7));
Row myRow = table.AddRow();
Cell myCell = myRow.Cells[0];
Paragraph myParagraph = new Paragraph();
Style myStyle = doc.AddStyle("myStyle", "Normal");
myStyle.ParagraphFormat.Font.Size = 6.5;
myStyle.ParagraphFormat.Font.Bold = true;
myStyle.ParagraphFormat.TabStops.Clear();
myStyle.ParagraphFormat.AddTabStop(Unit.FromMillimeter(67), TabAlignment.Right);
myParagraph.Style = "myStyle";
myParagraph.Format.Alignment = ParagraphAlignment.Left; …Run Code Online (Sandbox Code Playgroud) 我正在使用MigraDoc以编程方式生成包含文本,图像和表格的PDF文件.
我需要在文档对象中设置Document Orientation(对于所有页面)Landscape.
所以我尝试了以下内容.
document.DefaultPageSetup.Orientation = Orientation.Landscape;
Run Code Online (Sandbox Code Playgroud)
但是我得到以下调试断言错误.
---------------------------
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
---------------------------
DefaultPageSetup must not be modified
Run Code Online (Sandbox Code Playgroud)
如果我单击忽略,它会通过,Orientation确实是Landscape.
但是,我想确保我以正确的方式这样做.
所以问题是,如何Document使用MigraDoc库为所有页面设置文档方向?
这是代码的其余部分(因此它可以帮助您获取上下文)
using System.Runtime.Remoting.Messaging;
using MigraDoc.DocumentObjectModel;
namespace MyNamespace.PdfReports
{
class Documents
{
public static Document CreateDocument()
{
// Create a new MigraDoc document
Document document = new Document();
document.Info.Title = "The Title";
document.Info.Subject = "The Subject";
document.Info.Author = "Shiva";
document.DefaultPageSetup.Orientation = Orientation.Landscape;
Run Code Online (Sandbox Code Playgroud)
非常感谢!
-Shiva …
我真的很难做到这一点,任何帮助将不胜感激.
我有一系列图像,我想使用MigraDoc构建到PDF(1图像= 1页)每个图像必须显示在一个单独的页面上,但可能不会延伸到它必须完全适合页面的页面上.
那么,如何使用MigraDoc缩放图像(任何大小)以适合页面?
刚开始使用 PDFsharp 并且它工作正常,但现在我想在我的 PDF 中创建表格,但尝试了其他来源并没有发现任何东西。
到目前为止,我知道如何使用graph.drawString().
我使用MigraDoc在项目中创建pdf文档.
下面的代码显示了我如何使用库:
var document = new Document { Info = { Author = "title" } };
Section section = document.AddSection();
Paragraph paragraph = section.AddParagraph("Title");
var renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always) { Document = document };
renderer.RenderDocument();
Run Code Online (Sandbox Code Playgroud)
所以,我正在寻找一种方法来在pdf中添加到web资源的链接.
有人知道吗?)
- - - - - - -解 - - - - - - - - - -
我找到了解决方案
我尝试使用AddHyperlink()来添加链接,这是第一步.以下代码显示正确使用:
var h = paragraph.AddHyperlink("http://stackoverflow.com/",HyperlinkType.Web);
h.AddFormattedText("http://www.stackoverflow.com/");
Run Code Online (Sandbox Code Playgroud)