• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Advanced PDF actions in Delphi

Sascha Оффлайн

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,486
Баллы
155
TMS Software Delphi  Components



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

has a lot of powerful components, both visual and non-visual. One of them is the TAdvPDFLib component. TAdvPDFLib is capable of generating PDF files in a Delphi VCL application. This blog covers more in depth code snippets to add navigation to your PDF document. To get started with TAdvPDFLib, read through

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

post first.





Go-To a specific page



A go-to action changes the view to a specified destination (page, location, and magnification factor). With TAdvPDFLib we can add actions with the following code. The code will add a clickable link that can be used to navigate to a different page, and make sure the page is completely visible in the reader.


uses
AdvGraphicsTypes, Types;

procedure TForm1.GeneratePDF;
begin
AdvPDFLib1.BeginDocument('MyPDF.pdf');
try
AdvPDFLib1.NewPage;

AdvPDFLib1.Graphics.AddGoTo('Link', '1 /Fit', RectF(50, 50, 150, 150));

AdvPDFLib1.NewPage;

AdvPDFLib1.Graphics.Fill.Color := gcYellowgreen;
AdvPDFLib1.Graphics.Stroke.Color := gcGreen;
AdvPDFLib1.Graphics.Stroke.Width := 4;
AdvPDFLib1.Graphics.DrawRectangle(RectF(100, 100, 300, 300));

finally
AdvPDFLib1.EndDocument(True);
end;
end;



TMS Software Delphi  Components





Go-To a specific rectangle



Let's say you have a part of the PDF that is requiring attention. It's possible to navigate to a specific rectangle in your page. To do this, use the following code.


var
l, r, t, b: Integer;
begin
AdvPDFLib1.BeginDocument('MyPDF.pdf');
try
AdvPDFLib1.NewPage;

l := 100;
t := 100;
r := 300;
b := 300;

AdvPDFLib1.Graphics.AddGoTo('Link', 1, '/FitR ' + l.ToString + ' ' + (AdvPDFLib1.PageHeight - t).ToString + ' ' +
r.ToString + ' ' + (AdvPDFLib1.PageHeight - b).ToString, RectF(50, 50, 150, 150));

AdvPDFLib1.NewPage;

AdvPDFLib1.Graphics.Fill.Color := gcYellowgreen;
AdvPDFLib1.Graphics.Stroke.Color := gcGreen;
AdvPDFLib1.Graphics.Stroke.Width := 4;
AdvPDFLib1.Graphics.DrawRectangle(RectF(l, t, r, b));

finally
AdvPDFLib1.EndDocument(True);
end;
end;
Please note that the `AddGoTo` parameter list includes an overload that allows you to specify a page index as an integer and an options parameter as a string. Since PDF output uses a different coordinate system, we need to perform some calculations before passing the rectangle to the options parameter.

Go-To an URL


Go-To actions not only navigate within the document, it's also possible to include URLs in the PDF document. To do so, use the following code


AdvPDFLib1.BeginDocument('MyPDF.pdf');
try
AdvPDFLib1.NewPage;
AdvPDFLib1.Graphics.AddURL('Link', '

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

', RectF(50, 50, 150, 150));
finally
AdvPDFLib1.EndDocument(True);
end;



Conclusion


TAdvPDFLib provides powerful functionality for working with PDFs in Delphi VCL applications. With features like the ability to add navigation actions such as go-to links, specific rectangles, and URLs, you can create interactive PDF documents. More info about actions and the possible optional parameters can be found here:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу