How to merge PDF files using dotnet

Remco_Reinking
Member Posts: 74
Sometimes one needs to merge multiple PDF-files to one PDF file, e.g. to send it by email to your customer.
This is how it could be done using dotnet and the PdfSharp.dll as an add-in (get it here)
Two functions, MergePDFFiles and a local function AddPages
with local vars declared as:
and the local function AddPages looks like:
with local vars:
This is how it could be done using dotnet and the PdfSharp.dll as an add-in (get it here)
Two functions, MergePDFFiles and a local function AddPages
function MergePDFFiles(PDFFile1 : Text;PDFFile2 : Text;NewPDFFile : Text) PDFDocOut := PDFDocOut.PdfDocument; AddPages( PDFFile1, PDFDocOut); AddPages( PDFFile2, PDFDocOut); IF EXISTS( NewPDFFile) THEN ERASE( NewPDFFile); PDFDocOut.Save( NewPDFFile); PDFDocOut.Close; PDFDocOut.Dispose;
with local vars declared as:
PDFDocOut DotNet PdfSharp.Pdf.PdfDocument.'PdfSharp, Version=1.32.2608.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb'
and the local function AddPages looks like:
LOCAL function AddPages(PDFFileName : Text;VAR DestPDF : DotNet "PdfSharp.Pdf.PdfDocument") FromPDF := PDFReader.Open( PDFFileName, PDFOpenDocMode.Import); FOR i := 0 TO FromPDF.PageCount-1 DO DestPDF.AddPage( FromPDF.Pages.Item(i)); FromPDF.Close; FromPDF.Dispose;
with local vars:
FromPDF DotNet PdfSharp.Pdf.PdfDocument.'PdfSharp, Version=1.32.2608.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb' PDFReader DotNet PdfSharp.Pdf.IO.PdfReader.'PdfSharp, Version=1.32.2608.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb' PDFOpenDocMode DotNet PdfSharp.Pdf.IO.PdfDocumentOpenMode.'PdfSharp, Version=1.32.2608.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb' i Integer
0
Comments
-
Just saw this one (file-access-error-from-dotnet-assembly), almost showing the same functionality as a sample. The function to merge two PDF's works fine if running from a RTclient, but when called through a webservice it gives the file access error. So far I did not find a solution for this, who did?0
-
If I remember correctly, the web service uses the service user's credentials and profile to access files, not the credentials used to access the web service.0
-
@Remco_Reinking what is version? I'll have so many errors with
PdfSharp.Pdf.PdfDocument.'PdfSharp-WPF, Version=1.32.2608.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb'
In Pdfsharp without WPF didn't see any Type in .NET Type list.
With my Errors i found pdfsharp 1.50 beta3b, but only source code, mb u have of 1.50beta3b pdfsharp.dll?
UPD.I'll rebuild source code and i saw Types with pdfsharp without WPF, OMG!
THIS IS WORK!0 -
P.S. version 1.50 beta3b work faster, i'll can link .DLL if someone have trouble with build source code in VS.0
-
I tried using @Remco_Reinking s Code to merge two PDF Files. I registerd the DLLs i downloaded via the link above. Unfortunately i can't compile the codeunit getting the following error: You have specified an unknown variable. Import. Which should be in:
PDFOpenDocMode DotNet PdfSharp.Pdf.IO.PdfDocumentOpenMode.'PdfSharp, Version=1.32.2608.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb'
Can anybody help me or had the same problem?
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions