Closed ashahabov closed 3 years ago
PresentationBuilder
is not designed to work with already opened PresentationDocument
.
Original implementation rely on assumption that you always create new PresentationDocument using SlideSource.
You may want to take a look at FluentPresentationBuilder
that wrap target PresentationDocument
and provided API like AppendSlides
PresentationDocument
that is released in 1.5.0-beta*
packages uses FluentPresentationBuilder
internally. But IIRC, it is may be slightly not ready for use case. It works well (even in production 😊) when FluentPresentationBuilder
wrap empty presentation at the beginning, but it still not fully-enumerate internals of PresentationDocument
that it wraps.
P.S. As workaround you always can create 3rd PresentationDocument
and copy there slides from sourcePreDoc
and from outputDoc
.
Looks like FluentPresentationBuilder.AppendSlides()
also rely on that PresentationDocument
instance passed in constructor is empty.
Will see some workaround.
Why do not you like workaround to create 3rd PresentationDocument
and copy all slides there?
For example, I wanna copy only the first slide from test1.pptx into test2.pptx. With this approach, I will touch one slide from the first presentation and all slides from the second. Even without considering performance issue, I think the chance of corruption is high.
In other words, you know that moving slide to an external presentation with its all references (layout, master, theme, chart, etc) is a tricky part, hence I'd like to avoid extra touching those references.
Today I made some implementation and it works for simple cases, but I do not know where it might go off :neutral_face:
I think the issue should be closed since PresentationBuilder
designed as a builder that creates slides deck from scratch, as mentioned above.
I am looking for a way to copy a slide from existing opened
PresentationDocument
document to another also already openedPresentationDocument
document. To achieve it I added a newAppendSlide()
method intoPresentationBuilder
. I tried re-use existing code without extra changes:Here is a sample running in PresentationBuilder01 project:
Commit changes: https://github.com/adamshakhabov/Clippit/commit/d402e25a265e49fd2c8021c8045fc8881d551b0b
It does not work. But works (the first slide from source.pptx is added to output.pptx) if we delete
outputDoc.PresentationPart.Presentation
statement.While debugging I can not detect how reading
DocumentFormat.OpenXml.Presentation.Presentation
affects onAppendSlide()
flow.Any ideas?