Bookmark from word to pdf


#1

Hi

I need to join several word document generated by aspose word in a pdf single document and then provide an index with link. Can I use word bookmark for the index? I tried to do that but the bookmark do not appear in the pdf document (created with aspose pdf)

Tanks,

Lorenzo


#2

If you have local hyperlinks inside a document, then they will be exported to PDF okay as clickable links and bookmarks.

I’m not so sure about the way you want to create the index. You can try to use DocumentBuilder to create bookmarks and hyperlinks to those bookmarks and these will be exported to PDF okay as I said above.

If you want more help, send me more detailed explanation or a sample of what you want you build.




#3

Tanks,

In my project I have to create several document (each document is a sub process). At the and I have to join all the document (the entire process) and create a full index.

For doing that I create all the Document with Aspose Word and put all the document in a ArrayList. And then I join all the document directly join the xml section in a single xml. At the end I create the PDF with Aspose PDF.

So the bookmarks are not inside the index document during the creation of the Word document.

Can I put the bookmark and the hyperlinks directly in the full xml document?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Lorenzo.

PS. Sorry for my English


#4

You should be able to. Here is some pseudocode and ideas that should get you started:

DocumentBuilder builder = new DocumentBuilder(dstDoc);

for each document you want to joing
{
builder.MoveToDocumentEnd();
builder.InsertBookmark(document name or whatever);
AppendDoc(dstDoc, srcDoc);
}

builder.MoveToDocumentStart(); //or where you want to insert the index
for each document in your list
{
builder.InsertHyperlink(name of the bookmark you inserted above);
builder.Writeln();
}

See sample code for DocumentBuilder.InsertHyperlink in the API documentation.


#5

<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p> </o:p>

Hello,

I try with this test code where docArray contanin all the documents and the first is the index:

<o:p> </o:p>

<o:p> </o:p>

IEnumerator docEnum=docArray.GetEnumerator();<o:p></o:p>

docEnum.MoveNext();<o:p></o:p>

indice = (Document)docEnum.Current;<o:p></o:p>

DocumentBuilder indexBuilder = new DocumentBuilder(indice);<o:p></o:p>

indexBuilder.MoveToDocumentEnd();<o:p></o:p>

int i=1;<o:p></o:p>

while(docEnum.MoveNext())<o:p></o:p>

{<o:p></o:p>

DocumentBuilder docBuilder = new DocumentBuilder((Document)docEnum.Current);<o:p></o:p>

docBuilder.MoveToDocumentStart();<o:p></o:p>

docBuilder.StartBookmark(“bookmark” + i);<o:p></o:p>

docBuilder.Writeln(“bookmark” + i);<o:p></o:p>

docBuilder.EndBookmark(“bookmark” + i);<o:p></o:p>

indexBuilder.Writeln("–");<o:p></o:p>

indexBuilder.InsertHyperlink(“link” + i, “bookmark” + i ,true);<o:p></o:p>

i++;<o:p></o:p>

}<o:p></o:p>

<o:p>
</o:p>

<o:p></o:p>

<o:p></o:p>

<o:p> </o:p>

But opening the result PDF file Acrobat show the error:

“There was an error processing a page. There was a problem reading this document (110).”

<o:p> </o:p>

Using the value “fase” as last parameter of the call:

<o:p> </o:p>

The PDF file is correct but the link don’t wor.

<o:p> </o:p>

Lorenzo


#6

Hi,

If this is all your code, then there is something missing. You need to append contents of the chapter documents to the main document. You need to use Sections and Section to copy or move sections between documents.

You probably can use only one document builder too, but your approach could be okay too.