In Android and iOS, it is possible to generate PDF files through script.
Following, we briefly describe the functions.

    Set pdf01 = CreateObject("XOnePDF")


With this, we start an xonepdf object to which we can modify the properties with the following methods.


    pdf01.Create "/mnt/sdcard/test.pdf"
    pdf01.Create "/mnt/sdcard/test.pdf", 700, 300


Here, we create the file.
It is essential to call this method first of all.
It is possible to encrypt the document with standard encryption of 128 bits.


Firs parameter File path. If we pass it a full path, it will write it there. This is useful for previewing the PDF at the time to develop the application. If only the name is specified, the file will go to the files folder.
Second parameter Optional together with the third one. It indicates the document width. The possible values are between 0 and 14400.
Third parameter Optional together the second one. It indicates the document height. The possible values are between 0 and 14400.


    pdf01.Open


It opens the document to write about it.

It is necessary to call it before starting to draw upon it and after setting the encryption and permissions.


    pdf01.Close
    Set pdf01 = nothing


Here, all the changed to the PDF are applied, saved, closed and we destroy the object.
It is essential and it is necessary to call it at the end.


    pdf01.SetFont "helvetica"


It changes the font.

Possible values helvetic, courier, times.


Instead using any of these three embedded fonts, it can be specified as parameter the path of a font-type file, a file extension, .ttf or .otf.
If only the file name is specified, it will search it at the folder of the project.

If it does not exist, it must be created.


    pdf01.SetFontSize 10


Setting the font size.


    pdf01.SetFontStyle "bold"


Font style options.

Possible values
italic
bold
underline
strike
bolditalic
boldunderline
bolditalicunderline
italicunderline



    pdf01.SetFontColor "#0000AA"


Color of the font in HTML notation.


    pdf01.AddText "Consejería de Sanidad y Asuntos Sociales"


It adds a text without a line break.


    pdf01.AddTextLine "Consejería de Sanidad y Asuntos Sociales"


It adds a text with line break to the document.


    pdf01.AddImage "logoxone.png", 50, 50


It adds an image to the document of the files folder, a full path can be specified for testing.

First parameter Path.
Second parameter Optional. It resizes the image width.
Tercer parámetro Optional. It resizes the image height.



    pdf01.AddHyperlink "Google", "http://www.google.com"


It adds a link to the document.


    pdf01.AddTextSetX "Consejería de Sanidad y Asuntos Sociales", 125

It adds text at the absolute position according the X axis and the current position at the Y axis.


First parameter Text to add.
Second parameter Position at the X axis.



    pdf01.AddCheckboxSetX "Se realiza toma de muestra", 230, 145, 20, "check", "true", "true"


It adds a checkbox type control to the document.

Firs parameter Annexed text.
Second parameter Position at the X axis.
Third parameter Checkbox type. Possible values: “star”, “square”, “circle”, “cross”, “diamond”, “check”.
Fourth parameter Optional.Checkbox value. Possible values: “true”, “false”.
Fifth parameter Optional. Read-only Checkbox . Possible values: “true”, “false”. Some PDF readers could not respect it, for locking completely combine with setencryption



    pdf01.AddImageSetX "logoxone.png", 125, 50, 50

It adds an image to the document of the file folders, at the position specifiedat the X axis.


First parameter Path.
Second parameter Position at the X axis.
Third parameter Optional. It resizes the image width.
Fourth parameter Optional. It resizes the image height.



    pdf01.AddTextFieldSetX "campo02", 250, 50, 100


It adds an editable text field.
The document must not be locked.

First parameter Internal name to be able to reference to the field later.
Second parameter Text field width.
Third parameter Text field height.
Fourth parameter Position at the X axis.



    pdf01.NewLine


It adds a new line.
An integer can be passed as parameter and it will make that breaks.


    pdf01.NewPage

It jumps to the PDF next page



    nYPos = pdf01.GetVerticalPosition


It gets the current position of the cursor at the Y axis.

This method was oficially entered in the 1.3.1.0. version of the xonepdf module.


    pdf01.AddTextSetXY "Consejería de Sanidad y Asuntos Sociales", 125, 750


It adds a text in the absolute position according the X and Y axis.


First parameter Text to add.
Second parameter Position at the X axis.
Third parameter Position at the Y axis.



    pdf01.AddSquare 100, 700, 20, 1


It draws an square in the document.


First parameter Position at the X axis of the lower left angle.
Second parameter Position at the axis and from lower left angle.
Third parameter Square size.
Fourth parameter Line width of the square.
Fifth parameter Optional. Color of the square background.
Sixth parameter Optional. Color of the square line.



    pdf01.AddRectangle 100, 700, 150, 100, 1

It draws a rectangle in the document.


First parameter Position at the X axis of the lower left angle.
Second parameter Position at the Y axis of the lower left angle.
Third parameter Rectangle width.
Fourth parameter Rectangle height.
Fifth parameter Line width of the rectangle.
Sixth parameter Optional. Background color of the rectangle.
Seventh parameter Optional. Color of the rectangle line.



    pdf01.AddImageSetXY "logoxone.png", 0, 750, 50, 50


It adds an image to the document of the files folder, at the specified position.

First parameter Path.
Second parameter Position at the X axis.
Third parameter Position at the Y axis.
Fourth parameter Optional. It resizes the image width.
Fifth parameter Optional. It resizes the image height.



    pdf01.AddCheckboxSetXY "Se realiza toma de muestra", 230, 145, 20, "check", "true", "true"


It adds a checkbox type control to the document.


Firsth parameter Annexed text.
Second parameter Position at the X axis.
Third parameter Position at the Y axis.
Fourth parameter Checkbox type. Possible values: “star”, “square”, “circle”, “cross”, “diamond”, “check”.
Fifth parameter Optional. Checkbox value. Possible values: “true”, “false”.
Sixth parameter Optional. Read-only checkbox. Possible values: “true”, “false”. Some PDF readers could not respect it, to totally block, match with setencryption.



    pdf01.AddBarcode "(00)350123451234567894", "ean128", 100, 100, 100, 200


It adds a bar code to the document.

The first 4 parameters are mandatory, the last two are optionals.

First parameter Datum to generate the code. It must be passed with the proper format for each bar code.
Second parameter Bar code type. Supported bar codes: codabar, code11, code128, code25, code39, code93, datamatrix, ean128, ean13, ean8, isbn, issn, itf14, identcode, interleaved2of5, leitcode, msi, onecode, pdf417, planet, postnet, rm4scc, upca, upce.
Third parameter Bar code width.
Fourth parameter Bar code height.
Fifth parameter Optional. Position at the X axis.
Sixth parameter Optional. Position at the Y axis.




    pdf01.AddBarcode "BIZCARD:N:Pepito;X:Grillo;T:Programador informático;C:CGSoft;A:Dirección;B:+34600404040;F:+34924202020;M:+34902202020;E:pepe@xone.es;;", "qrcode", 300, 300


It adds a QR code to the document.

It must follow the format passed at the example, besides that, same than the previous method.


    pdf01.AddTextFieldSetXY "campo01", 250, 50, 100, 700


It adds an editable field text at the XY axis.

The document must not be locked.

First parameter Internal name to be able to reference the field later.
Second parameter Text field width.
Third parameter Text field height.
Fourth parameter Position at the X axis.
Fifth parameter Position at the Y axis.




    pdf01.CreateTable 5


It starts a simple table.

First parameter Number of columns of a row.



    pdf01.SetTableCellWidths 50, 100, 150


It sets the columns width.

It must be invoked with as many parameters as columns have been defined in the table.

This method was entered at the 1.3.1.0 vesion of the xonepdf module.


pdf01.SetAlignment "center"
pdf01.SetAlignment "left"
pdf01.SetAlignment "right"
pdf01.SetAlignment "none"


