Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Aug 01, 2018 11:25 am

In following the code example completely found at, Set Graphic Overlay in PDF File, I cannot get the outcome to be the same as described.

I'm attempting to take two different PDFs. Both are text based and both are full 8.5x11 landscaped. My task is to take 'overlay' and overlay it on the 'print' document. View attachment for example files. When I do that I get only a single page and nothing is overlaid.

How do I correct this issue?

Code: Select all
Imports System.Drawing
Imports Spire.Pdf
Imports Spire.Pdf.Graphics

Namespace pdf_graphic_overlay
     Class Program
       Private Shared Sub Main(args As String())
      'load two documents
        Dim doc1 As New Spire.Pdf.PdfDocument()
        doc1.LoadFromFile("C:\temp\print.pdf")
        Dim doc2 As New Spire.Pdf.PdfDocument()
        doc2.LoadFromFile("C:\temp\overlay.pdf")
        'Create page template
        Dim template As PdfTemplate = doc1.Pages(0).CreateTemplate()
        'set PDF overlay effect and set transparency mode
        For Each page As Spire.Pdf.PdfPageBase In doc2.Pages
            'set transparency
            page.Canvas.SetTransparency(0.25F, 0.25F, PdfBlendMode.Overlay)
            'add the first page of doc1 to every page of doc2
            page.Canvas.DrawTemplate(template, PointF.Empty)
        Next
        'Save pdf file.
        doc2.SaveToFile("C:\temp\Overlay.pdf")
        doc1.Close()
        doc2.Close()
        'Launching the Pdf file.
        System.Diagnostics.Process.Start("C:\temp\Overlay.pdf")
       End Sub
     End Class
End Namespace

jandk4014
 
Posts: 1
Joined: Thu Aug 31, 2017 9:49 pm

Thu Aug 02, 2018 3:25 am

Dear Jeff,

Thanks for your post.
After testing your case with the latest Spire.PDF Pack(Hot Fix) Version:4.7.11, I can see the "overlay" effect if open the generated file in Foxit PDF Editor. But if open the file in Adobe, it pops up "An error exists on this page". I have posted the issue to our Dev team for investigating and fixing. If there is any update, I will notify you. Sorry for the inconvenience caused.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Fri Aug 11, 2023 8:08 am

Hello,

Sorry for long silence.
Recently, we released a new version of Spire.PDF (Version:9.8.5), which includes the fix of your reported issue. Please download the version from the following link and add the code below to have a try.
Code: Select all
doc2.FileInfo.Version = PdfVersion.Version1_3;

Website download link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget download link: https://www.nuget.org/packages/Spire.PDF/9.8.5

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF