Skip to content
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

RTF Writer - Support for Links and Page Breaks #196

Closed
Centurious opened this issue Apr 10, 2014 · 11 comments
Closed

RTF Writer - Support for Links and Page Breaks #196

Centurious opened this issue Apr 10, 2014 · 11 comments

Comments

@Centurious
Copy link

I would like to use the RTF Writer to create a document with some Page Breaks and Links in it.
When I tried to add page break it simply outputs Page Break in the document.

@ivanlanin
Copy link
Contributor

Hi @Centurious. Yes, PHPWord support for RTF are quite limited right now. I can't promise you any exact date, but support for RTF will be better shortly. You can always tweak and enhance the existing code for your need if you want, though.

@ivanlanin ivanlanin modified the milestones: 0.12.0, 0.11.0, 1.0.0, Next Apr 13, 2014
@ivanlanin ivanlanin modified the milestones: 0.11.0, 1.0.0 May 12, 2014
@ivanlanin ivanlanin self-assigned this May 12, 2014
ivanlanin added a commit to ivanlanin/PHPWord that referenced this issue May 12, 2014
@ivanlanin
Copy link
Contributor

Hi @Centurious. I just added this two feature to the develop branch. Can you please test and confirm that links and page breaks can be used in RTF now? Thanks.

@Centurious
Copy link
Author

Hi, I tried the page breaks and it works well. I tried the link and the link function itself works, however it does not seem to accept any styling. I tried passing a name style to the link and passed in an array defining a font and neither seemed to work.
Best Regards
Centurious

@ivanlanin
Copy link
Contributor

Ok. I'll work on the styling tonight.

ivanlanin added a commit to ivanlanin/PHPWord that referenced this issue May 13, 2014
ivanlanin added a commit to ivanlanin/PHPWord that referenced this issue May 13, 2014
@ivanlanin
Copy link
Contributor

Link styling should be working now. Please see and run Sample_15_Link.php to get the example.

@Centurious
Copy link
Author

I tried the example but for some reason the link does not display in the RTF file at all.
My steps were:

  1. Download the development code.
  2. Create a new folder for it on my webserver called Playground.
  3. Go to http://localhost/playground/PHPWord/samples/Sample_15_Link.php
  4. Click the RTF link.
    I tried to add it to my file also with the same result.
    Best Regards,
    Centurious

@ivanlanin
Copy link
Contributor

That's strange. The RTF file content is actually very simple.

{\rtf1\ansi\ansicpg1252\deff0\deftab720
{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red128\green128\blue0;\red0\green0\blue255;\red\green\blue;}
{\*\generator PhpWord;}
\viewkind4\uc1\pard\nowidctlpar\lang1036\kerning1\fs20
{\field {\*\fldinst {HYPERLINK "http://www.google.com"}}{\fldrslt {\cf2\f0\fs20\ul Best search engine}}}\par
\par
\par
{\field {\*\fldinst {HYPERLINK "http://www.bing.com"}}{\fldrslt {\cf1\f0\fs20\b http://www.bing.com}}}\par
{\field {\*\fldinst {HYPERLINK "http://www.yahoo.com"}}{\fldrslt {\cf1\f0\fs20\b http://www.yahoo.com}}}\par
}

That's the RTF that we got when running sample 15.

@Centurious
Copy link
Author

Aha mystery solved. I had downloaded the master copy rather than development.
I downloaded the development branch and it now sets the link as you described:

{\rtf1\ansi\ansicpg1252\deff0\deftab720
{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red128\green128\blue0;\red0\green0\blue255;\red\green\blue;}
{\*\generator PhpWord;}
\viewkind4\uc1\pard\nowidctlpar\lang1036\kerning1\fs20
{\field {\*\fldinst {HYPERLINK "http://www.google.com"}}{\fldrslt {\cf2\f0\fs20\ul Best search engine}}}\par
\par
\par
{\field {\*\fldinst {HYPERLINK "http://www.bing.com"}}{\fldrslt {\cf1\f0\fs20\b http://www.bing.com}}}\par
{\field {\*\fldinst {HYPERLINK "http://www.yahoo.com"}}{\fldrslt {\cf1\f0\fs20\b http://www.yahoo.com}}}\par
}

@ivanlanin
Copy link
Contributor

Ah, so that's the case :) So you can now use styling for links in RTF? Please close this when you confirm that your issue is solved.

The RTF writer is very much underdeveloped compared to the other writers. I'm just starting to work on it during my sparetime. Feel free to help develop it if you have time. Thanks.

@Centurious
Copy link
Author

Yes the styling for links and page breaks now works as expected.
Thank you very much for adding the code.
I would consider developing it in my spare time if there are any instructions on how to start contributing.

@ivanlanin
Copy link
Contributor

Good to know that it worked. The only "contributing instruction" that we have now is this page, but you've already helped us by submitting any issue that you're facing when using PHPWord. Thanks.

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