PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 7:37 am

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
PostPosted: Wed Jul 26, 2017 11:56 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
Hello, everybody!

As of today, PDFsharp 1.50 beta 4 is available.

You can find the source code on SourceForge and CodePlex:
https://sourceforge.net/projects/pdfsha ... ta%204%29/
https://pdfsharp.codeplex.com/releases/view/631450

You can find binaries (assemblies) on NuGet. Make sure to check "Include prerelease" in the NuGet Package Manager.

Note: New on NuGet are the Core, GDI, and WPF packages.
The Silverlight package was not yet updated on NuGet.
The Silverlight package will most likely be updated - ETA is before the ides of August, 2017.

The source on GitHub was also updated.

The ZIP files with the samples were not updated (yet). There were no changes since 1.50 beta 3b. The NuGet Package Manager will fetch the latest packages.


Please report all regressions versus 1.50 beta 3b.
Several bugs have been fixed - and hopefully there are no new bugs.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
 
PostPosted: Wed Aug 02, 2017 11:58 am 
Offline

Joined: Wed Aug 02, 2017 11:55 am
Posts: 1
Great news, thank you!! It helps and solves an issue with some pdf..


Top
 Profile  
 
PostPosted: Fri Aug 04, 2017 10:30 am 
Offline

Joined: Tue Jul 15, 2014 8:56 pm
Posts: 13
Looks really good. After I'd merged in a load of the font bits from the pdfsharper fork it's working great. and fixes issues I was having with a number of PDFs.

However... there is always a however!

I'm having to fight hard to stop .net throwing out of memory exceptions if I build up a pdf from a series of huge full colour PNGs. Adding pages with one png per page.
I have 9 pngs that are A4 (ish) at 600dpi. 5000+pixels by 8000+pixels. So yes when each goes through the bitmap bits I know I'm gonna be using 300MB or so. However it doesn't seem to let it go again, the memory usage goes 300>600>900>1200... Crash after 6 or 7 pages are added. I've tried lots of tweaking in the code, but the only thing I can do to get it to work is to run things in an apartment, save the pdf after each page, close everything, end the apartment thread, start a new one, open the pdf and then add page 2... etc etc.
I have builds of this version which will work but it seems I'm performing a hack to get around some 300MB object reference somewhere not being released. You'd think that's be easy to find but .net likes to hide the magic!


Top
 Profile  
 
PostPosted: Fri Aug 04, 2017 12:22 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
kensands wrote:
However it doesn't seem to let it go again, the memory usage goes 300>600>900>1200... Crash after 6 or 7 pages are added.
You do not show any code.
Maybe "Dispose()" missing? Using "using" may help.
Maybe run in 64-bit mode to go beyond the 2 GiB limit of 32-bit processes.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
 
PostPosted: Sat Aug 05, 2017 3:45 pm 
Offline

Joined: Tue Jul 15, 2014 8:56 pm
Posts: 13
I'll sort out example code and files. going 64 bit, doesn't solve it, it just puts off the crash for a few more pages.


Top
 Profile  
 
PostPosted: Wed Aug 23, 2017 8:43 pm 
Offline

Joined: Wed Aug 23, 2017 6:33 pm
Posts: 1
1.50 beta 4 - Simplest WPF program instantly crashes but does not in beta3
------------------------------------------------------------------------------------------
The simplest WPF program creates a valid PDF but crashes after that without throwing an exception.

• VS2015
• New project ‘WPF Application’
• NuGet: PDFsharp-MigraDoc-wpf v1.50.4589-beta4
• .NET 4.5.2 (doesn’t actually matter, same with 4.6)
• Add simple button
• Add the following code

Code:
private void button_Click(object sender, RoutedEventArgs e)
{
   try
   {
      var document = new Document();
      var section = document.AddSection();

      section.AddParagraph("Hello World");

      var renderer = new PdfDocumentRenderer();
      renderer.Document = document;
      renderer.RenderDocument();

      // ... save to PDFfile here ...
   }
   catch (Exception ex)
   {
      MessageBox.Show(ex.ToString(), "Exception ...");
   }
}


• Run
• Program crashes and doesn’t even hit the catch block
• If you would save the document, you would get a valid PDF file but it crashes after that anyway (I left that code out for simplicity)

• Revert to beta3
• NuGet: PDFsharp-MigraDoc-wpf v1.50.4000-beta3
• Compile and Run
• No crash

If the experts could have a look, Many Thanks!
(+ Many thanks for sharing the project!)


Top
 Profile  
 
PostPosted: Fri Aug 25, 2017 11:41 am 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
e420 wrote:
If the experts could have a look, Many Thanks!
(+ Many thanks for sharing the project!)
The problem is caused by calling "_dc.Dispatcher.InvokeShutdown();"
This call was introduced to prevent PDFsharp on Azure servers from running out of resources.
Unwanted side effect: the WPF desktop application will be closed.
See here:
viewtopic.php?p=10149#p10149

The call to "_dc.Dispatcher.InvokeShutdown();" will be removed from the next version on NuGet.
For use on a server, get the source code package and uncomment that line.

Thanks for the feedback. Sorry for the inconvenience.
I have no idea how to help both usage cases with a single NuGet package.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
 
PostPosted: Fri Aug 25, 2017 12:23 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
() => true wrote:
The call to "_dc.Dispatcher.InvokeShutdown();" will be removed from the next version on NuGet.
I can no longer replicate the issue with the current packages from NuGet:
PM> Install-Package PDFsharp-MigraDoc-WPF -Version 1.50.4619-beta4c

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group