I'm struggling to find out why "pbPDF-Watermark.pb" does NOT display the watermark, when I run the program.
Latest Win 10 Pro and PB 5.71 B2 (x86).
Tried 3 different PDF viewers, in case they might be the issue.
Perhaps you have an idea?

Code: Select all
#PDF=1
pdf$="test.pdf"
XIncludeFile "pbPDFModule.pbi"
Procedure Header()
PDF::Image(#PDF, "logo.jpg",5,8,30,0)
PDF::SetFont(#PDF, "Arial","B", 16)
PDF::SetPosY(#PDF, 10)
PDF::SetPosX(#PDF, 35)
PDF::Cell(#PDF, "Test Page", 100, 16)
PDF::Ln(#PDF, 20)
EndProcedure
If PDF::Create(#PDF,PDF::#Landscape,"mm",PDF::#Format_Letter)
PDF::SetPageCompression(#PDF, #True)
PDF::SetViewerPreferences(#PDF, PDF::#FitWindow)
PDF::SetHeaderProcedure(#PDF,@Header())
PDF::Enableheader(#PDF, #True)
PDF::AddPage(#PDF)
For tmp=1 To 60
PDF::Cell(#PDF, "This is a test"+Str(tmp), 100, 5, #False)
PDF::Ln(#PDF)
Next
PDF::Close(#PDF, pdf$)
RunProgram(pdf$)
EndIf
It was a little complicated to find the bug, but here it is:Paul wrote:I then tried with PDF::Image and unfortunately that also causes problems.
If I have an image in a header and there is more that 1 page in the PDF, the PDF that is generated is corrupt.
(I can view the first page but if I scroll to the second page Adobe Reader gives error)
Code: Select all
11 0 obj
<</Length 359>>
stream
2 J
0.57 w
BT /F2 12.00 Tf ET
q 85.04 0 0 NaN 14.17 NaN cm /I1 Do Q
BT /F1 16.00 Tf ET
BT 102.05 556.18 Td (Test Page) Tj ET
BT /F2 12.00 Tf ET
BT 31.18 516.27 Td (This is a test1) Tj ET
endstream
endobj
Code: Select all
XIncludeFile "..\pbPDFModule.pbi"
Define LinkID.i, File$ = "pbPDF-Images.pdf"
#PDF = 1
If PDF::Create(#PDF)
PDF::AddPage(#PDF)
LinkID = PDF::AddLinkURL(#PDF, "https://www.purebasic.com/")
PDF::Image(#PDF, "PureBasic.png", 10, 10, 30, 0, LinkID)
PDF::Image(#PDF, "PureBasic.jpg", 10, 110, 60, 0, LinkID)
PDF::Image(#PDF, "PureBasic.jp2", 10, 210, 80, 0, LinkID)
PDF::SetEncryption(#PDF,"test1","test",#False) ; if removed, images do appear
PDF::Close(#PDF, File$)
EndIf
RunProgram(File$)
Code: Select all
XIncludeFile "..\pbPDFModule.pbi"
Define LinkID.i, LinkURL.i, File$ = "pbPDF-Images.pdf"
#PDF = 1
If PDF::Create(#PDF)
PDF::AddPage(#PDF)
LinkURL = "https://www.purebasic.com/"
LinkID = PDF::AddLinkURL(#PDF, "https://www.purebasic.com/")
PDF::Image(#PDF, "purebasic.png", 10, 10, 30, 0, LinkID)
PDF::Image(#PDF, "PureBasic.jpg", 10, 110, 60, 0, PDF::AddLinkURL(#PDF, LinkURL))
PDF::Image(#PDF, "PureBasic.jp2", 10, 210, 80, 0, PDF::AddLinkURL(#PDF, LinkURL))
PDF::EmbedFont(#PDF, "l_10646.ttf", "LucidaSans", "", PDF::#Unicode)
PDF::SetFont(#PDF, "LucidaSans", "", 14)
PDF::PlaceText(#PDF, "This is an embedded Unicode-font (LucidaSans)", 20, 50)
; PDF::SetEncryption(#PDF,"test1","test",#False) ; if removed, images do appear
PDF::Close(#PDF, File$)
EndIf
RunProgram(File$)
Hi Norm., thank you, but regrettably this does not help either. Even if you remove all of the links, the images will not appear in the encrypted PDF.normeus wrote:Encryption might work,
I just figured it didn't since there was an error on a single line of text PDF which I encrypted,
but it turns out you get an error on non-encrypted PDFs: "invalid xref table"
The URL links for images cannot be reused so once you attach "LinkID" to the first image, the link is gone.
Code: Select all
XIncludeFile "..\pbPDFModule.pbi"
Define LinkID.i, File$ = "pbPDF-Images.pdf"
#PDF = 1
If PDF::Create(#PDF)
PDF::AddPage(#PDF)
; LinkID = PDF::AddLinkURL(#PDF, "https://www.purebasic.com/")
PDF::Image(#PDF, "PureBasic.png", 10, 10, 30, 0)
PDF::Image(#PDF, "PureBasic.jpg", 10, 110, 60, 0)
PDF::Image(#PDF, "PureBasic.jp2", 10, 210, 80, 0)
PDF::SetEncryption(#PDF,"test","test",#False)
PDF::Close(#PDF, File$)
EndIf
RunProgram(File$) ;- PDF is encrypted, but does not show images