How to amend select fields in document or PDF using SWIFT - iphone

Is there any way I can have a document or PDF stored on my swift application file and edit select predefined fields inside the document/pdf using swift code?
For example the document/pdf would contain the following fields i'd like to amend; [INPUT1], [INPUT2], [INPUT3]
"What is [INPUT1] Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the [INPUT2], when an unknown printer
took a galley of type and scrambled it to make a type [INPUT3] book.
It has survived not only five centuries, but also the leap into
electronic typesetting, remaining essentially unchanged."
In swift I would like to ask the user 3 questions and have their answers replace [INPUT1], [INPUT2], [INPUT3] respectively.
If not possible to edit word/pdf file is there any other way to achieve this while being able to keep the formatting of the text mentioned above while only changing the mentioned fields.
Thanks again for your help!

Look into implementing PDFKit and see this answer how to implement pdf editor
You have: https://developer.apple.com/documentation/pdfkit

Related

Batch turn plain text into endnotes/footnotes

In a document containing more than 2000 "manual" endnotes (= which are not formatted as such), I'm trying to batch turn plain text paragraphs into proper endnotes or, to be more precise (since the references already exist, thus empty endnotes as well) to sort of "paste" all manual endnotes' text into existing endnotes, based on numbering.
Here is the document pattern :
Lorem ipsum dolor sit amet1 (ref), consectetur adipiscing
elit2 (ref).
[1] Text endnote 1
[2] Text endnote 2
I've tried to play around with Alternate Find & Replace and Regular Expressions, but I could find a way. Couldn't find anything on forums either.

How to use an ellipsis overflow with multiline Text in Flutter

