I’m aware that Aspose.Words doesn’t (yet perhaps) support pages when editing / defining a document, but I would like to implement something that we deem as necessary for our project to go forward.
Attached is a zip file containing 2 doc’s, ideal.doc is what I would ideally like to achieve, which is a shape set to be behind text on every page (1 per page), however I appreciate that this is not possible (I can not use headers to achieve this, as this document will need to be merged into another document that can not contain these shapes).
However, perhaps it is possible to achieve what I have manually done in acceptable.doc, which is to propagate a shape down a document until the end of the document is reached, however I was unable to work out how to do this in Aspose.Words. So my question is, is this possible?
Hi David,
Please give me several hours to investigate probable solutions, although honestly it is hard to find a workaround without having pagination functionality.
David,
One major obstacle to implement the solution is the following. Given the page size, we can calculate relative coordinates of the floating shapes, but they need to be anchored (added) to a paragraph on the same page, and we can’t assume what paragraph it is. Currently I see 2 possible ways to research:
Manually place continuous section breaks at the end of each page. This would help to mark page limits, but based on your description, this is not likely to be acceptable for you because you need to insert watermarks into an arbitrary document, don’t you?
You said that placing the shapes into the header is not suitable, but maybe it still is? Can’t you programmatically remove the shapes from the header before merging the document to another document?
I can appreciate the problem without having a paging system in place, that is why I thought perhaps the second solution might be feasible.
Your assumptions are correct, we have no control over the documents we recieve
I will explain the reason why I think it wouldn’t be possible to use the headers in this instance:
We have one document, we then need to duplicate this document within itself (so basically if the first document was page 1 + page 2, it then becomes page 1 + page 2 + page 1 + page 2 etc) but we need to place a shape on only the duplicated pages (basically with a watermark to indicate that this is a duplicate). I would normally say that we would just create 2 documents, but unfortunatly we have clients that expect this behaviour (of one document).
If you can think of a better way to achieve this behaviour or if you still think headers are applicable, I’m all ears.
I still can’t understand why you think headers are not feasible. If you duplicate the document by cloning and appending sections, then the resulting document will consist of at least two sections which is exactly what we need: the first section will have an empty header and the second section will have a header with floating shapes in it. Based on your words, headers seem to me the ideal solution in your case. Is there something I missed?
Problem solved. Sorry about the misunderstanding, I actually wasn’t aware that Word was capable of having seperate headers/footers per section, so my appologies for my lack of knowledge.
Thanks Alexey,
Now it preserves the watermarks but getting rid off the Header which include text and image(s) which also needs to be preserved along with the watermark.
Thanks again for the help,
Salil
// Create clone of last section
Section section = builder.CurrentSection.Clone();
// Insert cloned sectin to and of the document
doc.Sections.Add(section);
// Delete images from header
section.DeleteHeaderFooterShapes();
// Remove content of section
section.Body.RemoveAllChildren();
// add one empty paragreph (Section.Body must have on paragraph)
section.Body.AppendChild(new Paragraph(doc));
section.HeadersFooters.LinkToPrevious(false);
instead this
builder.InsertBreak(BreakType.SectionBreakNewPage);
builder.CurrentSection.DeleteHeaderFooterShapes();
builder.CurrentSection.HeadersFooters.LinkToPrevious(false);
I hope that this will help you.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.