Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, May 10, 2023 11:52:52 AM(UTC)
KennethK

Groups: Registered
Posts: 2


The following code serves a PDF document that is merged from 40 single page PDF files. This process can take up to 30 seconds or more depending on how many PDFs are merged.





MemoryStream stream = new MemoryStream();
var docWriter = new DocumentWriter();
docWriter.BeginDocument(stream, DocumentFormat.Pdf);
PdfDocumentOptions pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
pdfOptions.OneBitImageCompression = OneBitImageCompressionType.FaxG4;
docWriter.SetOptions(DocumentFormat.Pdf, pdfOptions);
using (var codecs = new RasterCodecs())
{
foreach (JToken token in oPaths)
{
var rasterPage = new DocumentWriterRasterPage();
using (rasterPage.Image = codecs.Load(token.ToString(), 1))
{
docWriter.AddPage(rasterPage);
}
}
docWriter.EndDocument();
stream.Flush();
}
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, May 10, 2023 3:10:17 PM(UTC)

Nick  
Nick

Groups: Registered, Tech Support, Administrators
Posts: 163

Was thanked: 9 time(s) in 9 post(s)

Note the time for the DocumentWriter to complete can depend on a variety of factors including available system resources, where the source documents are located in the event they require transfer from a network location (which includes the possiblity of network latency and traffic) and the complexity of the input documents.

You may be able use our PDFFile.MergeFiles() functionality as it's optimized for this type of operation.
https://www.leadtools.co.../pdffile-mergefiles.html
https://www.leadtools.co...-to-single-pdf-file.html

Alternatively since you're writing to a raster format, you can combine the PDFs as a RasterImage and save it as RasterImageFormat.RasPdfG4.
https://www.leadtools.co...rasterimage-addpage.html

Does this occur with all PDF documents or only a combination of specific ones? Which version of the toolkit are you using?
Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.057 seconds.