Hi,
Previously I was able to use “sections” to convert tif to pdf (see below code):
TestTif4.zip (160.3 KB)
Dim pdf1 As Pdf = New Pdf()
Dim ms As MemoryStream = New MemoryStream(tiffFil)
Dim myimage As New Bitmap(ms)
Dim dimension As New FrameDimension(myimage.FrameDimensionsList(0))
Dim frameCount As Integer = myimage.GetFrameCount(dimension)
Dim tifstream = New MemoryStream()
If frameCount = 1 Then
Dim sec As Section = pdf1.Sections.Add()
SetupMargener(sec)
If myimage.Width > myimage.Height Then
sec.IsLandscape = True
Else
sec.IsLandscape = False
End If
Dim imageht As Aspose.Pdf.Generator.Image = New Aspose.Pdf.Generator.Image(sec)
imageht.ImageInfo.ImageFileType = ImageFileType.Tiff
imageht.ImageInfo.ImageStream = ms
imageht.ImageInfo.IsBlackWhite = blackWhite
sec.Paragraphs.Add(imageht)
Else
For frameIdx As Integer = 0 To frameCount - 1
Dim sec As Section = pdf1.Sections.Add()
SetupMargener(sec)
myimage.SelectActiveFrame(dimension, frameIdx)
Dim currentImage As New MemoryStream()
myimage.Save(currentImage, ImageFormat.Tiff)
If myimage.Width > myimage.Height Then
sec.IsLandscape = True
Else
sec.IsLandscape = False
End If
Dim imageht As Aspose.Pdf.Generator.Image = New Aspose.Pdf.Generator.Image(sec)
imageht.ImageInfo.ImageFileType = ImageFileType.Tiff
imageht.ImageInfo.ImageStream = currentImage
imageht.ImageInfo.IsBlackWhite = blackWhite
sec.Paragraphs.Add(imageht)
Next frameIdx
End If
pdf1.Save(tifstream)
The above code results in a pdf of 954kb.
Now i cant use “section” anymore - and therefore im now using this code to convert from tid to pdf:
Dim pdf As New Aspose.Pdf.Document()
Dim page = pdf.Pages.Add()
Dim tifstream = New MemoryStream()
Dim ms As MemoryStream = New MemoryStream(tiffFil)
Dim bitmap As New Bitmap(ms)
page.PageInfo.Margin.Bottom = 0
page.PageInfo.Margin.Top = 0
page.PageInfo.Margin.Left = 0
page.PageInfo.Margin.Right = 0
page.CropBox = New Aspose.Pdf.Rectangle(0, 0, bitmap.Width, bitmap.Height)
Dim image As New Aspose.Pdf.Image()
page.Paragraphs.Add(image)
image.IsBlackWhite = blackWhite
image.ImageStream = ms
pdf.OptimizeResources()
pdf.Save(tifstream)
The result is PDF of almost 11MB (!!)
What can I do to fix this, since i cant use “Section” anymore
“BlackWhite” is set to true
I have attached the tif file (as .zip) im convertering to pdf.
Hope you can help.