0% found this document useful (0 votes)
15 views3 pages

Cdu 50003

cdu50003 - copia

Uploaded by

Pepi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Cdu 50003

cdu50003 - copia

Uploaded by

Pepi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

OBJECT Codeunit 50004 Export Invoices to PDF 2

{
OBJECT-PROPERTIES
{
Date=16/02/21;
Time=20:20:29;
Modified=Yes;
Version List=;
}
PROPERTIES
{
OnRun=BEGIN
// Export Invoices example
// This example is based on PDF Printer 10.2 or later.
// Please go to www.bullzip.com to download the printer.
// There is a counter that limits the number of invoices printed to
PDF.

// NOTE: You should change the paths to match the location of the files
on your system.

CREATE(pdfSettings);
CREATE(pdfUtil);

IF header.FINDFIRST THEN BEGIN

baseFolder := 'C:\txt\Microsoft Dynamics NAV - Export Invoices';


// The status file is used to check for errors and determine when the
PDF is ready.
statusFileName := baseFolder + '\temp\status.ini';
// You can get a free test certificate at http://www.pdfpowertool.com
certificateFileName := baseFolder + '\ressources\CERTIF.DIGITAL
TEIDE.pfx';
certificatePassword := 'EM2007';
// Set file name of background PDF.
// Performance can be increased if you use an EPS file for background
instead of a PDF.
// Letterhead-A4.eps is a sample EPS background.
// Note that using EPS files as background requires the Expert
edition of the PDF Printer.
backgroundFileName := baseFolder + '\ressources\letterhead-a4.pdf';

//mergeBeforeFileName := baseFolder + '\ressources\Before.pdf';


//mergeAfterFileName := baseFolder + '\ressources\After.pdf';

counter := 0;
REPEAT
// Set file name for output file.
pdfFileName := baseFolder + '\Output\Invoice ' + header."No." +
'.pdf';

// Delete old output file if it already exist.


IF EXISTS(pdfFileName) THEN ERASE(pdfFileName);

// Multiple PDF printers could be installed.


// Let the automation know which one to control.
pdfSettings.printerName := pdfUtil.DefaultPrinterName;
// Set output file name
pdfSettings.SetValue('Output', pdfFileName);

// Make sure no dialogs are shown during conversion.


pdfSettings.SetValue('ShowSaveAs', 'never');
pdfSettings.SetValue('ShowSettings', 'never');
pdfSettings.SetValue('ShowPDF', 'no');
pdfSettings.SetValue('ShowProgress', 'no');
pdfSettings.SetValue('ShowProgressFinished', 'no');
pdfSettings.SetValue('ConfirmOverwrite', 'no');

// Set file name of status file to wait for.


pdfSettings.SetValue('StatusFile', statusFileName);

// Add a text watermark.


pdfSettings.SetValue('WatermarkText', 'PDF EXAMPLE - invoice ' +
header."No.");
pdfSettings.SetValue('WatermarkColor', '#FF0000');
pdfSettings.SetValue('WatermarkVerticalPosition', 'top');
pdfSettings.SetValue('WatermarkHorizontalPosition', 'right');
pdfSettings.SetValue('WatermarkRotation', '90');
pdfSettings.SetValue('WatermarkOutlineWidth', '0.5');
pdfSettings.SetValue('WatermarkFontSize', '20');
pdfSettings.SetValue('WatermarkVerticalAdjustment', '5');
pdfSettings.SetValue('WatermarkHorizontalAdjustment', '1');

// Add a background.
// If a professional or expert license is installed the quality of
the
// background will improve.
pdfSettings.SetValue('Superimpose', backgroundFileName);
pdfSettings.SetValue('SuperimposeLayer', 'bottom');

// Merge with other PDF files.


pdfSettings.SetValue('MergeFile', mergeBeforeFileName + '|.|' +
mergeAfterFileName);

// Sign with a digital certificate.


pdfSettings.SetValue('SignCertificate', certificateFileName);
pdfSettings.SetValue('SignPassword', certificatePassword);
pdfSettings.SetValue('ShowSignature', 'yes');

// Do not show errors in PDF user interface.


pdfSettings.SetValue('SuppressErrors', 'yes');

// You can see more features and settings at


// http://www.biopdf.com/guide/settings.php

// Write settings to printer.


// This writes a file name runonce.ini. It is a configuration that
is used
// for the next print job. The printer will delete the runonce.ini
after it
// is read.
pdfSettings.WriteSettings(TRUE);

IF EXISTS(statusFileName) THEN ERASE(statusFileName);


header2.COPY(header);
header2.SETRECFILTER;
REPORT.RUNMODAL(206, FALSE, FALSE, header2);

IF pdfUtil.WaitForFile(statusFileName, 20000) THEN BEGIN


// Check status file for errors.
IF pdfUtil.ReadIniString(statusFileName, 'Status', 'Errors', '')
<> '0' THEN BEGIN
ERROR('Error creating PDF. ' +
pdfUtil.ReadIniString(statusFileName, 'Status', 'MessageText', ''));
END;
END ELSE BEGIN
// The timeout elapsed. Something is wrong.
ERROR('Error creating ' + pdfFileName)
END;

counter := counter + 1;
UNTIL (header.NEXT=0) OR (counter >= 2);
END;
END;

}
CODE
{
VAR
header@1160840000 : Record 112;
header2@1160840006 : Record 112;
pdfFileName@1160840002 : Text[250];
statusFileName@1160840005 : Text[250];
certificateFileName@1160840001 : Text[250];
certificatePassword@1160840009 : Text[30];
backgroundFileName@1160840008 : Text[250];
mergeBeforeFileName@1160840011 : Text[250];
mergeAfterFileName@1160840012 : Text[250];
baseFolder@1160840010 : Text[250];
pdfSettings@1160840003 : Automation "{A3F69B34-EAD8-4A3B-8DD5-C1C3FD300D67}
4.0:{F6C83BBD-F620-4F13-8320-9C51D1996EC4}:'Bullzip - PDF Writer
Automation'.ComPdfSettings";
pdfUtil@1160840004 : Automation "{A3F69B34-EAD8-4A3B-8DD5-C1C3FD300D67} 4.0:
{F9444F96-C32A-4745-9FF3-9059B92CDAB0}:'Bullzip - PDF Writer
Automation'.ComPdfUtil";
pdfFolderName@1160840007 : Text[200];
counter@1160840013 : Integer;

BEGIN
END.
}
}

You might also like