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,
Hi There.
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”);
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.
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,
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,
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,