PDF Template Editor

  • This component is not suitable for users that require assistive technologies. This component is not suitable for users who require assistive technologies.
  • This component is not suitable for use on mobile devies. This component is not suitable for use on mobile devices.

Used to create templates to be used by PDF Document: Static PDF mode. This component lets users place predefined placeholders (text or images) on a pdf document template.

Appearance

Screenshot of PDF Template Editor

SQL

SQL Call: Init (mandatory)

May modify database: No

Parameters

@Action string
Will be set to "Init".

Resultset: PDF document

Table count: repeated exactly once
Row count: exactly one row
Columns
PDF mandatory binary

Binary data of the pdf document.

Resultset: Fonts (optional)

The fonts to use for the text placeholders.

Table count: repeated zero or one time
Row count: zero or more rows
Columns
FontData mandatory binary

Binary true type data of the font. See SoftadminApi.PdfFont for easier managing of the fonts.

FontId mandatory string

The id of the font.

FriendlyName mandatory string

The font name displayed to the user.

Resultset: Groups (optional)

Optional groups to separate the available placeholders into

Table count: repeated zero or one time
Row count: zero or more rows
Columns
GroupId mandatory string

The id of the group.

GroupName mandatory string

The displayed name of the group.

Resultset: Available text placeholders (optional)

The list of text placeholders that the user may place on the document.

Table count: repeated zero or one time
Row count: zero or more rows
Columns
Description optional string

Extra information about the placeholder.

ExampleText optional string

Example text to display on the document when the user has placed the placeholder.

Default: The title will be used as example text.
FontId mandatory string

Id of the font to use.

FontSize mandatory decimal

The default font size.

GroupId optional string

Id of the group that the text belongs to. Must be set when using groups.

TextId mandatory string

The id of the text.

TextWidth optional decimal

Maximum width of the text before it inserts line breaks.

Default: The user may not change the text's width.
Title mandatory string

Descriptive title for the placeholder.

Resultset: Available image placeholders (optional)

The list of text placeholders that the user may place on the document.

Table count: repeated zero or one time
Row count: zero or more rows
Columns
CanResize optional bit

Whether or not the user may resize the image placeholder.

Default: true
Description optional string
Extra information about the placeholder.
GroupId optional string

Id of the group that the image belongs to. Must be set when using groups.

Height mandatory decimal

The height of the image.

ImageContentType optional string

The content type of the example image. Must be used when ImageData is set.

ImageData optional binary

The binary data of the example image.

Default: A default image will be used.
ImageId mandatory string

The id of the image.

Title mandatory string

Descriptive title for the placeholder.

Width mandatory decimal

The width of the image.

SQL Call: Get placeholders (mandatory)

Retrieves the existing placeholders that has already been placed on the document.

May modify database: No

Parameters

@Action string
Will be set to "GetPlaceholders".

Resultset: Text placeholders

Table count: repeated exactly once
Row count: zero or more rows
Columns
FontId mandatory string

Id of the font used.

FontSize optional decimal

The font size used.

Default: The font size of the available placeholder will be used.
PageNumber mandatory int

The page that the placeholder is placed on.

PlaceholderId mandatory string

Id of the placeholder.

TextId mandatory string

Id of the available placeholder that it is based on.

TextWidth optional decimal

Maximum width of the text before it inserts line breaks.

Default: The user may not change the text's width.
X mandatory decimal

X coordinate of the placeholder.

Y mandatory decimal

Y coordinate of the placeholder.

Resultset: Image placeholders

Table count: repeated exactly once
Row count: zero or more rows
Columns
Height mandatory decimal

The height of the image.

ImageId mandatory string

Id of the available placeholder that it is based on.

PageNumber mandatory int
The page that the placeholder is placed on.
PlaceholderId mandatory string
Id of the placeholder.
Width mandatory decimal

The width of the image.

X mandatory decimal
X coordinate of the placeholder.
Y mandatory decimal
Y coordinate of the placeholder.

SQL Call: Insert text placeholder

Called when the user places an available text placeholder on the document. This call will receive the following temporary table with one row.

CREATE TABLE #TextPlaceholder
(
	PlaceholderId nvarchar(max) NULL, -- Will be set to NULL.
	TextId nvarchar(max) NOT NULL,
	PageNumber int NOT NULL,
	X decimal(38, 1) NOT NULL,
	Y decimal(38, 1) NOT NULL,
	FontId nvarchar(max) NOT NULL,
	FontSize decimal(38, 1) NOT NULL,
	TextWidth decimal(38, 1) NULL
)
May modify database: Yes

