This is a migrated thread and some comments may be shown as answers.

PdfFormatProvider // Exporting multiple HTML pages

2 Answers 196 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Zen
Top achievements
Rank 1
Zen asked on 11 Sep 2015, 07:01 PM

A web based application, I am working on, must provide users with the ability to export a collection of articles to one single PDF document. This articles contain HTML code for formatting the text as well as positioning of various parts of the article.

Below is the code which I came up with for Exporting one single article:

 

var html = File.OpenText(artPath).ReadToEnd();
var buffer = new byte[0];

var pdfProvider = new PdfFormatProvider();
var htmlFormatProvider = new HtmlFormatProvider();

HtmlImportSettings importSettings = new HtmlImportSettings();
importSettings.UseHtmlHeadingStyles = true;

htmlFormatProvider.ImportSettings = importSettings;

var document = htmlFormatProvider.Import(html);
document.LayoutMode = DocumentLayoutMode.Paged;
document.EnsureDocumentMeasuredAndArranged();

buffer = pdfProvider.Export(document);

using (var fs = new FileStream(pdfDocPath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
fs.Write(buffer, 0, buffer.Length);
fs.Flush();
}

 

However, I am not being able to figure out how to export multiple articles into one single PDF document. Any help would be highly appreciated.

 

Thanks!

Zen

2 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 16 Sep 2015, 03:02 PM
Hello Zen,

The Merge functionality of RadPdfProcessing could help you achieve your goal. It allows to merge a source PDF document into a target document. More information about this feature is available in our documentation. In order to use the Merge() method in this library, you will need to create a RadFixedDocument. How you could achieve this is described in this article.

Hope this is helpful.

Regards,
Tanya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Zen
Top achievements
Rank 1
answered on 18 Nov 2015, 11:38 AM

Thanks Tanya!

Zen

Tags
PdfProcessing
Asked by
Zen
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Zen
Top achievements
Rank 1
Share this question
or