It is currently Thu Jun 20, 2013 11:18 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 303 posts ]  Go to page Previous  1 ... 15, 16, 17, 18, 19, 20, 21  Next
Author Message
 Post subject: Re: PurePDF Version 2.0
PostPosted: Thu Jun 07, 2012 12:56 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2009 10:33 am
Posts: 283
Hi, What is the best way to "wrap" an image in PDF. I have multiple image files I need to convert to PDFs but I don't seem to find a way to specify page width and height. My images are of various dimensions and A4 or Letter size page is not suitable in this case. Thanks.

_________________
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 7 HP (x64), DirectX 11, PureBasic 5.11 (x86)


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Thu Jun 07, 2012 1:09 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2919
Location: Wales, UK
...There is actually a huge list of page formats to choose from, so you may find that's enough:

#PDF_PAGE_FORMAT_4A0
#PDF_PAGE_FORMAT_2A0
#PDF_PAGE_FORMAT_A0
#PDF_PAGE_FORMAT_A1
#PDF_PAGE_FORMAT_A2
#PDF_PAGE_FORMAT_A3
#PDF_PAGE_FORMAT_A4
#PDF_PAGE_FORMAT_A5
#PDF_PAGE_FORMAT_A6
#PDF_PAGE_FORMAT_A7
#PDF_PAGE_FORMAT_A8
#PDF_PAGE_FORMAT_A9
#PDF_PAGE_FORMAT_A10
#PDF_PAGE_FORMAT_B0
#PDF_PAGE_FORMAT_B1
#PDF_PAGE_FORMAT_B2
#PDF_PAGE_FORMAT_B3
#PDF_PAGE_FORMAT_B4
#PDF_PAGE_FORMAT_B5
#PDF_PAGE_FORMAT_B6
#PDF_PAGE_FORMAT_B7
#PDF_PAGE_FORMAT_B8
#PDF_PAGE_FORMAT_B9
#PDF_PAGE_FORMAT_B10
#PDF_PAGE_FORMAT_C0
#PDF_PAGE_FORMAT_C1
#PDF_PAGE_FORMAT_C2
#PDF_PAGE_FORMAT_C3
#PDF_PAGE_FORMAT_C4
#PDF_PAGE_FORMAT_C5
#PDF_PAGE_FORMAT_C6
#PDF_PAGE_FORMAT_C7
#PDF_PAGE_FORMAT_C8
#PDF_PAGE_FORMAT_C9
#PDF_PAGE_FORMAT_C10
#PDF_PAGE_FORMAT_RA0
#PDF_PAGE_FORMAT_RA1
#PDF_PAGE_FORMAT_RA2
#PDF_PAGE_FORMAT_RA3
#PDF_PAGE_FORMAT_RA4
#PDF_PAGE_FORMAT_SRA0
#PDF_PAGE_FORMAT_SRA1
#PDF_PAGE_FORMAT_SRA2
#PDF_PAGE_FORMAT_SRA3
#PDF_PAGE_FORMAT_SRA4
#PDF_PAGE_FORMAT_LETTER
#PDF_PAGE_FORMAT_LEGAL
#PDF_PAGE_FORMAT_EXECUTIVE
#PDF_PAGE_FORMAT_FOLIO

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Thu Jun 07, 2012 1:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2009 10:33 am
Posts: 283
I have an image that has dimensions of 1714x1800. Which page mode should I choose then (it needs to done automatically)? We also have some US cheques scans. Obviously there should be some kind of command to set exact page dimensions. Think I used a library called HaruPDF and I believe it did have such command. Thanks.

Oh and by the way I cant leave white-space around the images, page size should match image size pixel to pixel (libtiff does this).

