Page 3 of 3
Re: [Module] PurePDF
Posted: Thu Feb 01, 2018 8:46 pm
by Wolfgang2
Dear normeus,
I do know and understand all this.
My question is regarding the opposite behaviour: I do not want to have two references to the same embedded file in the "Attachments" sidebar.
I observed that if you add a file annotation ( pdf_SetAFile() ) with the method from the Tutorial29, the embedded file shows up twice in the PDF.
To see that effect:
- Run Tutorial29
- In Acrobat Reader, on the left side, open the sidebar for "Attachments".
- See the same file showing up twice. Usually ( but not always ) you can click-open just one of the two.
I did look at the created PDF file today and it seems that the embedded file is just embedded once, indeed.
But it does show up twice in the "Attachments" sidebar in Acrobat Reader.
I do not understand PDF format and in the text edit, it was a mixture of text and binary. But it seems the issue is that PurePDF creates two references to the embedded file if you use pdf_SetAFile this way. Obviously it must create a reference when you pdf_EmbedFile() . But then it seems to create a 2nd one when you create the file annotation.
So, this may be called a bug.
I had a quick look in the PurePDF sources, but they are too big to understand without any documentation in a short time.
Thank you,
Wolfgang
Re: [Module] PurePDF
Posted: Thu Feb 01, 2018 10:21 pm
by normeus
Wolfgang2,
If you want to attach a file use the command to attach a file:
Code: Select all
pdf_EmbedFile("filename","description of this file if you like")
You don't need anything else. The rest of example 29 shows how to create an Annotation which points to the internal file.
The side effect is that you see 2 pointers to the attachment.
1 from Annotation and 2nd one from Attachment.
I use annotations because the people that use my pdfs do not know how to look at attachments tab so I have to create a "click on this link Annotation."
They will never know there are two links.
Both of the links should work the same. if they don't you might have a setting in your pdf reader that prevents opening attachments or annotations with attachments.
For more info about Attachments see:
http://www.purebasic.fr/english/viewtop ... 03#p517703
Thank you.
Norm.
Re: [Module] PurePDF
Posted: Fri Jun 01, 2018 9:37 am
by Wolfgang2
normeus, thanks for the explenation and sorry for the long delay of my reply.
So, this is a feature. All OK.
Thank you,
Wolfgang2
Re: [Module] PurePDF
Posted: Fri Jun 01, 2018 1:03 pm
by Wolfgang2
normeus, I have another issue with purePDF:
Embedding fonts that are on windows system as "TrueType collection font file" ( .ttc ) crashes purePDF.
I need to create chinese PDF files that need to be readable on any PC, so font needs to be embedded.
As I cannot guarantee which fonts are available on the PC that runs my program, I had the idea to let the user choose a font in the program setup.
Now, the issue is that there is no way to see if a font is regular truetype ( .ttf) or the above mentioned TrueType font collection ( .ttc)
I am also not awary of any way to check this within the PB code.
The fact that trying to embedd a .ttc font crashes the program with an memory access error makes this a pretty bad issue.
Excample code:
Code: Select all
XIncludeFile "PurePdfModule.pbi"
Global title.s = "PDF font embedding test"
PDF::Create()
PDF::AddPage()
PDF::SetFont("SimSun","",12)
PDF::Text(10,10,"这是一个嵌入式字体(SimSun Size 12)")
Define file$="purePDF_EmbedFonts.pdf"
PDF::Save(file$)
RunProgram(file$)
This does crash the program with a memory access error in line 1230 of PurePdfModule:
Code: Select all
formatID = ipdf_EndianW(*subtable\format)
Code: Select all
[14:01:08] Waiting for executable to start...
[14:01:08] Executable type: Windows - x64 (64bit, Unicode)
[14:01:08] Executable started.
[14:01:08] [ERROR] PurePdfModule.pbi (Line: 1230)
[14:01:08] [ERROR] Invalid memory access. (read error at address 178311806)
The same code with "SimHei" Font ( .ttf) does work as expected.
Unfortunately I am not good enough in either, PB or PDF, to fix that issue on my own.
So, any hint where to look at / what to do is very appreciated.
Thank you,
Wolfgang2
Re: [Module] PurePDF
Posted: Wed Jul 18, 2018 6:50 pm
by morosh
Hello:
Seems not working with unicode strings:
Code: Select all
XIncludeFile "E:\install\dvd1\dev_soft\purebasic\extra\PurePdfModule\PurePdfModule.pbi"
;XIncludeFile "PurePdfModule.pbi"
;Unicode example
;===============
Define File$
File$=GetFilePart(#PB_Compiler_File)
File$=Mid(File$,1,Len(File$)-Len(GetExtensionPart(File$))-1)
PDF::Create()
PDF::AddPage()
PDF::SetFont("Arial","",28)
PDF::Text(20,30,"Hello السلام عليكم")
PDF::Save(File$+".pdf")
RunProgram(File$+".pdf")
any tips?
thanks
Re: [Module] PurePDF
Posted: Sun May 26, 2019 11:30 am
by PhilGeorges
Thank you, my problem (specific font on Mac Osx) is now fixed. PDF file is now perfect !
Very Good work, useful !
Re: [Module] PurePDF
Posted: Mon Jun 10, 2019 12:04 pm
by Thorsten1867
'PurePDF' has been replaced by 'pbPDFModule.pbi'
Re: [Module] PurePDF
Posted: Wed Nov 06, 2019 10:33 am
by collectordave
Trying to display € in PDF using code below:-
Code: Select all
IncludeFile "pbPDFModule.pbi"
PDF::Create(0)
PDF::AddPage(0)
PDF::SetFont(0, "Arial", "B", 16)
PDF::Cell(0, StrF(PDF::GetPageWidth(0), 0) + "x" + StrF(PDF::GetPageHeight(0), 0) + "€m€m€", 40, 10, #True)
PDF::Save(0,"Testing.PDF")
RunProgram("Open" ,Chr(34) + "Testing.PDF" + Chr(34),"")
Running on my MAC the € sign does not appear at all.
Re: [Module] PurePDF
Posted: Wed Nov 06, 2019 11:33 am
by collectordave
A little more info
Changed € to char(128) and it shows a euro symbol in the pdf.
Re: [Module] PurePDF
Posted: Thu Jul 20, 2023 2:58 pm
by skinkairewalker
have a way to import other pdf and edit it ?