LEADTOOLS Support
Document
Document SDK FAQ
How do I set document output options with the Document Converters?
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, March 26, 2018 11:25:28 AM(UTC)
Groups: Tech Support
Posts: 366
Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
With the Document Converters, there are two ways for setting the output options (Document Writers). This comes from the way the Document Converters handles document and raster conversions. Raster conversions to documents require optical character recognition (OCR), and the document writers used by the OCR engine dictate the resulting output document. Document to document conversions do not require the use of OCR; they are converted first to scalable vector graphics (SVG) and then with the document writers outputted to a new document.
If we set up the Document Writers like this:
Code:DocumentWriter docWriters = new DocumentWriter();
PdfDocumentOptions pdfWriteOptions = docWriters.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
pdfWriteOptions.PageFitType = PdfDocumentPageFitType.FitHeight;
pdfWriteOptions.ZoomPercent = 100.0;
pdfWriteOptions.FitWindow = true;
pdfWriteOptions.HideMenubar = false;
pdfWriteOptions.HideToolbar = true;
pdfWriteOptions.HideWindowUI = false;
pdfWriteOptions.Protected = true;
pdfWriteOptions.OwnerPassword = "OwnerPass123";
pdfWriteOptions.EncryptionMode = PdfDocumentEncryptionMode.RC128Bit;
pdfWriteOptions.PrintEnabled = false;
pdfWriteOptions.EditEnabled = false;
pdfWriteOptions.CopyEnabled = false;
pdfWriteOptions.AssemblyEnabled = false;
pdfWriteOptions.HighQualityPrintEnabled = false;
pdfOptions.AutoBookmarksEnabled = true;
pdfOptions.AutoBookmarks.Add(new PdfAutoBookmark() { FontFaceName = "Arial", UseStyles = true, BoldStyle = true, ItalicStyle = false, FontHeight = 19.5 });
pdfOptions.AutoBookmarks.Add(new PdfAutoBookmark() { FontFaceName = "Arial", UseStyles = true, BoldStyle = true, ItalicStyle = false, FontHeight = 11 });
pdfOptions.TotalBookmarkLevels = 2;
docWriters.SetOptions(format, pdfWriteOptions);
The following is sample code illustrating how to set the output options without OCR:
Code:using (DocumentConverter documentConverter = new DocumentConverter())
{
documentConverter.SetDocumentWriterInstance(docWriters);
var myJobData = DocumentConverterJobs.CreateJobData(INPUT_FILE_NAME, OUTPUT_FILE_NAME, DocumentFormat.Pdf);
myJobData.JobName = "My job";
var job = documentConverter.Jobs.CreateJob(myJobData);
documentConverter.Jobs.RunJob(job);
}
The following illustrates how to set the output options when using OCR for conversions:
Code:RasterCodecs codecs = new RasterCodecs();
DocumentWriter docWriters = new DocumentWriter();
IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);
ocrEngine.Startup(codecs, docWriters, TEMP_WORKING_DIRECTORY, OCR_ENGINE_RUNTIME);
using (DocumentConverter documentConverter = new DocumentConverter())
{
documentConverter.SetOcrEngineInstance(ocrEngine, false);
var myJobData = DocumentConverterJobs.CreateJobData(INPUT_FILE_NAME, OUTPUT_FILE_NAME, DocumentFormat.Pdf);
myJobData.JobName = "Test conversion job";
var job = documentConverter.Jobs.CreateJob(myJobData);
documentConverter.Jobs.RunJob(job);
}
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.

LEADTOOLS Support
Document
Document SDK FAQ
How do I set document output options with the Document Converters?
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.