_________________
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 7 HP (x64), DirectX 11, PureBasic 5.11 (x86)


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Thu Jun 07, 2012 3:36 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2919
Location: Wales, UK
OK, try this:
Code:
#PDF_PAGE_FORMAT_CUSTOM = "1714.00,1800.00"

            sPdfName.s = "C:\TestCustomFormat.pdf"
          sImageFile.s = "C:\TestCustomFormat.png"

                  pdf_Create("P","mm",#PDF_PAGE_FORMAT_CUSTOM)
              pdf_SetMargins(0.00,0.00,0.00)
            pdf_SetFillColor(230,230,230) ;Light Gray
                 pdf_AddPage()
                   pdf_Image(sImageFile,0,0,1800)

                    pdf_Save(sPdfName)

                  ;View PDF created
                  RunProgram(sPdfName)


That's not an official constant but it seems to work. Note though that Adobe Reader for one does not like zero margins, so you may have to accept a tiny margin.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Thu Jun 07, 2012 9:14 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2009 10:33 am
Posts: 283
Vacuum, thanks for your code snippet, but unfortunately I only get like quarter of an image saved as PDF. Feels like it has higher DPI resolution than the page and gets truncated. 200 dpi btw. Any ideas how to fix that? Thanks.

_________________
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 7 HP (x64), DirectX 11, PureBasic 5.11 (x86)


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Thu Jun 07, 2012 11:10 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2919
Location: Wales, UK
Not sure. I think PDF perhaps is using a 'printing' dpi?

For example, #PDF_PAGE_FORMAT_A4 = 595.28,841.89

On screen, an A4 sheet is 794 x 1123 pix @ 96dpi (210 x 297mm)

Edit: Tried a 96dpi A4 image and a 200dpi A4 image. Both verify in Adobe reader as A4 (210 x 297mm).

The image is a simple 10 x 10 grid.

PDF of 96dpi image: The top left-hand corner of the image fills the whole page.
PDF of 200dpi image: None of the grid can be seen.

Code:
         ;  sPdfName.s = "C:\TestA4Format96dpi.pdf"
          ;sImageFile.s = "C:\TestA4Format96dpi.png"

            sPdfName.s = "C:\TestA4Format200dpi.pdf"
          sImageFile.s = "TestA4Format200dpi.png"

                  pdf_Create("P","mm",#PDF_PAGE_FORMAT_A4) ;210x297mm; 794x1123pix
              pdf_SetMargins(0.00,0.00,0.00)
            pdf_SetFillColor(230,230,230) ;Light Gray
                 pdf_AddPage()
                   pdf_Image(sImageFile,0,0,1123)

                    pdf_Save(sPdfName)

                  ;View PDF created
                  RunProgram(sPdfName)


Link to files: TestA4FormatPDF.rar

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Fri Jun 08, 2012 1:20 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2009 10:33 am
Posts: 283
This is exactly what I'm getting with my own image. Even if width and height is specified for pdf_image only top left corner is visible in the produced file. :?

_________________
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 7 HP (x64), DirectX 11, PureBasic 5.11 (x86)


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Fri Jun 08, 2012 3:24 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2919
Location: Wales, UK
Doh! I have the pdf_Image function wrongly primed. - firstly, the last value is width not height and secondly it should be in pdf document units, in this case mm!

So:
Code:
pdf_Image(sImageFile,0,0,210)
works fine for the 96dpi image. 200dpi image still fails.

Going back to custome size, @96dpi, the whole image is displayed in the PDF file, but the page size is wrong:
Code:
#PDF_PAGE_FORMAT_CUSTOM = "1714.00,1800.00" ;453.50 x 476.25mm or 17.85 x 18.75in

            sPdfName.s = "C:\TestCustomFormat.pdf"
          sImageFile.s = "C:\TestCustomFormat.png"

                  pdf_Create("P","mm",#PDF_PAGE_FORMAT_CUSTOM) ;453.50 x 476.25mm; 1714 x 1800pix
              pdf_SetMargins(0.00,0.00,0.00)
            pdf_SetFillColor(230,230,230) ;Light Gray
                 pdf_AddPage()
                   pdf_Image(sImageFile,0,0,453.5)

                    pdf_Save(sPdfName)

                  ;View PDF created
                  RunProgram(sPdfName)

                 ;resulting PDF page size is 604.70 x 635.00mm

What we are trying to do, in Adobe jargon, is to define a 'Postscript Custom Page Size'.
I think that maybe the lib is selecting the nearest size that fits? Maybe not. Hopefully ABBKlaus can put us out of our misery :D

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Sat Jun 09, 2012 3:57 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 525
Location: Germany
Is it possible to add encryption (AES) with a password to open the PDF to PurePDF? (Adobe PDF Reference => Syntax - Encryption)

_________________
PS: Sorry for my bad English. My native language is German.

My PureBasic-Project: EasySetup - SetupMaker for your programs
[Windows 7 x64] [PB V5.0x]


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Sat Jun 09, 2012 7:22 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1071
Location: Germany
@olby, have you tried using point in PDF_Create() ?

Code:
#PDF_PAGE_FORMAT_CUSTOM="1024,768"
Define sPdfName.s = "C:\TestCustomFormat.pdf"
Define sImageFile.s = "c:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg"

pdf_Create("P","pt",#PDF_PAGE_FORMAT_CUSTOM)
pdf_SetMargins(0,0,0)
pdf_SetFillColor(230,230,230) ;Light Gray
pdf_AddPage()
pdf_Image(sImageFile,0,0,1024)

pdf_Save(sPdfName)

;View PDF created
RunProgram(sPdfName)


@Thorsten1867, atm no. I think it was removed because of the redesign of PurePDF. It was using RC4 if i remember correctly :oops:

_________________
http://www.PureBasicPower.de


Last edited by ABBKlaus on Sat Jun 09, 2012 9:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Sat Jun 09, 2012 9:24 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2009 10:33 am
Posts: 283
Spiffy! It works, thanks very much Klaus.

_________________
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 7 HP (x64), DirectX 11, PureBasic 5.11 (x86)


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Sat Jun 09, 2012 9:33 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1071
Location: Germany
Glad i could help :P
Does it really worked without the missing #PDF_PAGE_FORMAT_CUSTOM ?

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Sat Jun 09, 2012 10:30 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2919
Location: Wales, UK
Strange, not working on my machine (PB4.61, WinXP 32) with the custom sized image:
Code:
#PDF_PAGE_FORMAT_CUSTOM="1714.00,1800.00"
Define   sPdfName.s = "C:\TestCustomFormat.pdf"
Define sImageFile.s = "TestCustomFormat.png"

pdf_Create("P","pt",#PDF_PAGE_FORMAT_CUSTOM)
pdf_SetMargins(0,0,0)
pdf_SetFillColor(230,230,230) ;Light Gray
pdf_AddPage()
pdf_Image(sImageFile,0,0,1714)

pdf_Save(sPdfName)

;View PDF created
RunProgram(sPdfName)

PDF Result is a blank page, 604.7 x 635.0mm. The size should be 453.5 x 476.25mm

The 200dpi image also does not display:
Code:
#PDF_PAGE_FORMAT_CUSTOM="794.00,1123.00"
Define   sPdfName.s = "C:\TestA4Format200dpi.pdf"
Define sImageFile.s = "TestA4Format200dpi.png"

pdf_Create("P","pt",#PDF_PAGE_FORMAT_CUSTOM)
pdf_SetMargins(0,0,0)
pdf_SetFillColor(230,230,230) ;Light Gray
pdf_AddPage()
pdf_Image(sImageFile,0,0,794)

pdf_Save(sPdfName)

;View PDF created
RunProgram(sPdfName)

PDF Page is 280 x 396mm when it should be 210 x 297mm
Really confused now! :mrgreen:

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Sat Jun 09, 2012 11:09 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1071
Location: Germany
Simple mathematics :wink:
Code:
ptinch.d=1/72 ; each point is ~0.014" (1/72 of an inch)
ptcm.d=(1/72)*25.4 ; each point is ~0.35 mm
Debug ptinch ; 0.013888888888888888
Debug ptcm ; 0.35277777777777775
Debug 1714 * ptcm ; 604.66111111111104
Debug 1800 * ptcm ; 634.99999999999989
Debug  794 * ptcm ; 280.10555555555555
Debug 1123 * ptcm ; 396.16944444444442

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
 Post subject: Re: PurePDF Version 2.0
PostPosted: Sat Jun 09, 2012 11:30 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2009 10:33 am
Posts: 283
Genius! :) Thanks for clarifying the metrics.

_________________
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 7 HP (x64), DirectX 11, PureBasic 5.11 (x86)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 303 posts ]  Go to page Previous  1 ... 15, 16, 17, 18, 19, 20, 21  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye