PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 1:01 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Sep 08, 2017 9:17 pm 
Offline

Joined: Fri Sep 08, 2017 8:55 pm
Posts: 3
This is from https://github.com/empira/PDFsharp/ which I just pulled down today. In PdfPages.cs

In the method ImportExternalPage there is a conditional compilation set that excludes Annotations from being cloned when a page is imported into a PDF document.

Code:
#if true
            // Do not deep copy annotations.
            //CloneElement(page, importPage, PdfPage.Keys.Annots, false);
#else
            // Deep copy annotations.
            CloneElement(page, importPage, PdfPage.Keys.Annots, true);
#endif


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 09, 2017 7:53 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Hi!

Thanks for the feedback.

How did it look in the working 1.32 code?
Should we go for "CloneElement(page, importPage, PdfPage.Keys.Annots, false);" or for "CloneElement(page, importPage, PdfPage.Keys.Annots, true);".

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


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 09, 2017 12:19 pm 
Offline

Joined: Fri Sep 08, 2017 8:55 pm
Posts: 3
TH-Soft wrote:
How did it look in the working 1.32 code?
Should we go for "CloneElement(page, importPage, PdfPage.Keys.Annots, false);" or for "CloneElement(page, importPage, PdfPage.Keys.Annots, true);".

I haven't looked at the 1.32 code as I am working with PDFs that can't be opened by the 1.32 version ("The current implementation of PDFsharp cannot handle this PDF feature introduced with Acrobat 6").

I don't know which version of the code to use. That's above my pay grade. When I tested it yesterday I thought that the "false" value worked and the "true" value failed. But I can't duplicate that now.


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 18, 2017 10:10 pm 
Offline

Joined: Wed Oct 18, 2017 9:44 pm
Posts: 1
I'm experiencing the same problem (obviously, since the line is commented out this would impact anyone using the latest version). I tried building locally and un-commenting out the line as-is and it worked. I'd hate to have to use a forked version of PdfSharp in my project just to uncomment one line; it'd be swell if whenever the next release happens this is changed. The change I made is what PeterEm suggested. I un-commented out line 444 of PDFsharp\src\PdfSharp\Pdf\PdfPages.cs so it now looks like this:

Code:
#if true
            // Do not deep copy annotations.
            CloneElement(page, importPage, PdfPage.Keys.Annots, false);
#else
            // Deep copy annotations.
            CloneElement(page, importPage, PdfPage.Keys.Annots, true);
#endif


It's also not obvious to me whether passing "false" to that final argument is right or not; since the commented-out line had it as false that's what I did, and it worked in my very limited testing. I also checked version 1.32, and it has that argument as false as well (and the line is not commented-out).

I can submit a pull request on Github if that would help.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 19, 2017 9:46 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!
ZeroG wrote:
I can submit a pull request on Github if that would help.
That won't help. Thanks for showing the code that works for you.

When seeing "#if true" I'm tempted to change this to "#if true_" to test the #else case.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 52 guests


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