7

この問題の解決策を探しましたが、まだ答えが見つかりません。どんな助けでも大歓迎です。

    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>

<...>

上記の例の文字「ąčęėįųųūū」は、エクスポートされた PDF には表示されません。

「MigraDoc」文字セットを設定するにはどうすればよいですか?

4

2 に答える 2

11

レンダラーにUnicodeドキュメントを作成するように指示するだけです。

PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = document;

Unicodeを取得するには、PdfDocumentRendererの最初のパラメーターがtrueである必要があります。すべてのTrueTypeフォントにすべてのUnicode文字が含まれているわけではないことに注意してください(ただし、Arial、Verdanaなどで機能するはずです)。

完全なサンプルについては、こちらを参照してください: http ://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

于 2011-10-20T09:34:42.807 に答える
3

私のようにPDFSharp と MigraDocを混在させている場合(つまり、 PdfSharp オブジェクトPdfDocument documentと、 documentの一部としてレンダリングされるMigraDoc オブジェクトDocument docがあることを意味します)、すべてがそれほど単純ではありません。PDFSharp チームが提供した例は、MigraDoc を個別に使用している場合にのみ機能します。

したがって、次のように使用する必要があります。

  • MigraDoc オブジェクトを PDF シャープXGraphics gfxにレンダリングする前に、MigraDoc ドキュメントをレンダリングしていることを確認してください。
  • ハックを使用して、gfx オブジェクトのエンコーディングを設定します。

XGraphics gfx = XGraphics.FromPdfPage(page);
        // HACK²
            gfx.MUH = PdfFontEncoding.Unicode;
            gfx.MFEH = PdfFontEmbedding.Always;
        // HACK²
  Document doc = new Document();

  PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
        pdfRenderer.Document = doc;
        pdfRenderer.RenderDocument();

  MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(doc);
        docRenderer.PrepareDocument();
        docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(10), "12cm", para);

1.5.x-betax の場合

 let gfx = XGraphics.FromPdfPage(page)
 gfx.MUH <- PdfFontEncoding.Unicode
 let doc = new Document()

 let pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always)
 pdfRenderer.Document <- doc
 pdfRenderer.RenderDocument()

 let docRenderer = new DocumentRenderer(doc)
 docRenderer.PrepareDocument()
 docRenderer.RenderObject(gfx, XUnit.FromCentimeter 5, XUnit.FromCentimeter 10, "12cm", para)
于 2016-02-28T14:20:28.580 に答える