I am trying to form ribbon XML with the data from the database and following is what I wrote:-
XNamespace xNameSpace = "http://schemas.microsoft.com/office/2006/01/customui";
XDocument document = new XDocument();
document.Add( new XElement (xNameSpace+"customUI"
, new XElement("ribbon"
, new XElement("tabs"))));
// more code to add the groups and the controls with-in the groups
.......
// code below to add ribbon XML to the document and to add the relationship
RibbonExtensibilityPart ribbonExtensibilityPart = myDoc.AddNewPart<RibbonExtensibilityPart>();
ribbonExtensibilityPart.CustomUI = new DocumentFormat.OpenXml.Office.CustomUI.CustomUI(ribbonXml.ToString());
myDoc.CreateRelationshipToPart(ribbonExtensibilityPart);
I don't see any error executing the above. However, when I open the changed document, I dont see my ribbon added. I see following in the CustomUI/CustomUI.xml inside the word:-
<?xml version="1.0" encoding="utf-8"?><customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon xmlns="">
<tabs>
.....
I am not sure how the "xmlns" attribute is getting added to the ribbon element. When I remove that attribute, the ribbon gets showed.
Could anybody throw any idea on where am I going wrong?
I ended up string replacing that string xmlns="" with empty string from the ribbon tag.
Related
I want to use the Data Source mechanism for granite/ui/components/coral/foundation/form/select widget in AEM dialog.
I want to render additional data attributes in the HTML of select items. When not using data source and having the select items directly in the dialog's XML file, I can add the data attributes using granite:data node:
<text
jcr:primaryType="nt:unstructured"
text="Text"
value="text">
<granite:data
jcr:primaryType="nt:unstructured"
custom-attribute="custom-attribute-value"/>
</text>
Is it possible to somehow include the data attribute when the items are coming from a Data Source Servlet? I am using this example code for my data source servlet. In particular, I'm updating the value map of the resource and returning it to the dialog. Is there anything I can do with this value map to render `data-custom-attribute="custom-attribute-value" in the particular element's HTML?
private Resource getItemResource(ResourceResolver resolver, String text, String value) {
ValueMap vm = new ValueMapDecorator(new HashMap<>());
vm.put("text", text);
vm.put("value", value);
return new ValueMapResource(resolver, "", "", vm);
}
Adding additional entries to this map indeed causes rendering of data attributes for granite/ui/components/foundation/form/select, but not for granite/ui/components/coral/foundation/form/select which I want to use.
We can add a child node with a name granite:data to the resource that we will be returning from the DataSource servlet. The properties of this child node will become pairs of data attributes in the markup. I don't think this is possible using ValueMapResource, as in the question, but can be done using real resources that are stored in JCR.
A number of other properties can be added to the original resource (not as children), and they will get rendered in the HTML markup, too:
granite:id
granite:rel
granite:class
granite:title
granite:hidden
granite:itemscope
granite:itemtype
granite:itemprop
I am using iTextSharp 5.5.3 i have a PDF with named fields i created with Adobe lifecycle I am able to fill the fields using iTextSharp but when i change the textcolor for a field it does not change. i really dont know why this is so. here is my code below
form.SetField("name", "Michael Okpara");
form.SetField("session", "2014/2015");
form.SetField("term", "1st Term");
form.SetFieldProperty("name", "textcolor", BaseColor.RED, null);
form.RegenerateField("name");
If your form is created using Adobe LifeCycle, then there are two options:
You have a pure XFA form. XFA stands for the XML Forms Architecture and your PDF is nothing more than a container of an XML stream. There is hardly any PDF syntax in the document and there are no AcroForm fields. I don't think this is the case, because you are still able to fill out the fields (which wouldn't work if you had a pure XFA form).
You have a hybrid form. In this case, the form is described twice inside the PDF file: once using an XML stream (XFA) and once using PDF syntax (AcroForm). iText will fill out the fields in both descriptions, but the XFA description gets preference when rendering the document. Changing the color of a field (or other properties) would require changing the XML and iText(Sharp) can not do that.
If I may make an educated guess, I would say that you have a hybrid form and that you are only changing the text color of the AcroForm field without changing the text color in the XFA field (which is really hard to achieve).
Please try adding this line:
form.RemoveXfa();
This will remove the XFA stream, resulting in a form that only keeps the AcroForm description.
I have written a small example named RemoveXFA using the form you shared to demonstrate this. This is the C#/iTextSharp version of that example:
public void ManipulatePdf(String src, String dest)
{
PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileStream(dest, FileMode.Create));
AcroFields form = stamper.AcroFields;
form.RemoveXfa();
IDictionary<String, AcroFields.Item> fields = form.Fields;
foreach (String name in fields.Keys)
{
if (name.IndexOf("Total") > 0)
form.SetFieldProperty(name, "textcolor", BaseColor.RED, null);
form.SetField(name, "X");
}
stamper.Close();
reader.Close();
}
In this example, I remove the XFA stream and I look over all the remaining AcroFields. I change the textcolor of all the fields with the word "Total" in their name, and I fill out every field with an "X".
The result looks like this: reportcard.pdf
All the fields show the letter "X", but the fields in the TOTAL column are written in red.
I finally found a way, guess the problem was coming from using Adobe LC, so i switched to Open Office it all worked but when i flatten the form everything disappears. I found a solution to that here ITextSharp PDFTemplate FormFlattening removes filled data
Thanks Mr Lowagie for your help
I am using Org.W3c.dom for generating and parsing XML files in my app.
Here I am stuck because I can not find a way to add more elements to a Root element.
I want to generate Xml as below :
<root>
<siteDesc>abc</siteDesc>
<respCode>false</respCode>
<respMsg>Done</respMsg>
</root>
Here is the code which I am using to generate XML File ...
private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
Element responseElement = document.createElementNS(NAMESPACE_URI, "root");
responseElement.appendChild("TODO") // Confused Here .. How to append elements with their names
Can anyone suggest me, Here In above code .. What are the required changed to add elements to the roor node ????
You want to
create a node and add that to your document (responseElement)
create further Elements and add those to your responseElement (again, using appendChild())
for each of these, create a TextNode and add those to your Elements
In the above, the element creation is distinct from the addition to the document.
I want to add a new custom component in the Web page Editor Palete named "myHTMLComponent".
So, as soon as user opens any html page with WPE, myHTMLComponentM should be present there.
How can I do the needful, moreover this component will as well need to generate the code changes accordingly. How to achieve the desired result.
Is there any input I can get for this.
I already created standardmetadata tag, but what next!
Finally, I found the solution of the problem.
For adding new categories in the palette, we need to use pagedesignerextension in plugin.xml as following -
<extension
point="org.eclipse.jst.pagedesigner.pageDesignerExtension">
<paletteFactory
class="com.comp.myeditor.palette.CustomEditorPaletteFactory">
</paletteFactory>
</extension>
Where CustomEditorPaletteFactory will be extending AbstractPaletteFactory. Here in createPaletteRoot(), we can add our category.
public PaletteRoot createPaletteRoot(IEditorInput editorInput){
PaletteRoot paletteRoot = new PaletteRoot();
paletteRoot.add(createStandardComponents());
return paletteRoot;
//return null;
}
private static PaletteContainer createStandardComponents() {
PaletteDrawer componentsDrawer = new PaletteDrawer("CustomHTMLComponent");
TagToolPaletteEntry paletteEntry = new TagToolPaletteEntry(
new FormPaletteComponent(".....);
componentsDrawer.add(paletteEntry);
return componentsDrawer;
}
This will create the component category in the palette and we can add as many components as needed using the componentsdrawer.
For adding a new category in the existing one -
Add this in the constructor -
super();
this._paletteContext = PaletteItemManager.createPaletteContext(file);
this._manager = PaletteItemManager.getInstance(_paletteContext);
Then use Palette Grouping like this -
PaletteGroup controls = new PaletteGroup("CUST HTML");
super.add(controls);
ToolEntry tool = new SelectionToolEntry("CUST Cursor",
"Cursor DESCRIPTION");
controls.add(tool);
setDefaultEntry(tool);
//Custom Marquee
controls.add(new MarqueeToolEntry("Marquee", "Marquee Desc"));
controls.add(new PaletteSeparator());
//This class maintins or load all categories features
controls.add(new CustomComponentToolEntry("Custom Component", "Custom Component Descrition",
This really is a good start but I can't find any tutorial or book that get deeper in this matter. For instance, I don't want to replace the default palette but this code does with "new PaletteRoot()" and I lost my HTML tags. Also I want that my new custom components behave as HTML Tags using Drag and Drop, but I don't know how?????????
More Info:
I discovered this code, that was very helpful, whereas file come from ((FileEditorInput)editorInput).getFile()
PaletteRoot paletteRoot = DesignerPaletteRootFactory.createPaletteRoot(file);
This is very interesting topic and I think we are pioneer documenting this feature of eclipse. Here other good point, I want to personalize the tag... e.g. something similiar what I want to achieve is add a tag like "MY TRUEFALSE TAG" and then when is selected and place it in the HTML Designer, I want to become something like <select><option>YES</option><option>NO</option></select> and I guess that I can achieve it by doing something with the tagTransformOperation extension... if you know how to implement it, please let me know. also there is others extensions(tagConverterFactory, elValueResolver). I am guessing here! please I would like your help.
<extension point="org.eclipse.jst.pagedesigner.pageDesignerExtension">
<paletteFactory ...>
<tagTransformOperation id="plugin.tagTransformOperation1XXXXXX">...
SOLUTION?? (Chinese) -solved with tagConverterFactory
http://www.blogjava.net/reloadcn/archive/2007/11/08/webeditor1.html
I want to create a word 2007 document without using object model. So I would prefer to create it using open xml format. So far I have been able to create the document. Now I want to add a content control in it and map it to xml. Can anybody guide me regarding the same???
Anoop,
You said that you are able to creat the document using OpenXmlSdk. With that assumption, you can use the following code to create the content control to add to the Wordprocessing.Body element of your Document.
//praragraph to be added to the rich text content control
Run run = new Run(new Text("Insert any text Here") { Space = StaticTextConstants.Preserve });
Paragraph paragraph = new Paragraph(run);
SdtProperties sdtPr = new SdtProperties(
new Alias { Val = "MyContentCotrol" },
new Tag { Val = "_myContentControl" });
SdtContentBlock sdtCBlock = new SdtContentBlock(paragraph);
SdtBlock sdtBlock = new SdtBlock(sdtPr, sdtCBlock);
//add this content control to the body of the word document
WordprocessingDocument wDoc = WordprocessingDocument.Open(path, true); //path is where your word 2007 file is
Body mBody = wDoc.MainDocumentPart.Document.Body;
mBody.AppendChild(sdtBlock);
wDoc.MainDocumentPart.Document.Save();
wDoc.Dispose();
I hope this answers a part of your question. I did not understand what you ment by "Map it to XML". Did you mean to say you want to create CustomXmlBlock and add the ContentControl to it?
Have a look for the Word Content Control Toolkit on www.codeplex.com.
Here is a very brief explanation on how to do what you are attempting.
You need to have access to the developer tab on the Word ribbon. To get this working click on the Office (Round thingy) in the top left hand corner and Select Word Options at the bottom of the menu. On the first options page there is a checkbox to show the developer toolbar.
Use the developer toolbar to add the Content controls you want on the page. Click the properties button in the Content controls section of the developer bar and set the name and tag properties (I stick to naming the name and tag fields with the same name).
Save and close the word document.
Open the Content control toolkit and then open your document with the toolkit. Use the left hand pain to create some custom xml to link to your controls.
Now use the bind view to drag and drop the mappings between your custom xml and the custom controls that are displayed in the right panel of the toolkit.
You can use the openxml sdk 1.0 or 2.0 (still in ctp) to open your word document in code and access the custom xml file that is contained as part of the word document.
If you want to have a look at how your word document looks as xml. Make a copy of your word document and then rename it to say "a.zip". Double click on the zip file and then navigate the folder structure. The main content of the word document is held under the word folder in a file called "document.xml". The custom xml part of the document is held under the customXml folder and is generally found in the file named "item1.xml".
I hope this brief explanation get you up and running.