When I configure a Text widget with a maximum of 1 line and an overflow set to ellipsis, the widget shows correctly.
Text(
"Last summer, I was working on a prototype for an AR app that would allow users to create
virtual objects in real world spaces. I carried out the work using the Unity3D game engine.
My last commit to the repository was five months ago.",
maxLines: 1,
overflow: TextOverflow.ellipsis
)
However, when I set the maximum number of lines to any number higher than 1, the
number of lines is limited correctly, but the overflow ellipsis does not show.
Text(
"Last summer, I was working on a prototype for an AR app that would allow users to create
virtual objects in real world spaces. I carried out the work using the Unity3D game engine.
My last commit to the repository was five months ago.",
maxLines: 2,
overflow: TextOverflow.ellipsis
)
How can I configure the Text widget to show the overflow ellipsis when more than one line is set for maxLines?
Find below code , it might help you.
Text(
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
overflow: TextOverflow.ellipsis,
maxLines: 5,
),
In your example, the maximum lines is 3 but the text just show 2 lines of text. It means you dont provide enough height for maximum lines (like the height of it's container).
So you can provide more space for it or reduce maximum lines to 2 or place the text widget in Flex widgets (like ListView, ...)
You can test this one to see what i mean for
Container(
height: 100,
child: Text(
"Last summer, I was working on a prototype for an AR app that would allow users to create virtual objects in real world spaces. I carried out the work using the Unity3D game engine. My last commit to the repository was five months ago.",
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
),

How to make certain part of a large static text bold or italic in UITextView in Swift 2

I just have three months learning experience in Swift, so please forgive my ignorance.
I am doing a Book reading app and populating the chapters using a json file.
The problem i am facing is :
1. This chapter contents can have sub headers or quotes in between them which are supposed to be in bold or some in italics. I am not sure how to identify these parts and display them in bold/italics.
I had two approaches to this:
1. Use just a UITextView to display chapter contents. In this case, my json looks like this :
"book": {
"name": "Fairy Tale,",
"chapters": [
{
"chapterNumber": 1,
"chapterName": "Tale First",
"chapterContents": "<\bold>This is a first heading.And it will be bold.Contents come here<\bold>.This will be plain text. Non bold.<\bold>This is a second heading.<\bold> And it will be bold.Contents come here.This will be plain text. Non bold."
}
]
}
Put some string like <\bold> and use it to split it. And then show the strings in bold for heading and non bold for the contents. But this does not look like a solution, and i am not sure, if i can split this up properly and also do this for all the 18 chapters.
Using a UITableViewCell and put UITextView within it. And pass an array of chapterContents with its heading and contents. So my json looks like this.
"book": {
"name": "Fairy Tales,",
"chapters": [
{
"chapterNumber": 1,
"chapterName": "Tale First",
"chapterContents": [
{
"contentHeader": "This is a first heading.And it will be bold.",
"contents": "Contents come here.This will be plain text. Non bold."
},
{
"contentHeader": "This is a second heading.And it will be bold.",
"contents": "Contents come here.This will be plain text. Non bold."
}
]
}
]
}
and then iterate over the chapterContents array, and put each one in one TableViewCell containing a UILabel for showing the contentHeader, and UITextView for showing the contents. But with this, i will have to remove the scroll since i want the chapters to scroll for the entire length of the screen and not limit to the cell height. And am not sure if this is how the book reading app should be done.
These both dont look like feasible solutions.
Could some one please help me to know
1. if there is some other component that supports this kind of display or a different solution that i can implement to figure out the bold and non bold parts.?
2. Or if using the UITextView inside a UITableViewCell is one of the ways of doing it.?
Thanks in advance. I am using Swift 2.
let json : NSString = <h1>Heading</h1><p><strong>Lorem Ipsum</strong>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h1>Heading</h1><p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
let attrStr = try! NSAttributedString(
data: json.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil)
dispatch_async(dispatch_get_main_queue(), {
yourTextView.attributedText = attrStr
})

Is there any way to generate "Lorem ipsum" in eclipse?

I'm into finding a way to generate Lorem ipsum in eclipse when creating views just for dummy texts. for example in Visual studio you can do it simply by typing lorem and press tab.
Is there any to do that in eclipse? any Idea?
In Android Studio, you can preview lorem ipsum TextViews with:
tools:text="#tools:sample/lorem/random"
You can also use this for Names, Cities, Zip codes, Avatars, and more.
see https://developer.android.com/studio/write/tool-attributes.html#toolssample_resources
I haven't encountered an Eclipse functionality to actually generate dummy text, but I do highly recommend this workaround (truth be told, I don't think you need different dummy text each time).
Create an Eclipe template. It's an xml file that looks like this:
<templates>
<template autoinsert="true" context="java" deleted="false" description="Dummy text" enabled="true" name="Lorem Ipsum">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</template>
</templates>
Go to Java -> Editor -> Templates and import the above file.
Now, when you write code and type lore (which represents the name attribute value of the template tag above), and hit CTRL+SPACE, then it will automatically insert the lorem ipsum text.
More Tips:
Add apostrophes to the ipsum text, so that it automatically generates a Java String
Add + signs to the ispum text, so that it breaks down the long string when inserted
Set the autoinsert attribute to false. Then you can see the ipsum description in the proposal
Set the name of the template to something like aaa_LoremIpsum. Then, in Eclipse, type aaa and press CTRL+SPACE. That way you can add many templates beginning with aaa, and select in Eclipse whichever you like.
I myself have templates for separating methods in a class. (e.g. aaa_1.StaticFields, aaa_2.InstanceFields, aaa_3.Constructors etc.)
They can help.
tools:text="#tools:sample/cities"
tools:text="#tools:sample/backgrounds/scenic"
tools:text= "#tools:sample/avatars"
tools:text="#tools:sample/full_names"
tools:text=”#tools:sample/lorem"
tools:text=”#tools:sample/lorem/random"
for other

Confluence macro for specifying a reference, source of the quotation, etc.?

Is there a way in Confluence for specifying a reference to a text passage — for example, to provide the source of the quoted text, in a similar way as is done on Wikipedia, so that it's rendered like this:
Lorem ipsum dolor sit amet1
[down the page]
1 Cicero
Ideally, the subscript "1" should be an internal hyperlink
I believe this plugin may help: https://marketplace.atlassian.com/plugins/com.adaptavist.confluence.footnotes
The footnotes plugin allows you to quickly and easily add footnote
references to your wiki pages.
You can:
Define Footnotes - Define any number of footnotes throughout your content
Display Footnotes - Display a table of footnotes anywhere in the page
Quickly move between content and footnotes with a click of the mouse
You can do it using anchors:
Pros:
It is native in Confluence
Cons:
It is a very manual procedure (no automatic numbering, etc.)