PDF- PDF.KIT- Hyperlinks and Concatenation

I’m doing this:

1) Create a Table of Contents document. I have code like this that creates hyperlinks:

segment1 = textTOC_Entries.Segments.Add(“SIL - Child : 1. Intake/Admission”)
segment1.TextInfo.IsUnderline = True
segment1.Hyperlink.LinkType = HyperlinkType.Local
segment1.Hyperlink.TargetID = “heading1”

This is one PDF.

2) I then create a second PDF. This PDF has the other side of the hyperlink, such as:

Dim textSectionHeading As Text = New Text(section1, “SIL - Child : 1. Intake/Admission”)
section1.Paragraphs.Add(textSectionHeading)
textSectionHeading.TextInfo.Color = New Aspose.Pdf.Color(“Red”)
textSectionHeading.TextInfo.FontSize = 20
textSectionHeading.TextInfo.Alignment = Aspose.Pdf.AlignmentType.Center
textSectionHeading.ID = "heading1"

3) I then use the PDF.KIT to Concatenate these two document. The Concatenate works OK and I get my final document, but I was expecting the hyperlink to work, but it does not.

Am I missing something? if I create a hyperlink within a single PDF using code like above, it works fine. Does the Concatenate function not respect links created as I’m doing above? If not, how can I create links between what start as separate PDFs but end up being Concatenated?





Hi,

Could you please share the input PDF files, which you’re trying to concatenate? We’ll have to investigate this issue at our end. You’ll be updated with the status accordingly.

We’re sorry for the inconvenience.
Regards,

OK. I have attached the PDFs and the code I am using. Below are three pieces of code.

First, I create a TOC PDF. Please note that in this code I do set the segment1.Hyperlink.TargetID.

Second, I then create the PDFs which are the parts of the final document. These have the ID’s that match the segment1.Hyperlink.TargetID. For the attached files, there are two links - “part1” and “part2”.

Lastly, I merge the 3 PDFs.

I have attached all 4 PDF created in this process.

*************************************************************************************

Private Sub Create_TOC_PDF()

Dim pdf1 As New Pdf
Dim section1 As New Section
Dim section2 As New Section
Dim textTOC_Entries As New Text
Dim segment1 As New Segment

’ Add a new section to the PDF document.
section1.StartingPageNumber = 1
pdf1.Sections.Add(section1)

’ The “Table of Contents” Title
Dim textTOC_Title As Text = New Text(section1, “Table of Contents”)
section1.Paragraphs.Add(textTOC_Title)

textTOC_Title.TextInfo.Color = New Aspose.Pdf.Color(“Red”)
textTOC_Title.TextInfo.FontSize = 20
textTOC_Title.TextInfo.Alignment = Aspose.Pdf.AlignmentType.Center

’ Insert two lines
segment1 = textTOC_Title.Segments.Add(vbCrLf)
segment1 = textTOC_Title.Segments.Add(vbCrLf)

’ Add new text object to the collection of paragraphs
section1.Paragraphs.Add(textTOC_Entries)

segment1 = textTOC_Entries.Segments.Add(“Part 1”)
segment1.TextInfo.IsUnderline = True

segment1.Hyperlink.LinkType = HyperlinkType.Local
segment1.Hyperlink.TargetID = “part1”
segment1 = textTOC_Entries.Segments.Add(vbCrLf)
segment1 = textTOC_Entries.Segments.Add(vbCrLf)

segment1 = textTOC_Entries.Segments.Add(“Part 2”)
segment1.TextInfo.IsUnderline = True
segment1.Hyperlink.LinkType = HyperlinkType.Local
segment1.Hyperlink.TargetID = “part2”
segment1 = textTOC_Entries.Segments.Add(vbCrLf)
segment1 = textTOC_Entries.Segments.Add(vbCrLf)

pdf1.Save(“c:\toc.pdf”)

End Sub


Private Sub Create_Part_PDF(ByVal PartNumber As Integer)

Dim pdf1 As New Pdf
Dim section1 As New Section
Dim segment1 As New Segment

’ Add a new section to the PDF document.
section1.StartingPageNumber = 1
pdf1.Sections.Add(section1)

’ The “Table of Contents” Title
Dim textSectionHeading As Text = New Text(section1, "Document Part " & PartNumber)
section1.Paragraphs.Add(textSectionHeading)

textSectionHeading.TextInfo.Color = New Aspose.Pdf.Color(“Red”)
textSectionHeading.TextInfo.FontSize = 20
textSectionHeading.TextInfo.Alignment = Aspose.Pdf.AlignmentType.Center
textSectionHeading.ID = “part” & PartNumber

pdf1.Save(“c:\part” & PartNumber & “.pdf”)

End Sub



Private Sub Concatenate_PDFS()

Dim PDFS(2) As FileStream

PDFS(0) = New FileStream(“C:\toc.pdf”, FileMode.Open)
PDFS(1) = New FileStream(“C:\part1.pdf”, FileMode.Open)
PDFS(2) = New FileStream(“C:\part2.pdf”, FileMode.Open)

'Create output stream object that would contain the final PDF file
Dim outStream As FileStream = New FileStream(“C:\Final_Doc.pdf”, FileMode.Create)

'Instantiate PdfFileEditor object
Dim pdfEditor As Aspose.Pdf.Kit.PdfFileEditor = New Aspose.Pdf.Kit.PdfFileEditor()

'Call Concatenate method of PdfFileEditor object to concatenate all input streams
pdfEditor.Concatenate(PDFS, outStream)

'Finally close the output stream
outStream.Close()

End Sub

Hi,

Thank you very much for sharing the input PDF files. We’ll investigate this issue in detail and update you with the status accordingly.

We’re sorry for the inconvenience.
Regards,

Hi,

I have reproduced this problem at my end and logged it as PDFKITNET-23543 in our issue tracking system. Our team will investigate it in detail and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Any update on this issue?

Hi,

I’m sorry to inform you that this issue is not yet resolved. However, I have asked our development team to share the ETA of this issue. You’ll be updated as soon as we get a clear idea of the ETA.

We’re sorry for the inconvenience.
Regards,

Hi,

Our team has further investigated this issue in detail and I would like to share with you that the fix for this issue will be available at the end of Q2’2011. You’ll be notified via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Is this problem fixed? if so, in what version?

Hi,

I’m very sorry to share with you that we couldn’t resolve this issue in the mentioned time period. However, I have asked our team for the latest status of this issue and you’ll be updated as soon as the response is received.

We’re sorry for the inconvenience.
Regards,

Hi,


Thanks for your patience and sorry for the delayed response.

We have further investigated the issue reported earlier in this thread and have found that the source files for concatenation do not contain any links. We looked into your code which is used to produce these files. (you can see the posts in forum above).

As per our observations, you have used Section, Segment objects and investigation has revealed that your code is not correct, you have tried to create link to object which does not exists in the same file (in fact, this object which is referenced is placed in other file)

Please note that Aspose.Pdf for .NET can not create link if it can not find referenced object in the file. Hyperlinks are absent in source files and that’s why they are absent in concatenated file. In order to accomplish your requirement, you may consider first concatenating the PDF files and then try creating Table Of Contents in resultant file. For further details, please visit

The issues you have found earlier (filed as PDFNEWNET-23543) have been fixed in Aspose.Pdf for .NET 9.8.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.