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 : Sunday, July 14, 2013 11:30:05 PM(UTC)

oklatt  
oklatt

Groups: Registered
Posts: 8


Hello,

I would like to create a PDF with the following function:

Public Function createTIF2PDF(arrlstTIFFiles As ArrayList, outputFile As String) As Boolean

Dim leadDocWriter As New DocumentWriter
leadDocWriter.BeginDocument(outputFile, Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf)

Dim page As DocumentPage = DocumentPage.Empty
Dim pdfOptions As PdfDocumentOptions = DirectCast(leadDocWriter.GetOptions(Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf), PdfDocumentOptions)

pdfOptions.DocumentType = PdfDocumentType.PdfA
leadDocWriter.SetOptions(Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf, pdfOptions)

For Each item In arrlstTIFFiles
Using codecs As New RasterCodecs()
page.Image = codecs.Load(item.ToString)
leadDocWriter.AddPage(page)
End Using
Next

leadDocWriter.EndDocument()
Return True

End Function


Unfortunately I get an error "Leadtools.RasterException: Not able to open file" in line "leadDocWriter.AddPage(page)"
Of course I unlock LEadtools before starting the function.

I'm using LEADTOOLS 18
- I refer Leadtools, Leadtools.codecs, codecs.BMP, codecs.CMP, codecs.FAX, codecs.TIF
LEADTOOLS.PDF, LEADTOOLS.PDFCompressor







 

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 : Tuesday, July 16, 2013 2:38:58 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

I checked your code and noticed that you are Not setting the DocumentPage.EmfHandle property. According to our documentation, the Leadtools.Forms.DocumentWriters.DocumentPage.EmfHandle property must contain a valid Windows Enhanced Meta File handle (EMF) that contains the visual representation of the page. This EMF handle can obtained through multiple sources, such as GetEnhMetaFile() API function.

The following code shows how you can set the EmfHandle property:
+------------------------+
Public Class Form1

' Windows API functions needed to load/delete an EMF
<DllImport("gdi32.dll")> _
Private Shared Function GetEnhMetaFile(ByVal lpszMetaFile As String) As IntPtr
End Function
<DllImport("gdi32.dll")> _
Private Shared Function DeleteEnhMetaFile(ByVal hemf As IntPtr) As Boolean
End Function
...
Public Function createTIF2PDF(arrlstTIFFiles As ArrayList, outputFile As String) As Boolean

Dim leadDocWriter As New DocumentWriter
leadDocWriter.BeginDocument(outputFile, Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf)

Dim page As DocumentPage = DocumentPage.Empty
Dim pdfOptions As PdfDocumentOptions = DirectCast(leadDocWriter.GetOptions(Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf), PdfDocumentOptions)

pdfOptions.DocumentType = PdfDocumentType.PdfA
      leadDocWriter.SetOptions(Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf, pdfOptions)

For Each item In arrlstTIFFiles
Using codecs As New RasterCodecs()
page.Image = codecs.Load(item.ToString)
page.EmfHandle = GetEnhMetaFile("c:\Users\Public\Documents\LEADTOOLS Images\Ocr1.emf")
leadDocWriter.AddPage(page)
End Using
Next

leadDocWriter.EndDocument()
Return True

End Function
+------------------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Tuesday, July 16, 2013 4:51:22 AM(UTC)

oklatt  
oklatt

Groups: Registered
Posts: 8



Hello Badwan,

thanks for quick response!

Unfortunately I have to work with TIFF files!

Is there no possibility to bundle multible tiff files to one PDF without using the emf format?

Thanks Olaf
 
#4 Posted : Tuesday, July 16, 2013 9:24:43 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

You can convert multiple tiff files to one PDF without using the DocumentWriter class. You can simple load the TIFF files using RasterCodecs.Load() method and then save them to one PDF file using the RasterCodecs.Save() method.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Tuesday, July 16, 2013 9:35:22 PM(UTC)

oklatt  
oklatt

Groups: Registered
Posts: 8


Hi Badwan,

but that is what I try in the first example code. I use the RasterCodecs.Load method and also the DocumentWriter class
By the way: I have multiple Single-TIFFs that I put together to a PDF.

Can you give me a correct example?

Thanks a lot...

Olaf

 
#6 Posted : Tuesday, July 16, 2013 9:48:48 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

You need to change the code as follows:
+---------------+
Public Function createTIF2PDF(arrlstTIFFiles As ArrayList, outputFile As String) As Boolean
For Each item In arrlstTIFFiles
Using codecs As New RasterCodecs()
Dim TIFFImage As RasterImage = codecs.Load(item.ToString)
codecs.Save(TIFFImage, outputFile, RasterImageFormat.RasPdf, 0, 1, 1, 1, CodecsSavePageMode.Append)
TIFFImage.Dispose()
End Using
Next
Return True
End Function
+---------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#7 Posted : Wednesday, July 17, 2013 12:51:43 AM(UTC)

oklatt  
oklatt

Groups: Registered
Posts: 8


Hello Badwan,

allthough I have included the Leadtools.codecs.pdf and other I get the error: "Leadtools.RasterException: Feature not supported"

Another question I have: Is it possible to write in PDFA Format? ( codecs.Options.Pdf.Save.SavePdfA = True )

Thanks Olaf
 
#8 Posted : Wednesday, July 17, 2013 3:18:17 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

About the "Feature not supported" error, you need to add Leadtools.Pdf.dll as a refernce in your project.

About saving PDFA format, you can do this by setting the codecs.Options.Pdf.Save.Version property to CodecsRasterPdfVersion.PdfA before saving the PDF file.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#9 Posted : Wednesday, July 17, 2013 9:19:48 PM(UTC)

oklatt  
oklatt

Groups: Registered
Posts: 8


Hi Badwan,

next try, next error... :-(
Leadtools.RasterException: PDF capability is required.

Of course I unlock Leadtools before and yes, I have serveral unlocks for:

[Unlocks]
L_SUPPORT_OCR_PROFESSIONAL_PDF_OUTPUT
L_SUPPORT_CLOUD
L_SUPPORT_OCR_PROFESSIONAL
L_SUPPORT_BARCODES_1D
L_SUPPORT_DOCUMENT
L_SUPPORT_MEDIA_WRITER
L_SUPPORT_JBIG2
L_SUPPORT_FORMS
L_SUPPORT_DOCUMENT_WRITERS
L_SUPPORT_DOCUMENT_WRITERS_PDF
L_SUPPORT_BASIC

I can't image, that I'm not allowed to save a normal PDF.

Thanks Olaf


 
#10 Posted : Thursday, July 18, 2013 12:35:06 AM(UTC)

Ibrahim  
Guest

Groups: Guests
Posts: 3,022

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

Olaf,
I need to investigate this issue further, so please open a support ticket by sending an email to support@leadtools.com and mention this forum post.

Include in the email the .LIC file and the developer key (do NOT post them here) that you used to set the runtime license.

Note: If you send any attachments, please put them in a ZIP or RAR file to ensure our server delivers them correctly.
 
#11 Posted : Thursday, July 25, 2013 9:13:14 PM(UTC)

oklatt  
oklatt

Groups: Registered
Posts: 8


Short info: It was a wrong key (L_SUPPORT...) that I got. With the new one everything works fine.

thanks a lot

Olaf
 
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.102 seconds.