我不知道如何摆脱添加段落时自动生成的书签:
Paragraph inicio = document.LastSection.AddParagraph();
inicio.Style = "Heading1";
inicio.AddSpace(110);
inicio.AddText("Factura nº");
inicio.AddText(facturaPat.FacturaN + "/" + DateTime.Now.Year);
inicio.Format.SpaceAfter = Unit.FromCentimeter(2);
inicio.Format.SpaceBefore = Unit.FromCentimeter(0.7);
Run Code Online (Sandbox Code Playgroud)
风格是:
style = document.Styles["Heading1"];
style.Font.Name = "Arial";
style.Font.Size = 10.5;
style.Font.Bold = true;
style.Font.Color = Colors.Black;
style.ParagraphFormat.PageBreakBefore = false;
Run Code Online (Sandbox Code Playgroud)
我正在使用的"Doc":
Document document = new Document();
...
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);
pdfRenderer.Document = document;
// Layout and render document to PDF
pdfRenderer.RenderDocument();
Run Code Online (Sandbox Code Playgroud)
如果有人能告诉我如何在pdf打开时没有书签的情况下生成所需的内容,那将会很棒(我找不到解决此问题的方法).
谢谢
在我的解决方案中,我使用PDF文件中的项目符号列表.
看起来像这样:
• Solcellepaneler kræver hverken autoriseret service eller tidskrævende vedligehold.
• Solceller er støjfri, forurener ikke og har ingen bevægelige dele, hvilket mindsker
service og vedligehold
• Solceller kan integreres i bygningers arkitektur eller anvendes som
bygningselement i form af tag, facader eller solafskærmning
• Solceller har lang levetid, med en produktionsgaranti på hele 25 år
• 10 kvadrameter solceller sparer ca. ½ ton CO2 om året
Run Code Online (Sandbox Code Playgroud)
我想要的是 :
• Solcellepaneler kræver hverken autoriseret service eller tidskrævende vedligehold.
• …Run Code Online (Sandbox Code Playgroud) 我正在使用Migradoc生成一些PDF.我有一个代码为数组中的每个元素创建一个文本表,并打印出这些表的页面.
但是,我给出的要求是,如果我有2个表,并且由于第一个表的长度,第2个表不适合页面,我需要第2个表来启动下一页.然后,我需要为我添加到文档中的每个表重复此操作.
我该怎么做呢?
我使用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) 我正在使用MigraDoc和PDFsharp,我需要为PDF文档中的每个页面设置不同的边距.运用
document.DefaultPageSetup.RightMargin = 20;
document.DefaultPageSetup.LeftMargin = 20;
Run Code Online (Sandbox Code Playgroud)
我知道我的文档中的所有页面都具有相同的边距.如何设置文档中每个页面的边距?谢谢
我正在使用 MigraDoc 在部署到 Azure 云的 ASP.NET5 MVC6 Web 应用程序中生成 PDF。我使用的是 1.50 beta-2 版本,但我也尝试过使用 v1.50 beta-1 和 v1.32。
\n\n当应用程序在本地运行时,我已成功生成 PDF。然而,当应用程序在云服务器上运行时,由于无法访问任何字体,我在生成 PDF 时遇到了很大的问题。 按照 PDFsharp 文档,我尝试通过在代码中嵌入字体来创建“私有字体”。
\n\n我直接使用 PDFsharp 在云上成功生成了 PDF
\n\n public static MyResolver FontResolver = new MyResolver();\n public void RenderPdf(CreateDocumentViewModel viewModel)\n {\n GlobalFontSettings.FontResolver = FontResolver;\n //...\n XFont font = new XFont("times-roman", 12, XFontStyle.Regular);\n //This font is then used in DrawString.\n }\nRun Code Online (Sandbox Code Playgroud)\n\n不过,我现在想利用 MigraDoc,这样我就不必自己完成所有排版工作。
\n\n我在这里遵循了 Thomas H\xc3\xb6vel\ 博客上的优秀指南(这是 beta-2 的新指南,尽管我之前也关注过他之前关于 beta-1 的帖子)。他的项目在本地非常适合我。
\n\n …我已经搜索了这个问题的解决方案,但仍然找不到答案.任何帮助,将不胜感激.
Document document = new Document();
Section section = document.AddSection();
Paragraph paragraph = section.AddParagraph();
paragraph.Format.Font.Color = Color.FromCmyk(100, 30, 20, 50);
paragraph.AddText("?????????");
paragraph.Format.Font.Size = 9;
paragraph.Format.Alignment = ParagraphAlignment.Center;
</b>
Run Code Online (Sandbox Code Playgroud)
<...>
在上面的示例中,导出的pdf中不显示"ąčęėįųųūū"字符.
如何设置'MigraDoc'字符集?
如何减少 MigraDoc 文档的上边距?
我在文档的右上角添加了一个图像,但是文档顶部和图像之间的空间太大。
这是我设置图像的方法:
Section section = document.AddSection();
Image image = section.AddImage(@"C:\img\mentSmallLogo.png");
image.Height = "1.5cm";
image.Width = "4cm";
image.LockAspectRatio = true;
image.RelativeVertical = RelativeVertical.Line;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Right;
image.WrapFormat.Style = WrapStyle.Through;
Run Code Online (Sandbox Code Playgroud)
以及文档样式:
Style style = document.Styles["Normal"];
style.Font.Name = "Verdana";
style = document.Styles[StyleNames.Header];
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
// Create a new style called Table based on style Normal
style = document.Styles.AddStyle("Table", "Normal");
style.Font.Name = "Verdana";
style.Font.Name = "Times New Roman";
style.Font.Size = …Run Code Online (Sandbox Code Playgroud) 我们正在使用 MigraDoc/PDFsharp GDI+,它依赖于将字体安装到系统以进行渲染。我们已尝试嵌入字体,但 MigraDoc 的 GDI+ 版本似乎不支持此功能。
尝试将此组件移动到 Azure 应用服务时,它找不到字体。有没有办法在本地将字体“安装”到应用服务,以便 GDI 可以看到它们?
我的图表中有很多元素,这些元素不适合图表下的一行。如何实现换行以便所有图例都适合图表下方?
这是我的用例示例,将其复制到本地项目并使用 NuGet 来配置 MigraDoc 包。
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Xml.XPath;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using System.Diagnostics;
using PdfSharp.Pdf;
namespace ConsoleApplication2
{
class Program
{
static void Main()
{
// Create a MigraDoc document
Document document = CreateDocument();
//string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);
//MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");
PdfDocumentRenderer renderer = new PdfDocumentRenderer(unicode: true);
renderer.Document = document;
renderer.RenderDocument();
// Save the document...
//renderer.PdfDocument.Save(filename);
renderer.PdfDocument.Save("example.pdf");
// ...and start a viewer. …Run Code Online (Sandbox Code Playgroud)