Parameters

@Action string
Will be set to "InsertTextPlaceholder".

Resultset: Placeholder id

Table count: repeated exactly once
Row count: exactly one row
Columns
PlaceholderId mandatory string

The id given to the placeholder.

SQL Call: Insert image placeholder

Called when the user places an available image placeholder on the document. This call will receive the following temporary table with one row.

CREATE TABLE #ImagePlaceholder
(
	PlaceholderId nvarchar(max) NULL, -- Will be set to NULL.
	ImageId nvarchar(max) NOT NULL,
	PageNumber int NOT NULL,
	X decimal(38, 1) NOT NULL,
	Y decimal(38, 1) NOT NULL,
	Width decimal(38, 1) NOT NULL,
	Height decimal(38, 1) NOT NULL
)
May modify database: Yes

Parameters

@Action string
Will be set to "InsertImagePlaceholder".

Resultset: Placeholder id

Table count: repeated exactly once
Row count: exactly one row
Columns
PlaceholderId mandatory string
The id given to the placeholder.

SQL Call: Update placeholders (mandatory)

Called when the user changes existing placeholders on the document. This call will receive the following temporary tables with zero to many rows.

CREATE TABLE #TextPlaceholder
(
	PlaceholderId nvarchar(max) NOT NULL,
	TextId nvarchar(max) NOT NULL,
	PageNumber int NOT NULL,
	X decimal(38, 1) NOT NULL,
	Y decimal(38, 1) NOT NULL,
	FontId nvarchar(max) NOT NULL,
	FontSize decimal(38, 1) NOT NULL,
	TextWidth decimal(38, 1) NULL
)

CREATE TABLE #ImagePlaceholder
(
	PlaceholderId nvarchar(max) NOT NULL,
	ImageId nvarchar(max) NOT NULL,
	PageNumber int NOT NULL,
	X decimal(38, 1) NOT NULL,
	Y decimal(38, 1) NOT NULL,
	Width decimal(38, 1) NOT NULL,
	Height decimal(38, 1) NOT NULL
)
May modify database: Yes

Parameters

@Action string
Will be set to "UpdatePlaceholders".

SQL Call: Delete placeholders (mandatory)

Called when the user deletes existing placeholders on the document. This call will receive the following temporary tables with zero to many rows.

CREATE TABLE #DeletedTextPlaceholder
(
	PlaceholderId nvarchar(max) NOT NULL
)

CREATE TABLE #DeletedImagePlaceholder
(
	PlaceholderId nvarchar(max) NOT NULL
)
May modify database: Yes

Parameters

@Action string
Will be set to "DeletePlaceholders".

SQL Call: Validate parameters

Allows you to validate the parameters supplied by the user before any other SQL is run in the component. This call is only made if the component has visible parameters, the SQL is a stored procedure, and Validate parameters is checked.

May modify database: No

Parameters

@Force bit
Set to 1 if the last call to validate parameters used admin_force and the user clicked OK in the OK/Cancel dialog.
@ValidateParams bit
Set to 1 when this call is made.

Resultset: Messages (optional)

Table count: repeated zero or one time
Row count: zero or one row
Columns
ADMIN_Force optional string
Message asking the end user to confirm their parameters.
ADMIN_Message optional string
Message explaining why the parameters are rejected.

Custom access control and logging

SQL Call: Custom access control and logging

Use this call to restrict which entries a user is allowed to view and edit, and to log which entries a user views.

Access to a menu item is normally controlled through functions and roles alone but some entities need more fine grained control. For example, a user may have access to the View Member menu item for normal members but not for members with a protected identity.

The menu items a user visits are always logged (in ADMINLogMenuItem) but for sensitive data you may need to log exactly what entries are viewed. Do the logging in this call as the common ways of viewing data (grid and InfoSQL) are not allowed to modify the database.

If you bind a scalar function instead of a stored procedure to this call then its name must end with '_GrantAccess'.

May modify database: Yes

Resultset: Access permissions

Return whether the user is allowed to visit the menu item with the current parameters.
Table count: repeated exactly once
Row count: exactly one row
Columns
GrantAccess mandatory bit
1 if the user is allowed to view the menu item, 0 if the user should not be allowed to view the menu item.

