Get form field format itext7 - itext7

I am getting form fields from the PDF document but I did not see any method for getting form field format ForExample there are multiple text form fields in my document including Number field, Date field, Percentage field.
Is there any way to get field format type in itext7

#Uladzimir Asipchuk
/TU dictionary contains ToolTip value. Format value is contained in /AA >> /K dictionary in PDF structure. However I have extracted the JS Method after some tries and exploring the PDF structure through Pre-Flight. The following code snippet give the associated JSMethod if any:
PdfDictionary additionalActions = formField.GetAdditionalAction();
if (additionalActions != null)
{
PdfDictionary formatDictionary = additionalActions.GetAsDictionary(PdfName.K);
PdfString jsMethod = formatDictionary.GetAsString(PdfName.JS);
string fieldJsMethod = jsMethod.GetValue();
}

I created a pdf via Adobe (as you suggested) and I indeed was able to set the "format" of a text field as Date, Number, Percentage, Email,..
Then I opened the resultant pdf in RUPS (an utility program used to open the pdf's tree) and investigated it.
It turned out that Adobe sets the "format" which you want to get as a /TU value of the field's dictionary. For example, for Percentage it's percentfield and for Email - emailfield.
Now the only thing you need to find the "format" of your fieeld is to get the value of /TU entry of your field:
field.getValue().getPdfObject().get(PdfName.TU)

Related

citation style language - extend with an additional field

I produce a bibliography with pandoc from a bibtex file. In my bibtex entries I have the location of the pdf (not an url, just a file reference in a field file). I would like to include this reference in the bibliography, but do not see how to extend the chicago-author-date.csl - I am completely new to CSL...
I assume I have to add something like
<text macro="file" prefix=". "/>
in the layout section. But how to define the macro? How is the connection between the bibtex field and the CSL achieved?
Is there somewhere a "how to" page?
Thank you for help!
An example bibtex entry is:
author = {Frank, Andrew U.},
title = {Geo-Ontologies Are Scale Dependent (abstract only)},
booktitle = {European Geosciences Union, General Assembly 2009, Session Knowledge and Ontologies},
year = {2009},
editor = {Pulkkinen, Tuija},
url = {http://publik.tuwien.ac.at/files/PubDat-175453.pdf},
file = {docs/docs4/4698_GeoOntologies_abstarct_EUG_09.pdf},
keywords = {Onto},
owner = {frank},
timestamp = {2018.11.29},
}
the file entry should be inserted in the output as a relative web reference (clickable) - in addition to the usual output from the chicago-author-data style.
I add a list of nocite to the markdown text (read in from file) and process it (in Haskell) with the API
res <- processCites' markdownText
It works ok, I miss only the file value.

Error while saving modified excel(xlsx) file with ClosedXML

I am trying to add title rows on an existing excel file (xlsx) with ClosedXML library and following code:
public void HandlePrintTitleRows(IList<int> sheetIndex)
{
using (_workbook = new XLWorkbook(_filePath))
{
foreach (var i in sheetIndex)
{
IXLWorksheet workSheet = _workbook.Worksheet(i);
workSheet.PageSetup.SetRowsToRepeatAtTop(1, 5);
}
_workbook.SaveAs(_filePath);
}
}
File path is from SaveFileDialog dialog and it opens seemingly correct as XLWorkbook.
I am receiving this exception message from the _workbook.SaveAs method:
Attribute 'xfId' should have unique value. Its current value '10'
duplicates with others. in /x:styleSheet[1]/x:cellStyles[1]/x:cellStyle[21]Attribute 'xfId'
should have unique value. Its current value '12' duplicates with
others. in /x:styleSheet[1]/x:cellStyles[1]/x:cellStyle[24] Attribute 'xfId'
should have unique value. Its current value '50' duplicates with
others. in /x:styleSheet[1]/x:cellStyles[1]/x:cellStyle[55 Attribute 'xfId'
should have unique value. Its current value '50' duplicates with
others. in /x:styleSheet[1]/x:cellStyles[1]/x:cellStyle[59]"
StackTrace:
at ClosedXML.Excel.XLWorkbook.Validate(SpreadsheetDocument
package) in
C:\Git\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 90
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath,
SpreadsheetDocumentType spreadsheetDocumentType, B...
I am not sure how to proceed with this problem, all tips would be greatly appreciated ! The excel file has been previously created by Telerik.Windows.Documents.Spreadsheet.Model.Workbook class and opens normally with excel application.
Open your original file (unmodified by ClosedXML) with the OpenXML SDK Validator to see if it's a valid file. If the validation errors occur in the original file, fix them, or you can disable validation in ClosedXML by using the SaveAs(_filePath, false) overload at your own risk.

How to set variable values to specific cell or element in BIRT

I have declared variable in beforeFactory of BIRT Report.
For example:
This variable I am incrementing in table row render like:
Now when all the rows are rendered I want to set above variable to specific cell/ element. I tried
document.getElementName("numberOfMobilityFilesProcessed").text = numberOfMobilityFiles;
AND
reportContext.getDesignHandle().getElementByID
but they are not working out for me.
I had some problems with temporaly local variables used at multiple steps of datasource scripting so I always used global persisting.
After changing your variable you convert it to a String (because only Strings can be persisted) and before editing your variable again, you load the String from persisted context and convert it to the type you want (String to Integer are automatically converted by JavaScripts dynamic typed variables, but don't forget the toString() when you are saving otherwise you will risk an error).
Because you are using reportContext.setPersistentGlobalVariable your variable is accessable in every Element of your Report.
Example:
var rowNum = reportContext.getPersistentGlobalVariable("row_number");
if(rowNum == null){
rowNum = -1;
}
rowNum++;
reportContext.setPersistentGlobalVariable("row_number", rowNum.toString());
Ok, you have a text element displaying a number of row in a table element. The text element appears before the table in the report.
If you are using two separate tasks RunTask and RenderTask:
Add a report variable in your report (see "variable" node on the Data Explorer view). Then you can change the report variable in onCreate() event handler of the table row:
vars["numberOfSomething"] = vars["numberOfSomething"] + 1;
and access its value in an onRender() evenet handler of some text element, for instance DynamicText:
this.text = "Number of something: " + vars["numberOfSomething"];
If you are using RunAndRenderTask, you must look for another approach. In this case an order of onCreate() and onRender() calls is different. You could bind the same DataSet to the text element displaying the counter, as the one bound to the table. Than you can add an aggregation binding to the text element that will count all rows in the dataset.

Getting model value and generated ID from within simple_form custom input

I'm trying to make a custom input type with simple_form that will implement combobox-type functionality using jQuery-Autocomplete
. What I need to do is output a hidden field that will hold the ID of the value selected and a text field for the user to type in.
Here's what I have so far:
class ComboboxInput < SimpleForm::Inputs::Base
def input
html = #builder.hidden_field(attribute_name, input_html_options)
id = '' #what?
value = '' #what?
return "#{html}<input class='combobox-entry' data-id-input='#{id}' value='#{value}'".html_safe
end
end
I need to get the ID of the hidden field that simple_form is generating to place as an HTML attribute on the text entry to allow the JavaScript to "hook up" the two fields. I also need to get the value from the model to prepopulate the text input. How do I do this from within my custom input?
I'm looking for the id as well, but I did get the value:
def input
current_value = object.send("#{attribute_name}")
end
I just found a hokey id workaround:
html = #builder.hidden_field(attribute_name, input_html_options)
id = html.scan(/id="([^"]*)"/).first.first.to_s
I know it's a hack, but it does work. Since we don't have access directly to this type of resolution, it is likely to keep working even if the underlying id creation code changes.

MSXML2.DOMDocument.xml give me malformed xml

We have an old legacy system that where a component is writter in VB6. One method returns a string that is xml data. The xml data is created with msxml3.dll MSXML2.DOMDocument and returns the data of the document with the property xml: http://msdn.microsoft.com/en-us/library/ms755989(v=VS.85).aspx
However, some data of the xmldocument is from the database and one field is a hashed password string. The code that set the data for the element:
Set cellNode = rowNode.appendChild(xml.createElement("COL"))
If IsNull(rs(oField.name).Value) Then
cellNode.Text = ""
Else
cellNode.Text = rs(oField.name).Value
End If
This gives me malformed/non-wellformed xml:
<ROWS><ROW><COL>r<í</COL></ROW></ROWS>
Is there a workaround for this?
You should escape unicode characters. Or put them in a CDATA tag (which is not such a nice solution though)
Btw < > and & should be escaped as well.

Resources