Can we set List-Style-Position in pdf using iText 7 ? is there any API available? - itext7

Am trying to find an equivalent method in Itext 7 to set the below style on lists. Is there any API available in Itext7 ?
list-style-position: inside;

Yes, there is API available to set analogue of list-style-position CSS property directly in layout code. For that, use listElement.setProperty(Property.LIST_SYMBOL_POSITION, ListSymbolPosition.INSIDE);
Example code:
Document document = new Document(pdfDocument);
List defaultList = new List();
for (int i = 0; i < 3; i++) {
defaultList
.add("Am trying to find an equivalent method in Itext 7 to set the below style on lists. Is there any API available in Itext7");
}
List bulletPositionInsideList = new List();
for (int i = 0; i < 3; i++) {
bulletPositionInsideList
.add("Am trying to find an equivalent method in Itext 7 to set the below style on lists. Is there any API available in Itext7");
}
bulletPositionInsideList.setProperty(Property.LIST_SYMBOL_POSITION, ListSymbolPosition.INSIDE);
document.add(defaultList);
document.add(bulletPositionInsideList);
Visual result of default list vs one with list symbol position set to inside:

Related

Iterating through controls on a form

I am using C++ Builder. I want to locate several string grids that I have located on different tab sheets of a page control. I know how to iterate through the child controls of a specific control. In my case, each string grid is contained under a separate tab sheet control. My question is, is there a list of all controls in an app, without regards to the hierarchy of where they are contained?
There is such a list: Application->Components, consider code below
for (int i = 0; i < Application->ComponentCount; i++) {
for (int j = 0; j < Application->Components[i]->ComponentCount; j++) {
if (dynamic_cast<TStringGrid*>(Application->Components[i]->Components[j])){
//there is your TStringGrid* regardless of a place in application
}
}
}
You may as well iterate through your tab controls children if you are sure that your string grids are only there.

GetFileAsync for large presentation file cause out of memory

I'm developing a PowerPoint add-in with the feature to upload a presentation to the web server. I have a presentation with 100MB exact size. I used the guidelines for using GetFileAsync in Office docs. It is working for small presentation files. But the add-in message of not responding when I select largely presentation file. I did break point to the code and I found out that the cause of not responding is in js due to the large array slices. There is no problem with getting the slices of a large file. But the problem in when slices array concat to be one array.
Here's the code came from Office docs where the issue occurred.
function onGotAllSlices(docdataSlices) {
var docdata = [];
for (var i = 0; i < docdataSlices.length; i++) {
docdata = docdata.concat(docdataSlices[i]);
}
var fileContent = new String();
for (var j = 0; j < docdata.length; j++) {
fileContent += String.fromCharCode(docdata[j]);
}
// Now all the file content is stored in 'fileContent' variable,
// you can do something with it, such as print, fax...
}
I don't know if it is a bug or issue on the part of Office Add-in. I hope someone helps me.
Thanks in advance.
UPDATES:
I simplify the given function like this:
function onGotAllSlices(docdataSlices) {
var fileContent = new String();
for(var i = 0; i < docdataSlices.length; i++) {
var docdata = docdataSlides[i];
for(var j = 0; j < docdata.length; j++) {
fileContent += String.fromCharCode(docdata[j]);
}
}
var base64String = window.btoa(fileContent);
}
So far, there is no 'out of memory' issue at all. But there is another issue with error message of '8007000e. “Not enough storage is available to complete this operation”' when the fileContent convert in base64String.
This looks like it's a performance problem. Have you checked How to extend an existing JavaScript array with another array, without creating a new array? ? .concat will create a new array from the previous two ones, which you're re-assigning. Perhaps there's a better way of doing this?

How to identify clipping masks in Photoshop using JavaScript

I've currently butchered a script I was reading that loops through a list of layers, and then looks for layers with a certain name (3/2, 4/3 etc). The next step is to check for layer masks that are clipped to the base layer, and merge them to it. I've read through the reference docs, and can't find anything about identifying clipping masks. I've attached an image as an example of how the document is structured.
And here is the code I have so far:
var doc = app.activeDocument
var ratios = ["1/1", "4/3", "3/4", "3/2", "2/3", "16/9", "9/3", "7/2", "11/5"];
for (var i = 0, il = doc.layers.length; i < il; i++) {
var curLayer = doc.layers[i];
for (var j = 0, jl = ratios.length; j < jl; j++) {
if (curLayer.name == ratios[j]) {
alert(curLayer.name);
// Check for clipping masks attached to this layer
}
}
}
I am using Photoshop CS5. Thanks!
I ended up working out another way to do it. I instead grouped the layers into a layerset, and exported them out of the document that way. For those that would like to see it, have a look here:
https://gist.github.com/BeauAgst/4da366b933cc75a0606a

Extract images from PDF with iTextSharp using Jscript

I've seen a few posts on extracting images from PDF using iTextSharp, but all are VB/C# based.
A core part of these solutions is something like:
PdfDictionary res = (PdfDictionary)(PdfReader.GetPdfObject(dict.Get(PdfName.RESOURCES)));
PdfDictionary xobj = (PdfDictionary)(PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT)));
if (xobj != null)
{
foreach (PdfName name in xobj.Keys)
I can create the res and xobj objects fine in Jscript, but JScript does not support foreach loops. I have to do something like
for
(var x = 0; x < xobj.Keys.Count; x++)
{
var name = xobj.Keys(x)
...
}
But this is of course invalid.
Can someone explain how I can parse all the keys in xobj, without using foreach loops?

Using HTML Agility Pack in windows phone 7

How can I get text in p tag behind from body tag with using Linq with HtmlAgilitypack?
Iam not sure that people say htmlagility doesn't support xpath.
I will parse html codes.
Simplest way to use HtmlAgility ->
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(string); //string contains the html code
var paragraphTags = doc.DocumentNode.SelectNodes("p"); //selects all p tags
for (int i = 0; i < paragraphTags.Count; i++) //loop through the p tags
{
String text = paragraphTags[i].InnerHtml;
//text has your paragraph content. use it here.
}

Resources