If 0 then an error will be logged as the user should not have been able to reach the menu item with the given parameters in the first place.

Examples

Example

ALTER PROCEDURE Example.PdfTemplateEditor
	@Action VARCHAR(50) = NULL,
	@PDFTemplateId int
AS
BEGIN
	SET NOCOUNT, XACT_ABORT ON;

	IF @Action = 'Init'
	BEGIN
		SELECT
			PDF
		FROM
			Example.PDFTemplate
		WHERE
			PDFTemplateId = @PDFTemplateId;

		SELECT
			F.FontId,
			F.FontData AS Font,
			F.FontName AS FriendlyName
		FROM
			SoftadminApi.Font F
		WHERE
			F.FontId = '<guid>';

		SELECT
			TextId,
			FontId,
			FontSize,
			Title,
			ExampleText,
			TextWidth,
			Description
		FROM
			Example.PDFTemplateAvailableTextPlaceholder
		WHERE
			PDFTemplateId = @PDFTemplateId;

		SELECT
			ImageId,
			Width,
			Height,
			Title,
			ImageData,
			ImageContentType,
			CanResize,
			GroupId,
			Description
		FROM
			Example.PDFTemplateAvailableImagePlaceholder
		WHERE
			PDFTemplateId = @PDFTemplateId;
	END;
	ELSE IF @Action = 'GetPlaceholders'
	BEGIN
		SELECT
			PlaceHolderId,
			TextId,
			PageNumber,
			X,
			Y,
			FontSize,
			TextWidth,
			FontId
		FROM
			Example.PDFTemplateTextPlaceholder
		WHERE
			PDFTemplateId = @PDFTemplateId;

		SELECT
			PlaceHolderId,
			ImageId,
			PageNumber,
			X,
			Y,
			Width,
			Height
		FROM
			Example.PDFTemplateImagePlaceholder
		WHERE
			PDFTemplateId = @PDFTemplateId;
	END;
	ELSE IF @Action = 'UpdatePlaceholders'
	BEGIN
		UPDATE t1
		SET 
			t1.X = t2.X,
			t1.Y = t2.Y,
			t1.FontId = t2.FontId,
			t1.FontSize = t2.FontSize,
			t1.TextWidth = t2.TextWidth
		FROM 
			Example.PDFTemplateTextPlaceholder t1
			JOIN #TextPlaceholder t2
				ON t1.PlaceholderId = t2.PlaceholderId;

		UPDATE t1
		SET 
			t1.X = t2.X,
			t1.Y = t2.Y,
			t1.Width = t2.Width,
			t1.Height = t2.Height
		FROM 
			Example.PDFTemplateImagePlaceholder t1 
			JOIN #ImagePlaceholder t2 
				ON t1.PlaceholderId = t2.PlaceholderId;
	END;
	ELSE IF @Action = 'InsertTextPlaceholder'
	BEGIN
		INSERT INTO Example.PDFTemplateTextPlaceholder
		(
			PDFTemplateId,
			TextId,
			PageNumber,
			X,
			Y,
			FontId,
			FontSize,
			TextWidth
		)
		SELECT 
			@PDFTemplateId,
			TextId,
			PageNumber,
			X,
			Y,
			FontId,
			FontSize,
			TextWidth
		FROM
			#TextPlaceholder;
		SELECT SCOPE_IDENTITY() AS PlaceHolderId;
	END;
	ELSE IF @Action = 'InsertImagePlaceholder'
	BEGIN
		INSERT INTO Example.PDFTemplateImagePlaceholder
		(
			PDFTemplateId,
			PredefinedImageId,
			PageNumber,
			X,
			Y,
			Width,
			Height
		)
		SELECT
			@PDFTemplateId,
			ImageId,
			PageNumber,
			X,
			Y,
			Width,
			Height
		FROM
			#ImagePlaceholder;
		SELECT SCOPE_IDENTITY() AS PlaceHolderId;
	END;
	ELSE IF @Action = 'DeletePlaceholders'
	BEGIN
		DELETE Example.PDFTemplateTextPlaceholder WHERE Id IN (SELECT PlaceholderId FROM #DeletedTextPlaceholder);

		DELETE Example.PDFTemplateImagePlaceholder WHERE Id IN (SELECT PlaceholderId FROM #DeletedImagePlaceholder);
	END;
END;