Welcome Guest Search | Active Topics | Sign In | Register

Link to specific page within PDF Options
Exameron
Posted: Tuesday, December 18, 2018 8:56:34 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
I'm using a combination of html to PDF and AcmContent in On_BeforeRenderPage to create repeating footer content.

I'd like to include a link in the footer that target's the 2nd page in the pdf. Ive been able to create an AcmLink to targetContent within a specific page, but I don't see how to link from every page to a single page.

Ideally, I could target the page index.

Any ideas would be great, thanks!
eo_support
Posted: Wednesday, December 19, 2018 8:49:18 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

You will just have to use a empty dummy target content that is placed at the beginning of the page for this purpose. In practice, it will be much easier for you to achieve this with the HTML to PDF converter with a link element. You will basically do the conversion twice with something like this:

Code: C#
PdfDocument doc = new PdfDocument();

//Convert the main content
HtmlToPdf.ConvertUrl(main_content_url, doc);

//Convert the page header/footer into the same document
HtmlToPdf.Options.StartPageIndex = 0;
HtmlToPdf.Options.OutputArea = new RectangleF(....);  //modify this line to define header/footer position
string headerFooterHtml = GenerateHeaderFooterHtml(doc.Pages.Count);
HtmlToPdf.ConvertHtml(headerFooterHtml, doc);


Here GenerateHeaderFooterHtml is a function that you will write to generate a single HTML string that contains all header/footers. A single page's header/footer can be something like this:

Code: HTML/ASPX
<div style="page-break-after:always;">
  <p>
    header
  </p>
  <div style="height:800px;">
  </div>
  <p>
    footer
  </p>
</div>


Here the outter DIV is to make sure that each block starts a new page. The inner DIV between the two Ps is to push the footer to the bottom of the page (obviously you will need to adjust the height of this DIV to achieve your desired result). And your function will generates a repeat of the above block of doc.Pages.Count times combined together as a single string.

Once you get that work, you can add <a> element into your HTML and then you will be able to link between your header/footer however you want.

Hope this help.

Thanks!
Exameron
Posted: Wednesday, December 19, 2018 12:12:12 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
Thanks for your reply, I'm not sure I've explained the challenge clearly enough. I need to be able to create a link using the Acm method in the footer of each page, and link to page #2 (of about 50 pages) in the pdf.

As far as I know, you can't link from Acm content to content that's converted from html?

I can create target text on the correct page, but the footer link only works on that page (not on all the other footers).

Hopefully that makes sense.

Ideas?
eo_support
Posted: Wednesday, December 19, 2018 12:36:40 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
What I was trying to tell you is DO NOT use Acm interface to create the link. It's much easier to use the HTML to PDF interface to create the links.
Exameron
Posted: Wednesday, December 19, 2018 12:45:02 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
The output is already developed and fairly complex. I'm not sure how straight forward it would be now to use a different method for creating page footers.
eo_support
Posted: Wednesday, December 19, 2018 12:51:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
You will have to change your code anyway. What I am trying to tell you is it's easier to change to HTML to PDF interface than keep using the ACM interface for your case. If you must keep using ACM interface, then you will have to move your code out of your On_BeforeRenderPage and add all the header/footer after the conversion in a way very similar to the approach we explained to you. The difference is instead of constructing a single HTML string to produce all the headers/footers, you will have to construct a complex AcmContent tree to do that. Such change is necessary for you because you will only see a single page inside On_BeforeRenderPage and you need to link to a different page.
Exameron
Posted: Wednesday, December 19, 2018 12:57:07 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
got it, thanks. You've given me a good place to start looking.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.