You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Tillinghast, Andrew P." <at...@conncoll.edu> on 2011/11/15 19:57:05 UTC
xwpf paragraph copy help
I'm working on an application that creates a docx resume from a template.
What I am attempting to do at this point is to clone a sample job listing from a resume template, then remove the example.
Then loop over database records modifying the sample and insert it back into the original resume.
The problem I'm having is there seems to be no way to create a copy of a paragraph. clone() is not visible
I've tried creating another XWPFDocument creating a paragraph and using set paragraph to put the source paragraph in the temp Document
I've tried creating a new paragraph using the CTR of source paragraph.
But so far every method I've attempted when I remove the paragraph from the source document it removes from the temp document as well.
Is the only way to get a true copy of a paragraph to createParagraph() and manually set the styles, spacing etc to match the source and then createRun() for each run in the source and manually set the text styles etc to match the source?
-Andrew
Re: xwpf paragraph copy help
Posted by "Tillinghast, Andrew P." <at...@conncoll.edu>.
I tried doing a copy from one document to a new document using the get and set for style, spacing etc but the paragraph in the new document didn't have the formating from the original document. How do I get and copy the details of the style?
-Andrew
On Nov 21, 2011, at 8:27 AM, Nick Burch wrote:
> On Tue, 15 Nov 2011, Tillinghast, Andrew P. wrote:
>> The problem I'm having is there seems to be no way to create a copy of a paragraph. clone() is not visible
>
> Caling clone won't do it, because a paragraph's properties aren't generally stored directly on it. Instead, they're held mostly in style tables, so to copy a paragraph from one document to another you'll first have to identify and clone the styling, before copying the text and linking it to the new styles
>
>
>> Is the only way to get a true copy of a paragraph to createParagraph() and manually set the styles, spacing etc to match the source and then createRun() for each run in the source and manually set the text styles etc to match the source?
>
> Largely, yes. Ideally we'd provide a helper method somewhere to do this for people though (much as we have for HSSF/XSSF cell styles), if you do get this working we'd love the patch!
>
> Cheers
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: xwpf paragraph copy help
Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 15 Nov 2011, Tillinghast, Andrew P. wrote:
> The problem I'm having is there seems to be no way to create a copy of a
> paragraph. clone() is not visible
Caling clone won't do it, because a paragraph's properties aren't
generally stored directly on it. Instead, they're held mostly in style
tables, so to copy a paragraph from one document to another you'll first
have to identify and clone the styling, before copying the text and
linking it to the new styles
> Is the only way to get a true copy of a paragraph to createParagraph()
> and manually set the styles, spacing etc to match the source and then
> createRun() for each run in the source and manually set the text styles
> etc to match the source?
Largely, yes. Ideally we'd provide a helper method somewhere to do this
for people though (much as we have for HSSF/XSSF cell styles), if you do
get this working we'd love the patch!
Cheers
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org