SetAPStringValue fails to set AP value for annotation - pdf

I'm using pdfium library to implement a UWP pdf viewer to view & annotate pdf documents.
I'm trying to set the AP of an annotation using SetAPStringValue method. But it always returns false, I can't figure out what's wrong there, Could someone help me on this please?
It is possible to set the AP to a null value always.
This is the AP I'm trying to set, Is there anything wrong with this value?
0 0.666672 0.800003 RG\r\n8 w\r\n1 J\r\n212.968 508.014 m\r\n212.968 504.9358 214.6739 502.1574 214.668 499.017 c\r\n214.6547 491.9495 212.5402 484.6869 211.076 477.821 c\r\n210.0284 472.9084 208.7786 468.0123 208.137 463.024 c\r\n208.0518 462.3612 207.356 459.7253 208.964 459.875 c\r\n213.5747 460.3044 219.8137 467.0719 223.299 469.701 c\r\n237.2607 480.2329 250.7885 491.2484 264.405 502.218 c\r\n268.4264 505.4576 272.3506 508.8012 276.312 512.112 c\r\n276.7569 512.4838 278.6922 514.3737 279.692 514.422 c\r\n282.4142 514.5536 281.4551 503.5199 281.455 502.658 c\r\n281.454 490.1216 281.1169 477.5842 281.018 465.048 c\r\n281.0128 464.3856 280.2306 456.1341 281.317 455.688 c\r\n282.5744 455.1717 285.308 456.9032 285.826 457.248 c\r\n290.2267 460.177 293.8474 464.3806 297.173 468.424 c\r\n306.4158 479.6619 314.0752 492.1592 323.835 502.989 c\r\n328.4252 508.0824 335.0986 516.2838 341.875 518.736 c\r\n345.0803 519.8959 342.9341 507.3706 342.716 505.824 c\r\n342.3412 503.1659 342.5182 504.5981 342.22 502.051 c\r\n342.1545 501.4919 341.7112 499.8896 341.991 500.378 c\r\n346.9278 508.9975 351.6264 517.5739 357.18 525.9 c\r\n358.8962 528.473 362.074 534.9524 365.907 535.166 c\r\n369.1411 535.3463 370.1482 527.8484 370.606 525.934 c\r\n372.8778 516.4341 376.1095 505.7724 384.086 499.386 c\r\n395.6985 490.0885 415.9169 503.0661 426.441 508.202 c\r\nS\r\n
Are there any constraints which I should be aware of on this process?
Thanks

Related

Janus GridEX - C# How to show multi-line header using columnsets at runtime?

I have already tried:
How to wrap header caption in Janus GridEx
and
https://www.c-sharpcorner.com/forums/table-column-set
and looked through Janus documentation at http://codelibraries.blogspot.com/search/label/Janus%20GridEX.
I have a business requirement to show wrapped column header. For example, if column header is:
This is column header
need to show
This is column
header
As it is right now (before I tried implementing code for this requirement), code looked like:
dgMulti.SetDataBinding(bulkTable, "")
dgMulti.RetrieveStructure()
Dim column As Janus.Windows.GridEX.GridEXColumn
For Each column In dgMulti.RootTable.Columns
column.Width = 150
Next
where bulkTable is a System.Data.DataTable object.
After visiting above links, I tried suggestions and used ColumnSets as shown below and added after above code:
Dim CSET As New Janus.Windows.GridEX.GridEXColumnSet()
CSET.Caption = "YourCaption"
CSET.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center
CSET.ColumnCount = 2
CSET.Width = 150
CSET.Key = "YourCaptionKey"
' FOLLOWING LINE THROW ERROR
**CSET.Add(New Janus.Windows.GridEX.GridEXColumn(dgMulti.RootTable.Columns(0).Key, dgMulti.RootTable.Columns(0).ColumnType), 0, 1)
CSET.Add(New Janus.Windows.GridEX.GridEXColumn(dgMulti.RootTable.Columns(1).Key, dgMulti.RootTable.Columns(1).ColumnType), 0, 2)**
dgMulti.RootTable.ColumnSets.Add(CSET)
dgMulti.RootTable.ColumnSetHeaderLines = 2
dgMulti.RootTable.CellLayoutMode = Janus.Windows.GridEX.CellLayoutMode.UseColumnSets
Error: Operation is not valid due to the current state of the object.
Can you please help what I am missing? I believe I need to somehow link the columns with ColumnSets but how?
You don't need columnsets for this.
I can't get a deeplink to the janus forums thread with this answer, but here is the copy/pasted answer:
You can put a CR Character if you can determine where to wrap.
in e.g.
Column.Caption = Now.ToString("ddd" & vbCr & "d MMM");
You can see the janus support forums here: https://www.janusys.com. Click through to the Winforms GridEX forum, and use search phrase "wrap".
The website is basically unusable in Firefox, I fallback to Chrome to browse.
Dim CSET As New Janus.Windows.GridEX.GridEXColumnSet()
CSET.Caption = "YourCaption"
CSET.HeaderAlignment = Janus.Windows.GridEX.TextAlignment.Center
CSET.ColumnCount = 2
CSET.Width = 150
CSET.Key = "YourCaptionKey"
dgMulti.RootTable.ColumnSets.Add(CSET)
CSET.Add(dgMulti.RootTable.Columns.Add("Yourcolumnkey"), 0, 0)
CSET.Add(dgMulti.RootTable.Columns.Add("Yourcolumnkey"), 0, 1)
dgMulti.RootTable.ColumnSetHeaderLines = 2
dgMulti.RootTable.CellLayoutMode = Janus.Windows.GridEX.CellLayoutMode.UseColumnSets