It specifies the text alignment in the subsequents cells.

Setting to “none” to come back to the regular alignment.


pdf01.SetTableWidth 300


With this, we set the total width of the table.

The height is determined by the number of added rows.


    pdf01.SetCellBorder "top"


By invoking this method, the next cells added to the open table will have the specified border.

These calls can be summed to have corners, for instance.

By default, the cells have all the borders.

Possible values:
setcellborder “none”. It removes all the borders.
setcellborder“topIt adds the top border.
setcellborder “bottomIt adds the bottom border.
setcellborder “rightIt adds the right border.
setcellborder “leftIt adds the left border.
setcellborder “all It adds all the borders.



    pdf01.AddCellText "Transportistas S.A.","#000000"


It adds a cell with text to the table.

They will be added according the order of appearance in the script.

First parameter Text to enter.
Second parameter Optional. Background color of the cell.



    pdf01.AddCellHyperlink "Google", "http://www.google.com"


It adds a link to the cell of the table.

First parameter Link text.
Second parameter Link URL.



    pdf01.AddCellImage "/mnt/sdcard/xone/logoxone.gif"


It adds an image to the table.

They will be added according the order of appearance in the script.

First parameter Path of the image. If only the name is specified, it will seach in the files folder of the application.
Second parameter Optional. For resizing. Image width in pixels.
Third parameter Optional. For resizing. Image height in pixels.



    pdf01.AddTable


It ends the table and adds it to the document.

It is essential to call to this function or to its siter function addtablesetxy.


    pdf01.AddTableSetXY 50, 600


It ends the table and adds it to the document in the position specified at the X and Y axis passed by parameter.

It is essential to call to this function or to its siter function addtable.

Before drawing directly a table in the document, it is necessary to specify its width with settablewidth.



	pdf01.BeginHeader


The following drawing calls of the PDF will constitute the heading of the document, until calling to endheader.


	pdf01.EndHeader


It ends the heading block.


	pdf01.BeginFooter


The following drawing calls of the PDF will constitute the footer of the document, until calling to endfooter.


	pdf01.EndFooter


It ends the block of the footer.


It is necessary to define the heading before calling to pdf01.Open, since in that moment the document is opened.

	pdf01.BeginHeader
	pdf01.AddImageSetXY "logoempresa.png", 0, 750, 100, 50
	pdf01.SetFont "helvetica"
	pdf01.SetFontSize 10
	pdf01.SetFontStyle "bold"
	pdf01.SetFontColor "#0000AA"
	pdf01.AddTextLine chr(10) + chr(10) + chr(10) + "                            Sociedad Limitada"
	pdf01.EndHeader
 
	pdf01.BeginFooter
	pdf01.CreateTable 1
	pdf01.SetTableWidth 300
	pdf01.SetCellBorder "all"
	pdf01.SetAlignment "center"
	pdf01.AddCellText "Pie de página, línea 1"
	pdf01.AddCellText "Pie de página, línea 2"
	pdf01.AddTableSetXY 0, 600
	pdf01.EndFooter
 
	pdf01.Open




    pdf01.LaunchPDF "/mnt/sdcard/xone/testpdf01.pdf"


This method sends Android the order to open the PDF specified in the PDF reader installed in the system. It is worth any PDF file.
It is enough to install the “Adobe Reader” from the Play Store.
For instance, it is possible to generate the PDF, ask for the user to fill it up by this method and send it to print.

It is not possible to launch PDFs generated with XOne that have not been ended with the Close method.
If the full path is not specified, it will be search at the files folder.

This method launch an exception if it does not find the document, by cancelling the script.


    nPagina = pdf01.GetCurrentPage


This method returns the page in which the cursor is at the momento to call it.

It may be helpful for the footer.

This method was entered at the 1.3.1.0 version of the xonepdf module.


    pdf01.AddAttachment "/mnt/sdcard/xone/archivoadjunto.txt"


It attachs a file to the pdf.

