Underline text in PDF on Mouse Text Selection in Asp.net - asp.net

Can anyone guide me how can I achieve this in my web application ? I am using Aspose.PDF Third Party dll in order to achieve this.I want to select text in PDF using Mouse and then want to underline selected text.

Once you have selected the string over PDF file, you may get the selected string and then parse the selected string to Aspose.Pdf for .NET API and then have tried updating its formatting with underlined text. Please take a look over following code snippet to underline searched string.
// Open document
Document pdfDocument = new Document("c:/pdftest/Table_abc.pdf");
// Create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("Employee_Name");
// Accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber);
// Get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
// Loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
// Underline the selected string
textFragment.TextState.Underline = true;
}
// Save resulting PDF document.
pdfDocument.Save("c:/pdftest/TextUnderlined.pdf");
My name is Nayyer and I am developer evangelist at Aspose.

Related

While updating .docx file using docx4j, Read only fields become editable

In my docx file we have some readonly fields but, While i'm updating docx file using docx4j library that read only fields become editable.
XML Block
In document we have some section and readonly block for guide the user and below that section we have added block for enter value.
Dependency
compile "org.docx4j:docx4j-JAXB-ReferenceImpl:8.3.4"
In Word, Review > Restrict Editing > Editing Restrictions > Filling in Forms
results in the following in the Document Settings part, word/settings.xml:
<w:documentProtection w:edit="forms" w:enforcement="1"/>
Check this value before and after manipulation with docx4j.
If it is changing, then something in your code is changing it.
Basically you want something like:
DocumentSettingsPart documentSettingsPart = getPkg().getMainDocumentPart().getDocumentSettingsPart();
documentSettingsPart.protectRestrictEditing(STDocProtect.FORMS, null, null);
See further https://github.com/plutext/docx4j/blob/VERSION_11_4_7/docx4j-core/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/DocumentSettingsPart.java#L311

Set docx properties using library .docx

