Open and Close a PDF File Using Swift

Anvi Jain
Updated on 30-Jul-2019 22:30:24

700 Views

In this article we’ll see how to open a pdf file using swift in iOS. Here we’ll do it with an example of opening pdf in webView in iOS. Let’s create a project and add WKWebView to the storyboard.Connect it’s outlet to the ViewController class.Now we’ll see two different thingsOpening a PDF file from a URL on the web.To open a web view from a url, first we need to have a url with a pdf file. In this example I’ll be using a dummy URL https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdfLet’s create a URL first, let url: URL! = URL(string: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")Now the remaining steps ... Read More

Equivalent of SQL Server Identity Column in MySQL

George John
Updated on 30-Jul-2019 22:30:24

9K+ Views

Equivalent of Microsoft SQL Server IDENTITY column in MySQL is AUTO_INCREMENT. The IDENTITY in SQL Server acts like AUTO_INCREMENT in MySQL.The syntax is as follows −CREATE TABLE yourTableName (    yourColumnName1 dataType NOT NULL AUTO_INCREMENT,    yourColumnName2 dataType,    .    .    .    N,    PRIMARY KEY(yourColumnName1) );In MySQL, you need to use primary key if your column is auto_increment otherwise MySQL will give an error. Look at the error −mysql> create table EquivalentOfIdentityInMySQL    -> (    -> ProductId int NOT NULL AUTO_INCREMENT,    -> ProductName varchar(30)    -> ); ERROR 1075 (42000) − Incorrect table definition; ... Read More

Order By Date in MySQL with Empty Dates at the End

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

522 Views

Order by date and set the empty dates in the last with the help of ORDER BY clause and IS NULL property. The syntax is as follows:SELECT *FROM yourTableName ORDER BY (yourDateColumnName IS NULL), yourDateColumnName DESC;In the above syntax, we will sort the NULL first after that date. To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table DateColumnWithNullDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> LoginDateTime datetime, -> PRIMARY KEY(Id) -> ... Read More

Display a Percentage in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

2K+ Views

To display a percentage in Java, use the following DecimalFormat.DecimalFormat decFormat = new DecimalFormat("#%");Since, we have used the DecimalFormat class, therefore do not forget to import the following package −import java.text.DecimalFormat;Now, let us learn how to display percentage −decFormat.format(0.80) decFormat.format(-0.19) decFormat.format(1.88)The above will be displayed as −80% -19% 188%The following is the complete example −Example Live Demoimport java.text.DecimalFormat; public class Demo { public static void main(String[] argv) throws Exception { DecimalFormat decFormat = new DecimalFormat("#%"); System.out.println(decFormat.format(0.80)); System.out.println(decFormat.format(-0.19)); ... Read More

Resolve the MySQL Error Type MyISAM

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

1K+ Views

To fix the error, you just need to replace TYPE with ENGINE. The syntax to set the engine is as follows −ENGINE = MyISAM;The MySQL error occurs when TYPE is used. Let us see the same scenario while creating a table −mysql> create table Customers −> ( −> CustomerId int, −> CustomerName varchar(200) −> )TYPE = MyISAM;The error is as follows −ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use ... Read More

Will Robots Develop Feelings in the Future?

Knowledge base
Updated on 30-Jul-2019 22:30:24

148 Views

Robotics is the fast emerging technology today. Robots are being designed to be used for various activities from daily domestic chores to military operations. These Robots are designed based on the idea of Artificial Intelligence.What is Artificial Intelligence?A machine is initially developed to take instructions from the user and process it according to a pre-designed program and give the output. Whereas if this machine can do something more extraordinary, other than simply taking the instructions and matching with previously fed data, that would be great. Such a thought is the basis for Artificial Intelligence. This can be understood as the ... Read More

Change Thread Priority in Java

Fendadis John
Updated on 30-Jul-2019 22:30:24

754 Views

A thread can be created by implementing the Runnable interface and overriding the run() method. Then a Thread object can be created and the start() method called.The thread priority determines when the processor is provided to the thread as well as other resources. It can be changed using the method setPriority() of class Thread.A program that demonstrates changing the thread priorities using the method setPriority() in Java is given as follows:Example Live Demopublic class ThreadDemo extends Thread {    public void run() {       System.out.println("Running...");    }    public static void main(String[] args) {       ThreadDemo thread1 ... Read More

Display a Currency Value in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

233 Views

To display a currency in Java, use the following DecimalFormat −DecimalFormat decFormat = new DecimalFormat("\u00a4#, ##0.00");Since, we have used the DecimalFormat class, therefore do not forget to import the following package −import java.text.DecimalFormat;Now, let us learn how to display percentage −decFormat.format(877.80) decFormat.format(8.19) decFormat.format(9897.88)The above will be displayed as −$877.80 $8.19 $9, 897.88The following is the complete example −Example Live Demoimport java.text.DecimalFormat; public class Demo { public static void main(String[] argv) throws Exception { // for currency DecimalFormat decFormat = new DecimalFormat("\u00a4#, ##0.00"); ... Read More

Format Java Date with HH:MM:SS Z using SimpleDateFormat

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

2K+ Views

The Z means "zero hour offset", also known as "Zulu time" (UTC) in the ISO 8601 time representation. However, ACP 121 standard defines the list of military time zones and derives the "Zulu time" from theGreenwich Mean Time (GMT).Let us see the usage of SimpleDateFormat(“HH:mm:ss Z”) −Format f = new SimpleDateFormat("HH.mm.ss Z"); String strResult = f.format(new Date()); System.out.println("Time = "+strResult);The following is the complete example that displays time with offset (HH:mm:ss Z) −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { ... Read More

Data Type for Unix Timestamp in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

2K+ Views

The best data type for unix_timestamp in MySQL is integer. The integer data type is as followsint(11);The integer data type is useful for condition checking like ( > , create table UnixTime -> ( -> DueTime datetime -> ); Query OK, 0 rows affected (0.55 sec)Insert records in the form of date using insert command. The query is as followsmysql> insert into UnixTime values(now()); Query OK, 1 row affected (0.15 sec) mysql> insert into UnixTime values('2010-10-14'); Query OK, 1 row affected (0.15 sec) mysql> insert into UnixTime values('2020-09-24'); Query ... Read More

Advertisements