We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Combine files to PDF - bookmarks vs outlines issue

Hi, we are looking at using the Aspose product family to combine multiple types of office files (word, excel, powerpoint etc.) into a single PDF. To do so, I am firstly individually converting each file to a PDF in memory, and then using Aspose.Pdf to combine/concatenate the PDFs into a single file. This mostly works fine, but one problem I have run into is that we have a core requirement in that things like headings in word docs, names of worksheets in excel, etc. need to appear in the bookmarks panel of the final combined PDF. If you look at the files I have attached, it was pretty easy to get the two office files I individually converted to PDF to have these things show up in the bookmarks panel, however, as you’ll notice, in the pdf “combined” file, they are gone.



From the documentation I’ve looked at, apparently setting this before combining pdf’s is meant to copy the bookmarks:



pdfFileEditor.CopyOutlines = true;



However, it doesn’t work – from further investigation I have found out that although “bookmarks” and “outlines” are more or less the same thing to the end-user, e.g. they both appear in the bookmarks panel in a pdf, look exactly the same and take you to a spot in the document when clicked on, they appear to be treated differently from a technical perspective. I have noticed that when the word and excel files are converted to individual pdfs, those items have come through as bookmarks, not as outlines, and when combining the pdfs, there doesn’t appear to be a mechanism to copy bookmarks, e.g. there is nothing like “pdfFileEditor.CopyBookmarks” that I can see, like there is for outlines.



So with that in mind, I was hoping to find out if there is some way we can use Aspose to either…

-Copy bookmarks (not outlines) which are in individual pdfs into the combined pdf, or

-Is there any easy way to convert the bookmarks in each pdf to outlines before combining them, so that then they’ll automatically show up in the combined pdf, and if so, how?, or

-Initially when we convert the different types of office files to pdf, is there some way we can tell it to create these items as outlines rather than bookmarks (because this: saveOptions.OutlineOptions.HeadingsOutlineLevels = 9; is creating them as bookmarks). I note that if I manually open an office file and select “Save as Adobe PDF” (which I believe is Acrobat DC functionality), the resulting PDF has those items as outlines, not bookmarks, so if I then feed those PDF’s into Aspose.Pdf, it all works. However we need to automate the whole process.



Any advice would be appreciated.

Hi There,


Thanks for contacting support. I am looking into it in detail, I will share my findings with you shortly.

We are sorry for the inconvenience.

Best Regards,

Hi There.


I have tested the scenario using following code snippet and it seems to be working fine and full filling your requirement of keeping headings of word docs and names of the worksheets to appear in bookmark panel of the combined file. I have attached the final PDF file for your reference.

c#

Document pdfDoc1 = new Document(dataDir + “Excel-636264822031535640.pdf”);
Document pdfDoc2 = new Document(dataDir + “Word-636264822017940640.pdf”);
pdfDoc1.Pages.Add(pdfDoc2.Pages);
foreach (OutlineItemCollection item in pdfDoc2.Outlines)
{
pdfDoc1.Outlines.Add(item);
}
//save concatenated output file
pdfDoc1.Save(dataDir + “Concat_outputDOM.pdf”);

If you still face any issue or need further assistance, please feel free to contact us.

We are sorry for the inconvenience.

Best Regards,

Thanks for getting back to me Fahad. When I have a moment I will try your suggested code and see if it works for me. I thought that the .Outlines collection was returning empty for me, but maybe I was doing something wrong. I’ll try again with your code and let you know.

Should you have any further query, please feel free to contact.


Best Regards,

Hi Fahad



That seems to work to some extent - from your suggestion I’ve now been able to get them all to show up in the bookmark panel of the combined pdf. However, I have noticed another problem…

If you combine the “Excel-” pdf file followed by the “Word-” pdf file, everything works as you have shown (works for me too), but if you switch the order around like combine the “Word-” one then the “Excel-” one (leaving the rest of the code the same), in the combined pdf the bookmark links for the “Excel-” file are messed up (not going to the correct location). If you open this file I’ve attached and click on “Sheet1” or “Sheet2” in the bookmarks panel, you’ll see what I mean.



Jason

Hi Jason,


Thanks for sharing further details.

I have tested the scenario and have managed to reproduce the same the problem that after combing word and then excel file book marks get messed. For the sake of correction, I have logged a ticket PDFNET-42561 in our issue tracking system. We will further look into the details of this issue and will keep you updated on the stats of its resolution within this forum thread. Please be patient and spare us little time.

We are sorry for this inconvenience.

Best Regards,

Hi again

Was just wondering if it’s possible for you to give me an indication of what the timeframe is for when you guys will be able to look at/fix this problem, so that I can inform our management.

Jason

Hi Jason,


Thanks for your inquiry. I am afraid the earlier reported issue is not yet resolved as we have been busy fixing other previously reported issue. However I have intimated the product team to evaluate the issue and try accommodating it in development schedule. As soon as we have some further updates regarding its resolution, we will let you know. Please be patient and spare us little time.

We are sorry for this inconvenience.

Best Regards,

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px ‘Helvetica Neue’; -webkit-text-stroke: #000000}
span.s1 {font-kerning: none}

Thank you for the update Fahad, much appreciated and I look forward to hearing back once the product team can get onto this. Just so you know, we are currently evaluating different products against our requirements, and Aspose does tick most of our boxes but being able to have the bookmark links working in a combined PDF is a core requirement, and our executive aren’t keen to engage a PDF solution without that feature being fully functional. Without commitment to resolve, I can’t see them engaging Aspose. We are reaching the point where they want to decide on a provider.
Regards
Jason

Hi Jason,


Thanks for contacting support.

We do understand the criticallity of issue and the inconvenience which you have been facing but as shared earlier by Fahad, the issue is recently noticed and is pending for review and as a normal rule of practice, we resolve the issues in first come first serve basis as we believe its the fairest policy to all the customers. However your concerns have already been shared with product team and they will surely consider them while resolving this problem. As soon as we have some definite updates regarding its resolution, we will let you know.