I have a PDF that I’ve created in Aspose.PDF and I want to save it as an image. When trying to save as a TIFF, the PDF becomes blurry. I’m also losing some of the lines that I’m adding to the PDF.
If I save as PDF it looks like this:
test3.pdf (15.7 KB)
If I save as a TIFF it looks like this (attaching a screenshot because this system will not allow me to upload a TIFF) Notice how the bars become blurry:
2020-07-20_14-05-52.png (109.4 KB)
Source code:
Private Sub ButtonSupport_Click(sender As Object, e As EventArgs)
Dim bArr() As Byte
Dim License As Aspose.BarCode.License = New Aspose.BarCode.License()
License.SetLicense("C:\Users\nbart\Documents\SourceCode\psg-docutransfer\ConnectSuite\Aspose\Aspose.Library\bin\Aspose.Barcode.lic")
Dim Generator = New Aspose.BarCode.Generation.BarcodeGenerator(EncodeTypes.GS1Code128, "(420)55350(92)14890194038316398145")
Aspose.Library.PdfHelper.LoadLic()
Generator.Parameters.Barcode.BarHeight.Point = 39
Generator.Parameters.Barcode.AutoSizeMode = Generation.AutoSizeMode.None
Generator.Parameters.Barcode.XDimension.Point = 1
Generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None
Generator.Parameters.Barcode.CodeTextParameters.Alignment = Aspose.BarCode.Generation.TextAlignment.Center
Generator.Parameters.CaptionBelow.Visible = True
Generator.Parameters.Barcode.Padding.Bottom.Point = 6
Generator.Parameters.Barcode.Padding.Top.Point = 6
Generator.Parameters.CaptionBelow.Text = "9214 8901 1538 5200 5203 11"
Generator.Parameters.CaptionBelow.Font.FamilyName = Font.Bold
Generator.Parameters.CaptionAbove.Text = "USPS CERTIFIED MAIL"
Generator.Parameters.CaptionAbove.Visible = True
Dim lGeneratedBitmap = Generator.GenerateBarCodeImage()
Dim imageWidth = lGeneratedBitmap.Width
Dim imageLength = lGeneratedBitmap.Height
Dim mStream = New System.IO.MemoryStream()
Generator.Save(mStream, Aspose.BarCode.BarCodeImageFormat.Bmp)
Dim ImageStamp = New ImageStamp(mStream)
ImageStamp.Background = True
ImageStamp.XIndent = 18
ImageStamp.YIndent = 0
ImageStamp.Quality = 100
Dim pdfDocument = New Document()
Dim Page = pdfDocument.Pages.Add()
pdfDocument.Pages(1).SetPageSize(imageWidth + 36, 108)
Page.PageInfo.Margin = New MarginInfo(0, 0, 0, 0)
Page.AddStamp(ImageStamp)
Dim graph = New Aspose.Pdf.Drawing.Graph(Page.PageInfo.Width, Page.PageInfo.Height)
Dim line = New Aspose.Pdf.Drawing.Line(New Single() {1, 106, (imageWidth - 1) + 36, 106})
line.GraphInfo.LineWidth = 2
graph.Shapes.Add(line)
Dim line2 = New Aspose.Pdf.Drawing.Line(New Single() {1, 2, (imageWidth - 1) + 36, 2})
line2.GraphInfo.LineWidth = 2
graph.Shapes.Add(line2)
Page.Paragraphs.Add(graph)
Dim pdfConverter = New PdfConverter()
pdfConverter.BindPdf(pdfDocument)
pdfConverter.DoConvert()
pdfConverter.SaveAsTIFF("C:\Users\nbart\Downloads\test3.tif")
pdfConverter.Close()
End Sub