How to set properties like title, author, subject for a file created with docx library for .net ?
docx
The DocX project that you provided appears to be able to easily access the metadata properties that you are referring to and can do so quite easily by using the CoreProperties property as seen below :
// Load your Document
var wordFile = Novacode.DocX.Load(#"your-docx-file-path");
// Access Metadata properties
var props = wordFile.CoreProperties;
The issue here is that this collection of properties is read only, so you won't be able to easily change them. However, you may be able to take a look at what the values look like and attempt to add one manually :
So if you wanted to update the title property (clearly named dc:title), you would simply need to add a new Core Property (via the AddCoreProperty() method) that matched that same name and then save the file to persist the changes :
// Load your Document
var wordFile = DocX.Load(#"your-docx-file-path");
// Update Metadata
wordFile.AddCoreProperty("dc:title", "Example Title");
wordFile.Save();
After doing this, you should be able to re-open the file and see that your changes reflected :
As you can see the dc:title property is now set to "Example Title" as per the example code above.

How to get the itemxml of a selected item in Tridion

I would like to get and display the itemxml of the selected item from the Tridion CME.
I was able to get the Itemxml from my VM server when i give the tcm id in the browser.
However, i would like to get the same information from Tridion GUI Extension.
I am able to get the selected item tcm id. Is there any way to get the itemxml using coreservice?
or is there any other way to get this?
At the moment there's no way you can get Item XML through core service. Item XML you have seen was provided to you by TCM Protocol handler that might not be there in future versions. If you want to show item XML in CME - take a look at this extention by Yoaw:
http://sdltridionworld.com/articles/sdltridion2011/tutorials/GUIextensionIn8steps.aspx
Also, keep in mind that not all properties of an item might be exposed in Xml, sometimes you have more info in Data object
Take a look at the PowerTools, it has an ItemXML viewer (written by Robert Curlette) for all items in SDL Tridion
http://code.google.com/p/tridion-2011-power-tools/wiki/ItemXML
The XML is loaded on a tab using JavaScript as follows:
ItemXmlTab.ItemXmlTab.prototype.updateView = function ItemXmlTab$updateView()
{
if (this.isSelected())
{
var xslPath = $ptUtils.expandPath("/PowerTools/Client/ItemXml/ItemXmlTab.xslt", true);
$xml.loadXsltProcessor(xslPath, function (value)
{
var xmlSource = $display.getItem().getXml();
// Filter out all spacing characters
xmlSource = xmlSource.replace(/\t|\n|\r/g, "");
var html = $xml.xsltTransform(value, $xml.getNewXmlDocument(xmlSource), null);
$dom.setOuterHTML($("#itemXml"), html);
});
}
};
You can view the source code of the extension at http://code.google.com/p/tridion-2011-power-tools/source/browse/#svn%2Ftrunk%2FPowerTools.Editor%2FPowerTools%2FClient%2FItemXml%253Fstate%253Dclosed
You can get the item XML via CoreService, but this will get you the Tridion R6 (2011) Xml format, which is not the same you would see before.
Sample code available here.
I tend to have a page "GetItemXml.aspx" on my Tcm servers that I then call with a Uri as a parameter, and then this page would return the Item Xml.
Article written by Yoav Niran (Url in the post of user978511) is perfect for your requirement.
if you are still facing any issue and in hurry to get it working just perform below steps -
1- Download the extension.
2- Apply the steps 7 and 8 of this article to configure this extension.

How can you extend the default behavior of Tridion.Cme.Commands.Open.prototype._execute()?

I have written a GUI extension which adds an additional tab to many of the Item views in the SDL Tridion CME (e.g. Component, Page and Schema etc.). I have also written some JavaScript which loads that tab directly if when the view is loaded with a tab name is specified in the URL.
The result is that if a page is loaded with the tab name added as follows:
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64&tab=InfoTab
Rather than the default of
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64
The Info Tab will be loaded on top, instead of the General Tab. This is performed with the following code snippet and works very well:
$evt.addEventHandler($display, "start", onDisplayStarted);
// This callback is called when any view has finished loading
function onDisplayStarted() {
$evt.removeEventHandler($display, "start", onDisplayStarted);
var tabname = $url.getHashParam("tab");
if (tabname != '') {
var tabControl = $controls.getControl($("#MasterTabControl"), "Tridion.Controls.TabControl");
tabControl.selectItem(tabname);
}
}
Now I would like to make a context menu item to open items and link to the tabs using my new functionality. My first thought was to construct the Item URL myself and simply open a new window in my execute method. So I looked at the default functionality in the standard Open.prototype_execute() functionality of the GUI. This is stored in the navigation.js file of the CME, and is performed by the Tridion.Cme.Commands.Open.prototype._execute method. The code is a lot more complicated than I had anticipated as it deals with shared items, and permissions etc.
Rather than just copying all of this code to my own function, I was wondering if there is a way to elegantly extend the existing Open.prototype_execute() function and append my “&tab=MyTab” to the $cme.Popups.OPEN_ITEM_OPTIONS.URL constant for my own functions.
Any advice would be greatly appreciated.
At the end the Open command uses $config.getEditorUrl(item_type) to get the url for the item view (item_type - $const.ItemType.COMPONENT, etc). There are no extension points for this part of the functionality, but you could always try to overwrite it on your own risk.

Print crystal report without using the default print button

I have an application(ASP.NET), in that I am showing different reports using the crystal report viewer.The deafult print dialog is not matching with the template I used in the page.so decided to make a differnt one.The Export option is dynamically working and exporting the report, but for printing,I use the printToPrinter method, which is not showing up the print dialog where I can seleted the printer and the print quality, paper orientation..etc...
Can anyone suggest a method to invoke the print dialog through this method
In order to configure these parameters in your code you can use:
string printerName = ""; //Insert printer name here.
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new ReportDocument();
rpt.PrintOptions.PrinterName = printerName;
rpt.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
And so on... I think that all the rest of your needed configuration are there, available for you to set.

Resources