It may be of all kinds, even a URL.


    pdf01.Delete "/mnt/sdcard/xone/testpdf01.pdf"


It deletes the file.


    pdf01.SetPDFVersion "1.7"


It sets the version of the format of the PDF we want to generate.
By default, it is set to “1.7”.
Lower values to this one, could be not support the rest of methods.

Possible values
“1.2”
“1.3”
“1.4”
“1.5”
“1.6”
“1.7”


It must be invoked before the Open().


    pdf01.SetCompression "false"


It defines if we want to compress the document.

By default, it is equal to true.


This methods modify the properties of the document, such as the author and the creation date.

    pdf01.AddTitle "Título del documento"
    pdf01.AddAuthor "John Doe"
    pdf01.AddCreationDate "10/10/2010"
    pdf01.AddCreator "John Doe"
    pdf01.AddKeywords "palabra clave"
    pdf01.AddSubject "Asunto"


PDF protection and permissions



    pdf01.Permissions "degradedprint"
    pdf01.Permissions "modifyannotations"
    pdf01.Permissions "screenreaders"
    pdf01.Permissions "assembly"
    pdf01.Permissions "print"
    pdf01.Permissions "copy"
    pdf01.Permissions "modifycontents"
    pdf01.Permissions "fillin"


It sets the permissions that the document will have.

It must be invoked in this order if we want the permissions have an effect:

Create() → Permissions() → setencryption().

Several calls can be added to sum permissions.

With “clear”, the current permissions selection is restarted, but this method has no effect if it is called after setencryption().


    pdf01.SetEncryption "passwordusuario", "passwordpropietario", "128bits"


It defines the document encryption.

It is necessary to call it if we want the permissions have an effect.
The passwords can be left to null.

They must be call it after Create(), after Permissions() and before Open().

First parameter Reading password.
Second parameter Owner password. The owner will have all the permissions upon the document.
Third parameter Size of the encryption block. Possible values: “40bits”, “128bits”



    pdf01.EncryptPDF "/mnt/sdcard/desencriptado.pdf", "encriptado.pdf", "passwordusuario", "passwordpropietario", "128bits"


It encrypts a PDF.

First paramter Source path.
Second parameter Destination path.
Third parameter User password.
Fourth parameter Owner password.
Fifth parameter Block Bits of the encrypting. Possible values:“40bits”, “128bits” .



    pdf01.DecryptPDF "encriptado.pdf", "/mnt/sdcard/desencriptado.pdf", "passwordpropietario"


It decrypts a file.

First parameter Source path.
Second parameter Destination path.
Third parameter Owner password.



    pdf01.EncryptWithCertificate "testpdf.pdf", "testpdfencriptado.pdf", "certificado.cer"


It encrypts a document by using a certificate.



    pdf01.SignPDFWithKey "testpdf.pdf", "testpdffirmado.pdf", "keystore.pfx", "1234", "Nombre de la clave", "Contraseña de la clave"


It signs digitally a document.


When we are creating our PDF, we can use the following fuction for helping us to position the different elements in the coordinate axis that our file is, so that it is much easier its layout.

