PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

[solved] PDFSharp - Text outlining not working
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4410
Page 1 of 1

Author:  pridachin_nikolai [ Wed Jan 04, 2023 4:36 pm ]
Post subject:  [solved] PDFSharp - Text outlining not working

Hello! I'm trying to output text with border using "Draw Glyphs" sample code.

Code:
XGraphicsPath path = new XGraphicsPath();
// Test gfx active
gfx.DrawLine(XPens.Black, 10, 10, 100, 100);
// Output outlined font
path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140), XStringFormats.Center);
gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, path);


As the result - I can see black line on my page, but no text (screenshort attached). No any errors or warnings, so I have no idea what goes wrong :(

Attachment:
2023-01-04 19_37_05-2023-01-04 19_31_59-test.pdf - Adobe Acrobat Reader (64-bit).jpg ‎- Фотографии.jpg
2023-01-04 19_37_05-2023-01-04 19_31_59-test.pdf - Adobe Acrobat Reader (64-bit).jpg ‎- Фотографии.jpg [ 22.31 KiB | Viewed 2091 times ]

Author:  TH-Soft [ Thu Jan 05, 2023 10:13 am ]
Post subject:  Re: PDFSharp - Text outlining not working

pridachin_nikolai wrote:
Hello! I'm trying to output text with border using "Draw Glyphs" sample code.
Thanks for showing the lines from our sample. I can see no error in there.
Thanks for not sharing the rest of your code. The error is probably somewhere in that code.

Author:  pridachin_nikolai [ Thu Jan 05, 2023 4:14 pm ]
Post subject:  Re: PDFSharp - Text outlining not working

Hello, Thomas. Thank you for answer. Do you have any ideas, how can I debug this to understand the problem?

I created the test project (Clear WPF .NET 4.8 App ), and add PdfSharp via NuGet. I got the same result in this blank project - I can see only line, but no text :(

Here is the full code:

Code:
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PDFSharpTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            PdfDocument document = new PdfDocument();

            PdfPage page = document.AddPage();
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XGraphicsPath path = new XGraphicsPath();

            // Test gfx active
            gfx.DrawLine(XPens.Black, 10, 10, 100, 100);
            // Output outlined font
            path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140), XStringFormats.Center);
            gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, path);

            const string filename = "HelloWorld.pdf";
            document.Save(filename);
            Process.Start(filename);
        }
    }
}

Author:  TH-Soft [ Thu Jan 05, 2023 5:08 pm ]
Post subject:  Re: PDFSharp - Text outlining not working

One could check the contents of the PDF file to see what gets added.

You can download the sample and run it to see if it still works:
https://github.com/empira/PDFsharp-samples

You can download PDFsharp and step through the code (reference the project files, not the NuGet packages):
https://github.com/empira/PDFsharp

Are you using the WPF build or the GDI build of PDFsharp? AIUI this code will not work with the Core build of PDFsharp.

Author:  pridachin_nikolai [ Thu Jan 05, 2023 5:30 pm ]
Post subject:  Re: PDFSharp - Text outlining not working

pridachin_nikolai wrote:
Are you using the WPF build or the GDI build of PDFsharp? AIUI this code will not work with the Core build of PDFsharp.

Ah! Yes, this is was my problem. I delete PDFSharp Core iand installed PDFsharp-MigraDoc-wpf and now it works fine! Thank you so much!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/