We add a watermark to a PDF file using this logic:
public void CreateWatermark(string outputFile)
{
PdfFileInfo fileInfo = new PdfFileInfo(outputFile);
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindLogo(new FormattedText("DEMO", System.Drawing.Color.Blue, System.Drawing.Color.White,
Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 100));
stamp.SetOrigin(fileInfo.GetPageWidth(1) / 4, fileInfo.GetPageHeight(1) / 2);
stamp.IsBackground = true;
stamp.Rotation = 30;
stamp.Opacity = .7F;
PdfFileStamp fileStamp = new PdfFileStamp(outputFile, outputFile);
fileStamp.AddStamp(stamp);
fileStamp.Close();
}
We can see and print the PDF with the watermark in Adobe Reader, but when we use PdfViewer to print the PDF the watermark does not show:
public void PrintPdf(string pdfpath)
{
PdfViewer pdfview = new PdfViewer();
pdfview.OpenPdfFile(pdfpath);
pdfview.GetDefaultPrinterSettings();
pdfview.PrintPageDialog = true;
pdfview.PrintDocument();
pdfview.ClosePdfFile();
}
How can we use ASPOSE to print a PDF file with a watermark using the default printer settings?