code
New Member
Posts: 30
|
Post by code on Sept 9, 2022 17:21:44 GMT -5
Hi, I am trying to make .pdf file with image ( link) I want to open the .jpg file and write the data to the pdf... Wich way i must do that? Thx, code edit: [something like: open "C:\pdfim\myimage.jpg" for input as #fIn content$ =input$( #fIn, lof( #fIn)) close #fIn but then with: open "C:\pdfim\myimage.jpg" for binary as #1 here the code .... .... .... ]
|
|
|
Post by Walt Decker on Sept 10, 2022 8:25:19 GMT -5
FileBytes = INPUT$(#1, LOF(#1))
|
|
|
Post by Rod on Sept 10, 2022 8:46:14 GMT -5
To input the file contents of a .jpg
open "C:\pdfim\myimage.jpg" for input as #fIn
content$ =input$( #fIn, lof( #fIn))
To save that data or append that data
open "C:\pdfim\my.pdf" for append as #pdf #pdf content$;
This will only work if the pdf is meant to contain an entire .jpg file within its file contents and you append it to the correct position. Not sure if that is the case, more likely a pointer/path to the .jpg is contained within the .pdf
|
|
|
Post by xxgeek on Sept 10, 2022 10:31:24 GMT -5
Curiosity led me to ..... It isn't as simple as copying a jpg file into a pdf file, or just appending the binary code of the jpg file to the pdf file. Have a look - blog.idrsolutions.com/understanding-the-pdf-file-format/If you scroll down there is a section on images. Quite complicated. There is no file pointer in the pdf file pointing to the jpg file. (not like HTML) Images are not stored inside a PDF file as Tiff or PNG or JPG images. They are stored as the binary pixel data along with the Colorspace used by that data. There is a pointer to the binary code "stream" of the embedded jpg code. See - blog.idrsolutions.com/how-are-images-displayed-in-a-pdf-file/Copied from the link Each image has a name (like Im4). In the stream, you would see the command /Im4
DO
which draws the image at this point with the current graphics Matrix.
The actual image IM4 is defined in a separate object which is listed in the Resources table. In this case it is Object 20 0 R.
XObject<</Im4 20 0 R/Im3 21 0 R>>
Object 20 contains the information on the image and the compressed binary pixel data
20 0 obj <<
/Filter/DCTDecode
/Type/XObject/
Length 33555/
Height 413/
BitsPerComponent 8/
ColorSpace 17 0 R/
Subtype/Image/
Width 633
>>
stream (binary pixel data follows)
Hope the info on those pages can help you code. I know you've been working on this for a while now. It may not be easy but it is doable.[/code]
|
|
code
New Member
Posts: 30
|
Post by code on Sept 10, 2022 13:04:40 GMT -5
Thank you all for the info! I guess i was looking for something that doesn't exist. I have to consider next step... Thx again! Regards, code
|
|