Why can't use use pptx.getPackage()  inside FontEmbedder? in this case the
call of pptx.write() will commit all your changes automatically.

Yegor




On Wed, Oct 23, 2013 at 3:30 AM, Andreas Beeker <[email protected]>wrote:

> Hi,
>
> I'm currently working on that FontEmbedder discussed recently, but I'm
> puzzled on how to use
> XMLSlideShow with OPCPackage and read-write-access.
>
> The following is similar in what is described @ http://stackoverflow.com/*
> *questions/16108142 <http://stackoverflow.com/questions/16108142>
>
> So, I'm opening an existing .pptx, adding a few fonts files and add a few
> entries to XMLSlideShow.**getCTPresentation().
> When I close the OPCPackage, the fonts are added, but the CTPresentation
> hasn't been changed.
>
> Regarding Nicks comment, one would have to save the changes in the
> high-level objects, but
> save(OutputStream/File) is probably not the right way, when you are
> working with a writable OPCPackage.
> Of course I had a look at the examples, e.g. org.apache.poi.openxml4j.opc.
> **TestPackage,
> but I don't want to save it to a different file, but to the original one
> ...
>
> Looking at the API, the revert() method is public, but commit() is
> protected - how come?
>
> When commit() is made public and called by the user code, the whole lot is
> saved ... well, nearly ...
> Libre Office left out the package properties, on my original test file, so
> I needed to create them on the fly.
>
> So in the end, I've got something like this - please comment on how to do
> it right:
>
> public static void main(String[] args) throws Exception {
>     OPCPackage opc = OPCPackage.open("textruns.**pptx",
> PackageAccess.READ_WRITE);
>     XMLSlideShow pptx = new XMLSlideShow(opc);
>
>     // manipulate pptx and add new parts (fonts) to the package
>     FontEmbedder fe = new FontEmbedder(pptx);
>     fe.analyzeDocument();
>     fe.embedFonts();
>
>     pptx.commit();
>     // bugfix for Libre Office, which omits sometimes the package
> properties and the
>     // next call to close throws an exception otherwise
>     opc.getPackageProperties();
>     opc.close();
> }
>
> Thank you,
> Andi.
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> [email protected].**org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>

Reply via email to