PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
AddPage does not clone Annotations https://forum.pdfsharp.net/viewtopic.php?f=3&t=3659 |
Page 1 of 1 |
Author: | PeterEm [ Fri Sep 08, 2017 9:17 pm ] |
Post subject: | AddPage does not clone Annotations |
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 |
Author: | TH-Soft [ Sat Sep 09, 2017 7:53 am ] |
Post subject: | Re: AddPage does not clone Annotations |
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);". |
Author: | PeterEm [ Sat Sep 09, 2017 12:19 pm ] |
Post subject: | Re: AddPage does not clone Annotations |
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. |
Author: | ZeroG [ Wed Oct 18, 2017 10:10 pm ] |
Post subject: | Re: AddPage does not clone Annotations |
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. |
Author: | Thomas Hoevel [ Thu Oct 19, 2017 9:46 am ] |
Post subject: | Re: AddPage does not clone Annotations |
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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |