Skip to content

Make a PPTX compatible with Mac Keynote #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Progi1984 opened this issue Aug 20, 2014 · 43 comments
Closed

Make a PPTX compatible with Mac Keynote #46

Progi1984 opened this issue Aug 20, 2014 · 43 comments

Comments

@Progi1984
Copy link
Member

Actually, @Djuki have some problems for reading PPTX in Keynote.

I added a patch for CodePlex (92ffaf4 - 29a3321 (Fix) - c0ef044 (Fix)).

But they always have a problem.

Now, could you send me a PPTX file created by Keynote, plz ? Thx

@Progi1984 Progi1984 added this to the 0.3.0 milestone Aug 20, 2014
@Progi1984 Progi1984 self-assigned this Aug 20, 2014
@surefirejack
Copy link

Here are two PPT files created from latest Mac Keynote. One is .ppt and other is .pptx

Thank you for your help and this terrific library.

https://www.dropbox.com/s/2msgluuwnp9cn2d/two-ppts-from-keynote.zip

@Progi1984
Copy link
Member Author

@surefirejack Could you test with the lastest version of the develop branch, plz ? Poke @Djuki

@surefirejack
Copy link

Unfortunately I'm still getting an error that it can't be opened. I pulled from the latest dev branch and manually inspected my code to make sure that your update was included, and it was.

Progi1984 added a commit that referenced this issue Aug 22, 2014
@Progi1984
Copy link
Member Author

@surefirejack I had an epiphany last night : I haven't done declarations in ContentTypes file. Could you test again, plz ? I will not give.

@surefirejack
Copy link

I tried after doing composer update and it doesn't work. Plus I tried opening with Open Office (which has always worked for PPT files created with your library) and got this error:

http://screencast.com/t/aWDNqFH2wwwh

Here's the code my developer created to test out the file:

https://gist.github.com/surefirejack/a1e7403bf174bb6e507a

@Progi1984
Copy link
Member Author

@surefirejack Could you try this :

Thanks :)

PS : Personnally, I tested with Libreoffice 4.2.5.2 Windows and no problem

@surefirejack
Copy link

I'm assuming you mean these lines:

    $this->writeOverrideContentType($objWriter, '/ppt/presProps.xml', 'application/vnd.openxmlformats-officedocument.presentationml.presProps+xml');
    $this->writeOverrideContentType($objWriter, '/ppt/tableStyles.xml', 'application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml');
    $this->writeOverrideContentType($objWriter, '/ppt/viewProps.xml', 'application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml');

I tried the following:

  1. All three commented out
  2. First uncommented, next two commented
  3. First two uncommented, next two commented
  4. First commented, next two uncommented

None of those 4 tests worked.

Also, I ran composer update to make sure I wasn't missing anything and I got a "Nothing to update" response so I believe I am working with latest develop branch.

And also, I deleted the test file before each test to make sure.

@Progi1984
Copy link
Member Author

@surefirejack F**k ! I don't see where the problem is. Keynote doesn't give any errors or informations ? or log ?

@Progi1984
Copy link
Member Author

@surefirejack Could you edit your file "PhpPowerpoint/Writer/PowerPoint2007/PptProps.php" ?
And replace the method writeViewProps with

public function writeViewProps()
{
    // Create XML writer
    $objWriter = $this->getXMLWriter();

    // XML header
    $objWriter->startDocument('1.0','UTF-8','yes');

    // p:viewPr
    $objWriter->startElement('p:viewPr');
    $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
    $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
    $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main');

        // p:normalViewPr
        $objWriter->startElement('p:normalViewPr');

            // p:restoredLeft
            $objWriter->startElement('p:restoredLeft');
            $objWriter->writeAttribute('sz', '15620');
            $objWriter->endElement();
            // p:restoredTop
            $objWriter->startElement('p:restoredTop');
            $objWriter->writeAttribute('sz', '94660');
            $objWriter->endElement();

        $objWriter->endElement();

        // p:slideViewPr
        $objWriter->startElement('p:slideViewPr');

            // p:cSldViewPr
            $objWriter->startElement('p:cSldViewPr');

                // p:cViewPr
                $objWriter->startElement('p:cViewPr');
                $objWriter->writeAttribute('varScale', '1');

                    // p:scale
                    $objWriter->startElement('p:scale');

                        // a:sx
                        $objWriter->startElement('a:sx');
                        $objWriter->writeAttribute('n', '70');
                        $objWriter->writeAttribute('d', '100');
                        $objWriter->endElement();

                        // a:sy
                        $objWriter->startElement('a:sy');
                        $objWriter->writeAttribute('n', '70');
                        $objWriter->writeAttribute('d', '100');
                        $objWriter->endElement();

                    $objWriter->endElement();

                    // p:origin
                    $objWriter->startElement('p:origin');
                    $objWriter->writeAttribute('x', '-516');
                    $objWriter->writeAttribute('y', '-90');
                    $objWriter->endElement();

                $objWriter->endElement();

                // p:guideLst
                $objWriter->startElement('p:guideLst');

                    // p:guide
                    $objWriter->startElement('p:guide');
                    $objWriter->writeAttribute('orient', 'horz');
                    $objWriter->writeAttribute('pos', '2160');
                    $objWriter->endElement();

                    // p:guide
                    $objWriter->startElement('p:guide');
                    $objWriter->writeAttribute('pos', '2880');
                    $objWriter->endElement();

                $objWriter->endElement();

            $objWriter->endElement();

        $objWriter->endElement();

        // p:notesTextViewPr
        $objWriter->startElement('p:notesTextViewPr');

            // p:cViewPr
            $objWriter->startElement('p:cViewPr');

                // p:scale
                $objWriter->startElement('p:scale');

                    // a:sx
                    $objWriter->startElement('a:sx');
                    $objWriter->writeAttribute('n', '1');
                    $objWriter->writeAttribute('d', '1');
                    $objWriter->endElement();

                    // a:sy
                    $objWriter->startElement('a:sy');
                    $objWriter->writeAttribute('n', '1');
                    $objWriter->writeAttribute('d', '1');
                    $objWriter->endElement();

                $objWriter->endElement();

                // p:origin
                $objWriter->startElement('p:origin');
                $objWriter->writeAttribute('x', '0');
                $objWriter->writeAttribute('y', '0');
                $objWriter->endElement();

            $objWriter->endElement();

        $objWriter->endElement();

        // p:gridSpacing
        $objWriter->startElement('p:gridSpacing');
        $objWriter->writeAttribute('cx', '76200');
        $objWriter->writeAttribute('cy', '76200');
        $objWriter->endElement();

    $objWriter->endElement();

    // Return
    return $objWriter->getData();
}

And test again ?

Hard to test with access to Keynote or Keynote Online ? Sorry :)

@surefirejack
Copy link

@Progi1984
I ran a battery of tests this morning and haven't been able to get it to work. I'm sorry.

Here's what I'm using to test now:

/vendor/phpoffice/phppowerpoint/samples/Sample_01_Simple.php

First I switched back to dev-master to confirm that the demo will open in OpenOffice. It does.

I tried that with Keynote, just in case. No luck.
I tried with an older version of Keynote, and yes that works (but this has always been the case - it's the newest version of Keynote that is the issue)

Then I switched to dev-develop and did composer update and composer dump-autoload

Tested without any changes.
Tested with the changes to PptProps.php
I tested with the changes to ContentTypes.php from previous day
I even tested different permutations of all of the above.

But nothing I tried worked with Keynote.

They did continue to work with OpenOffice.

@surefirejack
Copy link

@Progi1984
Copy link
Member Author

@surefirejack S**t ! I don't understand why this simple PowerPoint2007 file can't be opened in Keynote !
May be a link with #47 ? No error logs for Keynote ?

@surefirejack
Copy link

These are the only two error log entries when I try to open the ppt file
http://screencast.com/t/T9dz4BmgQu

@Progi1984
Copy link
Member Author

@surefirejack It seems that these errors are not linked to our problem.

@Progi1984
Copy link
Member Author

@surefirejack Small question : have you these two patchs applied in your code : #47 (comment) ? These patches have corrected corrupted PPTX for PowerPoint2007 & PowerPoint2010.

@Djuki
Copy link
Contributor

Djuki commented Sep 6, 2014

@Progi1984 I created files with latest dev version, and with changes on method writeViewProps
I sent them to @surefirejack and he will test them.

Both #47 patches are applied in latest dev code I used in ppt file generation.

@Progi1984
Copy link
Member Author

@Djuki ppt => pptx ?
@surefirejack Have you tested ?

@Djuki
Copy link
Contributor

Djuki commented Sep 8, 2014

@Progi1984 Files extension is ppt

@Progi1984
Copy link
Member Author

@Djuki But you use PowerPoint2007 writer (so there are OpenXML files (pptx)).

@Djuki
Copy link
Contributor

Djuki commented Sep 8, 2014

@Progi1984 Yes Writer is PowerPoint2007

$objWriter = IOFactory::createWriter($phpPowerPoint, 'PowerPoint2007');

But filename is with ppt extension.

$objWriter->save($path."osx_ppt_test.ppt");

@surefirejack
Copy link

When I create the ppt file it does not open with either OpenOffice or Keynote.

I am going to try one of the test files that comes with the library and see if I get a different result

@surefirejack
Copy link

Sample_01_Simple.php in samples directory created a ppt that I could open with Open Office but not latest Keynote.

@Progi1984
Copy link
Member Author

@surefirejack It doesn't open with OpenOffice (which version ?) or Keynote. But do it open with LibreOffice ?

Wow, that begins to be hard to test without access to Keynote 😟

@Progi1984
Copy link
Member Author

@PHPOffice/phpword-team / @PHPOffice/phppowerpoint-team Noone in the team has a Mac for testing what the problem is with Keynote and helping @surefirejack & @Djuki ?

References : #46 (comment)

@Progi1984
Copy link
Member Author

@surefirejack @Djuki Always the problem with the version 0.3 ?

@Progi1984
Copy link
Member Author

@surefirejack Have you ever had a working version of PHPPowerpoint running with Keynote ? 0.2 ? 0.3 ?

@surefirejack
Copy link

@Progi1984 No. We have never been able to get it to work with Keynote. Would love to. Do you believe this is fixed or are you waiting for us to re-test?

@Progi1984
Copy link
Member Author

@surefirejack And with the version 0.2 ?

You can test with the last version of dev. Some errors in PPTX format have been fixed.

@surefirejack
Copy link

Ok, I'll ask @Djuki to help me run a test.

@Progi1984
Copy link
Member Author

@Djuki @surefirejack Hi, since the last commit efa7bd6, PHPPowerPoint create valid openxml. May be that could fix this bug with Keynote. Could you test and give me some feedback ? Thx

@surefirejack
Copy link

@Progi1984 I tested with dev-master and simple test didn't work. See here:
http://screencast.com/t/wNuBB2msQ7

@surefirejack
Copy link

BTW - It opens in Keynote 5.3 but not the current, which is 6+

@Progi1984
Copy link
Member Author

@surefirejack Yes, good news...

Doesn't an old version of PHPPowerpoint work with Keynote 5.3 ?

Now, what's it's the evolution with Keynote 6+ ?

@surefirejack
Copy link

@Progi1984 I think there was never an issue with opening PHPPowerPoint files using Keynote 5.3

The issue is with Keynote 6+

I really don't know why it is, but it doesn't appear that the latest commits have fixed this.

@Progi1984
Copy link
Member Author

@surefirejack I found the support table of PPTX by Keynote but no infos.

I agree with you... I must to find a way for fixing that : error log for Keynote ? changes between Keynote 5.3 & Keynote 6 for PPTX support ? others ... We will find a solution.

@Progi1984
Copy link
Member Author

@surefirejack Never give up ! Two ideas come to me this night.

First idea :
Could you in src/PhpPowerpoint/Writer/PowerPoint2007/Slide.php (l.160)
Replace

$objWriter->writeElement('a:masterClrMapping', '');

By

$objWriter->writeElement('a:masterClrMapping', null);

Link : scanny/python-pptx#80 (comment)

Second idea :
Do you use Python ? Could you use the first sample here to generate the PPTX and try to open it with Keynote 6 ? If it's good, could you send me this file. I will try to compare it with ours.

Project : https://github.com/scanny/python-pptx (Poke @scanny)

@surefirejack
Copy link

@Progi1984 I changed the line, but it wasn't line 160. Was line 156. Changed to null and tried. Test failed to create a pptx that could be opened with Keynote 6.

And although I don't know really how to run the Python code, I downloaded the files from Github and found that the pptx files in the tests directory work great with Keynote 6. Here's an example:

/python-pptx-master/tests/test_files/test_slides.pptx

@Progi1984
Copy link
Member Author

Progi1984 added a commit that referenced this issue Dec 30, 2014
@surefirejack
Copy link

@Progi1984 Yes that one works too.

@Progi1984
Copy link
Member Author

@surefirejack I fix some Unicode issues and some relations missings. Could you test again with the last develop branch ? Thx

@surefirejack
Copy link

@Progi1984 Boooya! That worked! You're the man.

@Progi1984
Copy link
Member Author

@surefirejack It's a pleasure to close it :) Thanks to you for your help in testing and Happy New Year :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants