Watermarks are printed bad

Hi,


We use Aspose.pdf library to apply watermarks and print documents.

I get file “Test (original).pdf”,
apply watermark by Aspose.pdf -> “Test (with watermark).pdf”.

I open this file “Test (with watermark).pdf” in Acrobat Reader and print it in pdf (by PDF Creator) -> “Printed (by Acrobat).pdf”.
File “Printed (by Acrobat).pdf” looks good.

I print file “Test (with watermark).pdf” by Aspose.pdf -> “Printed (by Aspose).pdf”.
File “Printed (by Aspose).pdf” looks bad. Watermark is in dot.

If I print to a real printer result is the same.

Last Aspose.pdf - v8.3.1.0, .Net 4.0

How can I fix it?

Thanks.

Hi there,


Thanks for your inquiry. I’ve manged to notice the printing issue while printing your source document with Aspose.Pdf and logged issue as PDFNEWNET-35733 for further investigation and resolution. It would help us to investigate the issue if your please share your sample code, used to add text watermark. As I’m unable to replicate the issue with other watermarked documents than your’s.

Looking forward for your input.

Best Regards,

Hi,


I attached small sample.

Thanks.

Hi there,


Thank you for sharing source code. It really helped to replicate the issue, opacity property is causing the issue. We will update you via this forum thread as soon as we make some progress towards the solution.

Thanks for your cooperation.

Best Regards,

Hi,


Is this isuue fixed?

Thanks.

Hi Igor,


Thanks for your patience.

The development team has been busy resolving
other priority issues and I am afraid the issue reported earlier is not yet
resolved. Nevertheless, I have requested the team to share the ETA regarding
its resolution. As soon as we have some definite updates regarding its
resolution, we would be more than happy to update you with the status of correction.
Please be patient and spare us little more time.<o:p></o:p>

We are really sorry for
this inconvenience.

Hi,


We are going to do next release of our application and would like to fix it in our release…
Didn’t it fix yet?
I reported about this issue almost a year ago…

Thanks.

Hi Igor,


Thanks for your inquiry. I am afraid your reported issue is still not resolved due to other priority tasks. However we have recorded your concern and requested our development team to complete the investigation and share an ETA at their earliest. We will keep you update about the issue resolution progress via this forum thread.

We are sorry for the inconvenience caused.

Best Regards,

Hi Igor,


Thanks for your patience. We have further investigated and found that unfortunately the issue can’t be completely fixed. The issue is .Net Framework printing known issue - it prints opacity as dot-filled color.

As a workaround, to make the text look better the system fonts may be printed with native .Net Framework text printing method. Embedded fonts may be substituted with the same named system fonts with a custom substitution method.

Please check following code snippet. Test it and share the results, hopefully it will help you to improve the print quality.

public void PDFNEWNET_35733()<o:p></o:p>

{<o:p></o:p>

String
inFile = “input.pdf”;<o:p></o:p>

String
outFile = “output.pdf”;<o:p></o:p>

//open document<o:p></o:p>

Document
pdfDocument = new Document(inFile);<o:p></o:p>

var
pdfTextFont = FontRepository.FindFont(“Tahoma”);<o:p></o:p>

var
pdfTextColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black);<o:p></o:p>

var
pdfTextBackColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.White);<o:p></o:p>

var
testStamp = new TextStamp(DateTime.Now.ToString())<o:p></o:p>

{<o:p></o:p>

BottomMargin = 10,<o:p></o:p>

LeftMargin = 30,<o:p></o:p>

TopMargin = 10,<o:p></o:p>

// Text is printed as dotted text when we
use Opacity property of TextStamp
<o:p></o:p>

Opacity = (float)90 / 100,<o:p></o:p>

HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center,<o:p></o:p>

VerticalAlignment = VerticalAlignment.Top,<o:p></o:p>

};<o:p></o:p>

testStamp.TextState.Font = pdfTextFont;<o:p></o:p>

testStamp.TextState.ForegroundColor = pdfTextColor;<o:p></o:p>

testStamp.TextState.BackgroundColor =
pdfTextBackColor;<o:p></o:p>

pdfDocument.Pages[1].AddStamp(testStamp);<o:p></o:p>

pdfDocument.Save(outFile);<o:p></o:p>

PdfViewer
pdfViewer = new PdfViewer();<o:p></o:p>

pdfViewer.BindPdf(outFile);<o:p></o:p>

// Print system
fonts with native .net method
<o:p></o:p>


pdfViewer.RenderingOptions.SystemFontsNativeRendering = true;<o:p></o:p>

// Substitute
embedded fonts with the same named system fonts
<o:p></o:p>

FontRepository.Substitutions.Add(new CustomSubst1());<o:p></o:p>

System.Drawing.Printing.PrinterSettings ps = new
System.Drawing.Printing.PrinterSettings();<o:p></o:p>

System.Drawing.Printing.PageSettings pgs = new
System.Drawing.Printing.PageSettings();<o:p></o:p>

System.Drawing.Printing.PrintDocument prtdoc = new
System.Drawing.Printing.PrintDocument();<o:p></o:p>

pgs.Margins = new
System.Drawing.Printing.Margins(0, 0, 0, 0);<o:p></o:p>

ps.PrinterName = “Adobe
Pdf”
;<o:p></o:p>

pdfViewer.PrintDocumentWithSettings(pgs,
ps);<o:p></o:p>

pdfViewer.Close();<o:p></o:p>

}<o:p></o:p>

<o:p> </o:p>

private class CustomSubst1
: CustomFontSubstitutionBase<o:p></o:p>

{<o:p></o:p>

public override bool
TrySubstitute(OriginalFontSpecification
originalFontSpecification, out Aspose.Pdf.Text.Font substitutionFont)<o:p></o:p>

{<o:p></o:p>

try<o:p></o:p>

{<o:p></o:p>

// substitute
embedded fonts with system fonts (.Net printing doesn’t support embedded fonts
printing. only system fonts are supported)
<o:p></o:p>

if
(originalFontSpecification.IsEmbedded)<o:p></o:p>

{<o:p></o:p>

substitutionFont = FontRepository.FindFont(originalFontSpecification.OriginalFontName);<o:p></o:p>

return true;<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

catch
(Aspose.Pdf.Exceptions.FontNotFoundException)<o:p></o:p>

{<o:p></o:p>

// don’t
substitute in case font is not found
<o:p></o:p>

}<o:p></o:p>

return base.TrySubstitute(originalFontSpecification, out substitutionFont);<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

Please feel free to contact us for any further assistance.


Best Regards,