LibreOffice API/UNO: How to horizontal right-align text in table cell in writer

I'm using C++ to control LibreOffice/OpenOffice from another application, but I guess you can help me if you know the java-bridge as well. So basically I want to load a document (works), set the text of a cell (works) and set a table-cell to horizontal align right (which I got no idea how to do it):
I do:
// Load Document
Reference <XInterface> rDoc = myLoader->loadComponentFromURL(...);
// Get Table
Reference <XTextTablesSupplier> rTablesSuppl(rDocument, UNO_QUERY);
Any any = rTablesSuppl->getTextTables()->getByName("Table1");
Reference<XTextTable> rTable(any, UNO_QUERY);
// Set Text in cell
Reference<XCellRange> rRange (rTable, UNO_QUERY);
Reference<XCell> rCell = rRange->getCellByPosition(x, y);
Reference<XTextRange> rTextRange(rCell, UNO_QUERY);
rTextRange->setString("MyNewText");
// Align "MyNewText" right
????
Any idea how to continue?
Caveat... While I have experience with C++, I use Java for LO API programming, so the following may be a bit off. You'll probably have to tweak a bit to get things going.
In Java and using the cell name to get the cell, I right-justified text in a cell like this:
XCell xCell = xTextTable.getCellByName(cellname);
XText xText = UnoRuntime.queryInterface(XText.class, xCell);
XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xText.getStart());
xPropertySet.setPropertyValue("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT);
In C++ and using the cell position to get the cell, I'm thinking that a rough translation would be:
Reference<XCell> rCell = rRange->getCellByPosition(x, y);
Reference<XText> rText(rCell, UNO_QUERY);
Reference< XPropertySet > xPropSet( rText->getStart(), UNO_QUERY );
xPropSet->getPropertyValue("ParaAdjust") >>= com::sun::star::style::ParagraphAdjust.RIGHT;
Given what you've already got, it looks like you might be able to just replace your ???? with something like this:
Reference< XPropertySet > xPropSet( rTextRange, UNO_QUERY );
xPropSet->getPropertyValue("ParaAdjust") >>= com::sun::star::style::ParagraphAdjust.RIGHT;

Why is a DOORS Module sometimes null when trying to edit the Module via DXL?

I'm new to DXL programming language in IBM DOORS. However, I think I have managed to do many interesting things: create Modules, create Objects, create Links, delete Objects etc.
However, I have a very specific problem regarding "null" Modules. I've just written null between "" because the modules exist and they are referenced with a correct name.
When doing this:
Module m1 = edit("1. MY_MODULE", false)
save(m1)
close(m1)
An error like this appears:
enter image description here
You could not understand what does that mean as it is spanish. Basically states this: "Module null parameter in the first position of the argument." That means that the "m1" is null, as the parameter for save() method is null.
The point is that it is an error which appears only sometimes. It seems that the Module is null as it has been previously opened and DOORS does not close properly.
Is there any way, any method...whatever to avoid this error?
I assume that the script cannot find the module when another folder is active.
Try
Module m1 = edit ("/myproject/myfolder/mysubfolder/1. MY_MODULE", false)
There might be many reasons that the module can't be opened in edit mode. For example: User do not have write access OR Module is being used by other user, etc.
However, you can get around the error with the below code snippet:
Module m = edit('My_module', false)
if(!null m) {
//execute program
...
}
else {
//do something
}
I hope this helps.
How does your script work? do you open the same module again and again and sometimes get the error or do you open lots of modules and for some of them it works and for others it doesn't? In the latter case, perhaps you misspelled the path. You could add some sanity checks like
string fullPathToMod = "/myproject/myfolder.."
Item i = item fullPathToMod;
if null i then error "there is no item called " fullPathToMod
if "Module" != type i then error "there is an item, but it's not a module, it's a " type i
This is how the Code is structured:
void checkModule(string folderPath, string mName, Skip list, int listSize, int listLastIndex, string headers[], string heading[], string headerKey, bool uniqueKey, string combinedKey[]){
if (module mName){
Folder f = folder(folderPath)
current = f
Module m = edit(folderPath""mName, false)
current = m
Object o = first(m) // error sometimes: Se ha pasado un parametro Module null en una posiciĆ³n de argumento 1
if (o == null){
loadModule(m, list, listSize, listLastIndex, headers, heading)
} else {
updateModule(m, mName, list, listSize, listLastIndex, heading, headerKey, headers, uniqueKey, combinedKey)
save(m)
close(m)
}
if (lastError() != ""){
print "Error: " lastError() "\n"
}
} else {
print "No module " mName ".\n"
}
}
Exactly it breaks in line:
current = m
But as said, only sometimes, not always.
BTW, I'm executing this script via Batch, via Java code. One curious thing is that if I close DOORS, and execute the script it does execute correctly. It is as if it needs to be closed in order to edit modules correctly.
I pressume current can be used more than once with different types of Items. I guess it should not be wrong, but it breaks saying (more or less):
Null value passed to DXL commmand (current Module).
Obviously, it means that m is null, but I cannot see any reason for that.

How to get the content of a document in documentum

I am new to documentum,can anyone suggest me how to get the content of a document in documentum. I am using the following code
document = (IDfSysObject) session.getObject(new DfId("some document id"));
document.getContent();
I am getting the following error:
DfSysObjectException:: THREAD: main; MSG: [DM_SYSOBJECT_E_INVALID_PAGE_NUM]error: "Invalid page number = 0 for 0000868416 sysobject. Maximum page count is 0."; ERRORCODE: 100; NEXT: null
at com.documentum.fc.client.DfSysObjectException.newInvalidPageNumberException(DfSysObjectException.java:47)
at com.documentum.fc.client.content.impl.ContentManager.verifyPageExists(ContentManager.java:151)
at com.documentum.fc.client.content.impl.ContentManager.getContentNoPermissionCheck(ContentManager.java:106)
at com.documentum.fc.client.content.impl.ContentManager.getContent(ContentManager.java:91)
at com.documentum.fc.client.content.impl.ContentManager.getStream(ContentManager.java:50)
at com.documentum.fc.client.DfSysObject.getContentEx3(DfSysObject.java:1952)
at com.documentum.fc.client.DfSysObject.getContentEx2(DfSysObject.java:1942)
at com.documentum.fc.client.DfSysObject.getContent(DfSysObject.java:1932)
at com.documentum.fc.client.DfDocument___PROXY.getContent(DfDocument___PROXY.java)
Can any one please help me with the above error and Is it the right way to get the content of a document with
document.getContent();
Thanks in advance

How to get chart info from an Excel spreadsheet using Apache POI?

Is it possible to extract chart information from an Office 2007 (xlsx / OpenXML) spreadsheet using Apache POI? I've managed to read in the spreadsheet and even get the part that refers to the chart but not sure how I can retrieve any info from this part e.g. Type of chart, chart data etc.
XSSFWorkbook xwb = new XSSFWorkbook("charts_lines.xlsx");
XSSFSheet sheet = xwb.getSheetAt(0);
I can also iterate through the package parts to retrieve the chart part, but I don't see how I then go on to retrieve any info about the chart?
Note, I'm not interested in creating charts using POI, just read as much chart info as is possible to do...I'm also not saving an xlsx. I simply wish to extract line colours, labels, data, chart type (pie, line, bar etc.)
There isn't a high level representation at the moment, so you'll need to drop down into the xmlbeans level and work with the low level CT* objects.
For Chart Sheets, there's XSSFChartSheet which will give you a CTChartsheet object, which has a little bit of info.
For both XSSFChart and XSSFChartSheet (regular and chart sheets), you'll need to go via the drawings to get the charts. Each sheet with charts on it should have one Drawing, and the charts get linked from the drawing, rather than the sheet itself.
As of r1090442 (so POI 3.8 or newer), there's a method on XSSFDrawing to give you all the XSSFChart objects (which are wrappers around the /charts/chart#.xml part). If you're on a really really old version of POI, use the CTDrawing to get the details of the chart, grab the /charts/chart#.xml part that corresponts, and then have xmlbeans give you the CT objects for it. Either way that'll let you get the titles, types, data ranges etc.
It is a bit fiddly though, so do please consider sending in a patch to POI if you get something good worked out for working with the CTChart objects!
you can read chart data as XML using XSSFDrawing
like
XSSFDrawing drawing = ((XSSFSheet)sheet).createDrawingPatriarch();
System.out.println(drawing.getCTDrawing().toString());
will print whole chart as XMl and also using
drawing.getCharts();
you can add Iterator to it to browse chart
I don't know the exact answer to your question, but the OpenXML SDK 2.0 comes with a DocumentReflector.exe tool that will show you exactly how the chart is defined (including all relationships between the SpreadsheetML and the DrawingML packages). There is some more info on this tool in this article.
Yes, It is possible to read any type of chart using Apache POI. But Before reading any chart information you need to know what XML string you are receiving because this could be different based on the chart type i.e. pie, line, bar, scatter or mixed (a combination of two or more) charts, etc. Therefore you approach will be different for different type of chart.
For a simple bar chart like this:
Your XML will look something like this:
<xml-fragment ...>
<c:title>
<c:tx>
<c:rich>
...
<a:p>
...
<a:r>
...
<a:t>Employee Salary</a:t>
</a:r>
</a:p>
</c:rich>
</c:tx>
...
</c:title>
...
<c:plotArea>
...
<c:barChart>
...
<c:ser>
...
<c:cat>
<c:strRef>
...
<c:strCache>
<c:ptCount val="5"/>
<c:pt idx="0">
<c:v>Tom</c:v>
</c:pt>
<c:pt idx="1">
<c:v>John</c:v>
</c:pt>
<c:pt idx="2">
<c:v>Harry</c:v>
</c:pt>
<c:pt idx="3">
<c:v>Sam</c:v>
</c:pt>
<c:pt idx="4">
<c:v>Richa</c:v>
</c:pt>
</c:strCache>
</c:strRef>
</c:cat>
<c:val>
<c:numRef>
...
<c:numCache>
<c:formatCode>"$"#,##0</c:formatCode>
<c:ptCount val="5"/>
<c:pt idx="0">
<c:v>1000</c:v>
</c:pt>
<c:pt idx="1">
<c:v>700</c:v>
</c:pt>
<c:pt idx="2">
<c:v>300</c:v>
</c:pt>
<c:pt idx="3">
<c:v>900</c:v>
</c:pt>
<c:pt idx="4">
<c:v>800</c:v>
</c:pt>
</c:numCache>
</c:numRef>
</c:val>
...
</c:ser>
...
</c:barChart>
...
</c:plotArea>
...
</xml-fragment>
Now based on the above XML String we can use CT* classes and its various methods to traverse through the whole XML using Apache POI. Let's see how to read Chart Title, Labels(Employee names) and Series(Employee salaries) using POI:
Workbook workbook = new XSSFWorkbook(new File(PATH));
Sheet sheet = workbook.getSheet("GraphSheet");
XSSFSheet xsheet = (XSSFSheet) sheet;
XSSFDrawing drawing = xsheet.getDrawingPatriarch();
if (drawing != null) {
List<XSSFChart> charts = drawing.getCharts();
for (int chartIndex = 0; charts != null && chartIndex < (charts.size()); chartIndex++) {
XSSFChart chart = charts.get(chartIndex);
CTChart chart2 = chart.getCTChart();
CTPlotArea plot = chart2.getPlotArea();
System.out.println("Chart Title :" + chart2.getTitle().getTx().getRich().getPArray(0).getRArray(0).getT());
CTBarSer[] ctScaSerList = plot.getBarChartArray(0).getSerArray();
for (CTBarSer ctLineSer : ctScaSerList) {
CTStrVal[] ctStrVals = ctLineSer.getCat().getStrRef().getStrCache().getPtArray();
for (int i = 0; i < ctStrVals.length; i++) {
System.out.print(ctStrVals[i].getV() + ",");
}
System.out.println();
CTNumVal[] ctXNumVal = ctLineSer.getVal().getNumRef().getNumCache().getPtArray();
for (int i = 0; i < ctXNumVal.length; i++) {
System.out.print(ctXNumVal[i].getV() + ",");
}
}
}
}
Console:
Chart Title :Employee Salary
Tom,John,Harry,Sam,Richa,
1000,700,300,900,800,
Note: Here, the idea is to first read the XML String(because could be different based on your graph type) and then traverse the whole XML accordingly.