|
Rank: Member Groups: Member
Joined: 5/8/2012 Posts: 13
|
Hello, I am currently trying to save the output as a TIFF file with CCITT4 compression. I am able to get the output to generate without errors, but there is a massive amount of quality loss. The output is virtually unreadable. When I save as PDF, the output is perfect. When I save as a TIFF with LZW compression, the quality is poor, but readable. Do you know if there is a way to get a higher quality output, that isn't lost in compression? We have a customer that is requiring CCITT4 compression, so another compression type isn't really an option. What I have tried so far:Adjusting the quality level
Code: Visual Basic.NET
HtmlToPdf.Options.JpegQualityLevel = 100
Increasing the zoom level
Code: Visual Basic.NET
HtmlToPdf.Options.ZoomLevel = 1.25
Auto Adjusting DPI
Code: Visual Basic.NET
HtmlToPdf.Options.AutoAdjustForDPI = True
Preserving High Res Image
Code: Visual Basic.NET
HtmlToPdf.Options.PreserveHighResImages = True
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Can you explain how do you save the output to TIFF file and how that is related to EO.Pdf?
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/8/2012 Posts: 13
|
To simplify it a little, I changed my code to save as a JPG and I am still getting a large amount of quality loss, compared to a pdf. I am saving the result as paged images, rather than a PDF. It's related to EO.Pdf, because I am using the AspxToPdf tool to generate the output. This code is getting executed in the AfterRender Event:
Code: Visual Basic.NET
Dim result As HtmlToPdfResult = CType(aspxToPDF.Result, HtmlToPdfResult)
Dim jpg As New PagedTiffFile(result.PageImages)
Dim stream as new MemoryStream
result.pageImages(0).Save(stream, ImageFormat.Jpeg)
stream.GetBuffer()
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, If you use Windows Forms, please try the add the following code in your main method and see if it helps:
Code: Visual Basic.NET
'Declare Windows API SetProcessDPIAware
Declare Function SetProcessDPIAware Lib "user32.dll" () As Boolean
Then call it in your main:
Code: Visual Basic.NET
Sub Main
'Enable high DPI aware
SetProcessDPIAware()
'Continue with other code
.....
End Sub
Please let us know if this works for you. Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/8/2012 Posts: 13
|
We are using ASP.NET Web Forms, so I don't think that will work. Do you know if there is a way to save the htmltopdf output in black and white? I wonder if the image is deteriorating when it's getting converted to gray scale, in the tiff compression.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Try call SetProcessDPIAware first. The reason we asked whether you are using Windows Forms because most UI programs are based on either Windows Forms or WPF. For WPF you do not need to call SetProcessDPIAware since the framework has already called it for you.
It is not uncommon to experience quality lose when converting image to gray scale. You can save our output to color image first to see if that has good quality. If that has good quality then obviously the problem is in the conversion.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/8/2012 Posts: 13
|
I was unable to get a high enough resolution image to be usable. We decided to go with an open source project called ImageMagicK, to convert the PDF output (From EO AspxToPdf) to an image array. By doing this, we get a much higher resolution/better quality image than we do from the EO PagedImage output. I am not completely happy with this solution, because it requires Ghostscript to be installed on the web server.
If you guys figure out how to generate that output in higher quality, please let me know. I'd much rather use a single solution for this.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Yes. We are working on this part and hopefully we can have a PDF render in the future. PageImages is always rendered at screen resolution (since it's a "by product" of the HTML render). Currently we do not have a PDF render that can render an PDF file. Once we have that, you should be able to render high quality images from any PDF file.
Thanks!
|
|