function showGridDebug(pdf)
 
	'Tabla para saber las posiciones X e Y de un PDF
 
	'Para el EJE X
	pdf.SetAlignment "center"	
	pdf.SetFontSize 9
	pdf.SetFontStyle "bold"
	pdf.SetFontColor "#0000CC"
	for i=2 to 26
		i=cint(i*20)
		'Esta es la primera fila del Eje X, Arriba, Y=840
		pdf.CreateTable 1
		pdf.SetTableWidth 20
		pdf.AddCellText i
		pdf.AddTableSetXY i,840
		'pdf.AddRectangle PosX, PosY, Ancho, Alto, Grosor, ColorFondo, ColorLinea
		pdf.AddRectangle i, 20, 0, 820, 0, "#FF0000", "#FF0000"
 
		'Esta es la segunda fila del Eje X, Abajo, Y=20
		pdf.CreateTable 1
		pdf.SetTableWidth 20
		pdf.AddCellText i
		pdf.AddTableSetXY i,20	
	next
 
	'Para el EJE Y
	pdf.SetFontColor "#009900"
	for i=0 to 42
		i=cint(i*20)
 
		'Esta es la primera columna del Eje Y, en la izquierda X=10
		pdf.CreateTable 1
		'pdf.AddCellText "10,"+i
		pdf.SetTableWidth 30
		pdf.AddCellText i
		pdf.AddTableSetXY 10,i
		'pdf.AddRectangle PosX, PosY, Ancho, Alto, Grosor, ColorFondo, ColorLinea
		pdf.AddRectangle 10, i, 540, 0, 0, "#FF0000", "#FF0000"
 
		'Esta es la segunda columna del Eje Y, en la derecha X=540
		pdf.CreateTable 1
		pdf.SetTableWidth 30
		'pdf.AddCellText "540,"+i
		pdf.AddCellText i
		pdf.AddTableSetXY 540,i	
	next
	pdf.SetFontStyle "normal"
	pdf.SetFontColor "#000000"
 
end function



Example of use


Downloading the full example with xonepdf v1.1.7 and resulting PDF: http://www.xoneisp.com/jc/TestPDFs.rar

	Set pdf01 = CreateObject("XOnePDF")
	'pdf01.AddPermission "degradedprint"
	'pdf01.AddPermission "modifyannotations"
	'pdf01.AddPermission "screenreaders"
	'pdf01.AddPermission "assembly"
	pdf01.Permissions "print"
	'pdf01.AddPermission "copy"
	'pdf01.AddPermission "modifycontents"
	'pdf01.AddPermission "fillin"
 
	pdf01.Create "/mnt/sdcard/xone/testpdf01.pdf"
	pdf01.SetEncryption "", "1234", "128bits"
	pdf01.Open
 
	pdf01.AddImageSetXY "logo.png", 0, 750, 75, 50
 
	pdf01.SetFont "helvetica"
	'pdf01.SetFont "ssf4.ttf"
	'pdf01.SetFont "courier"
	'pdf01.SetFont "times"
 
	pdf01.CreateTable 3
	pdf01.AddCellImage "logo.png", 25, 25
	pdf01.AddCellText "test"
	pdf01.AddCellText "1234"
	pdf01.AddTable
 
	pdf01.SetFontSize 10
	pdf01.SetFontStyle "normal"
	pdf01.SetFontColor "#0000AA"
	pdf01.AddTextSetXY "Consejería de Sanidad", 125, 750
	pdf01.AddText chr(10) + chr(10) + chr(10) + chr(10)
	pdf01.SetFontColor "#000000"
	pdf01.SetFontStyle "normal"
	pdf01.NewLine
	pdf01.AddText "CLAVE/CÓDIGO: "
	pdf01.SetFontStyle "bold"
	pdf01.AddText "Establecimiento"
	pdf01.SetFontStyle "normal"
	pdf01.NewLine
	pdf01.AddText "ACTIVIDAD: "
	pdf01.SetFontStyle "bold"
	pdf01.AddText "003 (RESTAURANTES DE 101 A 200 COMENSALES)"
	pdf01.SetFontStyle "normal"
	pdf01.NewLine
	pdf01.AddText "NOMBRE O RAZÓN SOCIAL: "
	pdf01.SetFontStyle "bold"
	pdf01.AddText "EL COMILÓN S.L."
	pdf01.SetFontStyle "normal"
	pdf01.NewLine
	pdf01.AddText "DOMICILIO: "
	pdf01.SetFontStyle "bold"
	pdf01.AddText "CALLE 123, Nº 23."
	pdf01.SetFontStyle "normal"
	pdf01.AddTextSetXY "Nº RGSEAA/INEA ", 400, 685
	pdf01.SetFontStyle "bold"
	pdf01.AddTextSetXY "222.111/33", 485, 685
	pdf01.SetFontStyle "normal"
	pdf01.NewLine
	pdf01.AddText "LOCALIDAD: "
	pdf01.SetFontStyle "bold"
	pdf01.AddText "BADAJOZ"
	pdf01.SetFontStyle "normal"
	pdf01.AddTextSetXY "PROVINCIA:", 400, 670
	pdf01.SetFontStyle "bold"
	pdf01.AddTextSetXY "BADAJOZ", 485, 670
	pdf01.NewLine 2
	pdf01.AddTextLine "* En inspección oficial realizada en el establecimiento en el día de la fecha, se efectúan los controles oficiales que se detallan y se ponen de manifiesto las siguientes incidencias:"
	pdf01.NewLine 2
	pdf01.SetFontSize 9
 
	pdf01.SetFontStyle "underline"
	pdf01.AddTextLine "CONTROL DE INSTALACIONES Y MANTENIMIENTO DE INSTALACIONES"
	pdf01.SetFontStyle "normal"
	pdf01.AddTextLine "En la inspección realizada en el establecimiento con fecha 8 de febrero de 2012 se constató que la campana extractora de la cocina no disponía de salida exterior de humos. Se comprueba que se ha dotado la campana extractora de salida de humos protegida en adecuadas condiciones..." 
 
	pdf01.NewLine
	pdf01.SetFontStyle "underline"
	pdf01.AddTextLine("CONTROL DE HIGIENE DE INSTALACIONES Y PROGRAMA DE LIMPIEZA:")
	pdf01.SetFontStyle "normal"
	pdf01.AddTextLine "Se revisan las condiciones higiénicas de las instalaciones. En la cocina se observan restos de suciedad acumulada en lugares de difícil acceso a la limpieza: esquinas, rincones, alrededores de las patas del mobiliario de la cocina e interruptores. En el establecimiento disponen de un Plan de Limpieza y Desinfección en el que se detallan las tareas a realizar, las frecuencias y los responsables de ejecutarlas. Se revisan los registros de verificación y se observa que se cumplimentan tal como está establecido en el Plan de Limpieza y Desinfección."
	pdf01.NewLine
 
	pdf01.SetFontStyle "underline"
	pdf01.AddTextLine "CONTROL DE TEMPERATURAS:"
	pdf01.SetFontStyle "normal"
	pdf01.AddTextLine "Se controla la temperatura de las cámaras (cámara de producto refrigerado, cámara de congelación y vitrina expositora). Todas cuentan con termómetro indicador de la temperatura de funcionamiento y no se observan restos de escarchamiento o de goteos desde los motores. Las cámaras de producto refrigerado y la de congelación funcionan a temperatura adecuada, de +4ºC y -19ºC, respectivamente. Se controla la temperatura de la vitrina expositora con un termómetro sonda del propio establecimiento, que indica una temperatura del producto de + 12ºC. El representante del establecimiento decide retirar las tapas expuestas en la vitrina y proceder a su destrucción."
 
	'pdf01.SetFont "ssf4.ttf"
	'pdf01.SetFontColor "#33AA88"
	'pdf01.CreateTable 2
	'pdf01.AddCellText "aaaa"
	'pdf01.AddCellHyperlink "aaaaa", "bbbbbb"
	'pdf01.AddTable
 
	pdf01.AddCheckboxSetX "Se levanta acta de inspección     nº de acta......", 230, 20, "check"
	pdf01.AddCheckboxSetX "Se realiza toma de muestra        nº de acta......", 230, 20, "check"
	pdf01.AddBarcode "1030000010000814919999", "interleaved2of5", 200, 50, 50, 60
 
	pdf01.Close
 
	'pdf01.DecryptPDF "/mnt/sdcard/xone/testpdf01.pdf", "/mnt/sdcard/xone/testpdf01decrypt.pdf", "1234"
	pdf01.LaunchPDF "/mnt/sdcard/xone/testpdf01.pdf"
	Set pdf01 = nothing