How to insert dynamic picture in PDF Document (ADOBE PRO or FoxIT)

74 views Asked by At

I have a PDF document with one first page where I want to put a image based on the path + filename of the external image-file (JPG).

If I change the picture (keeping path and filename), I want that the image on this (PDF) first page, automatically show the right image/picture

Target: I have two pictures (one file with a blue car "bluecar.jpg" and another file with a red car "redcar.jpg") On that PDF first-page, I want to display the content of my JPG-File: c:\temp\car.jpg

Scenario / desired solution: If I save the image of the "blue car" with the filename: c:\temp\car.jpg ... in the PDF document should be the "blue car"

If I save the image of the "red car" in the same path with the same filename: c:\temp\car.jpg ... in the PDF document should be displayed the "red car" image

How can I show images in a PDF document (can be done with FoxIT or ADOBE) based on the real file content ? ... like fields displaying data based on the external .FDF file ?

I try to put an image and test if I change the original file, that image would change... but it keeps still the same image, that I used at the first time.

No image automatically refresh will happen...

2

There are 2 answers

0
K J On

This is perfectly possible in a PDF, but yet again impractical outside of a corporate or personal user domain where the paths are secured.

from https://superuser.com/questions/368486/link-to-image-within-pdf-and-have-the-image-displayed/1809997#1809997

Normally all image content in a PDF is embedded in the file. But PDF allows image data to be stored in external files by the use of external streams or Alternate Images. Standardized subsets of PDF, including PDF/A and PDF/X, prohibit these features.

Really I don't see the value it is easier to use a viewer with 2 images or write 2 separate PDFs without field annotation or hyperlink annotation. any command line script can use multiple images but needs to allow for image file size thus not a working way to fix a pdf as constant.

However below it is done by "imagestreaming". So here the Minimal Working Example filename is very simply "imagestream.jpg" note the remote image filesize is not declared , making it more workable as a constant wrapper. However, the pixel area (density of JPG) is fixed, so here we set that remote width by height in number of pixels.

4 0 obj
<</BitsPerComponent 8/ColorSpace/DeviceRGB/FFilter/DCTDecode/Length 0/Subtype/Image/Type/XObject
/Width 3648/Height 2736/F(V:/temp/car.jpg)>>
stream

The security in Adobe Products now requires the source file folder be added as secured. Most other viewers will simply fail to run such framed contents since they could be on the dark side.

First Acrobat challenge:

enter image description here

so you add:

enter image description here

%PDF-1.7
%µ¶
1 0 obj <</Pages 2 0 R/Type/Catalog>> endobj
2 0 obj <</Count 1/Kids[3 0 R]/Type/Pages>> endobj
3 0 obj <</Parent 2 0 R/Resources<</XObject<</Im1 4 0 R>>>>/Contents 5 0 R/MediaBox[0 0 842 595]/Type/Page>> endobj
4 0 obj <</BitsPerComponent 8/ColorSpace/DeviceRGB/F(imagestream.jpg)/FFilter/DCTDecode/Height 2736/Length 1/Subtype/Image/Type/XObject/Width 3648>>
stream
endstream
endobj

5 0 obj <</Length 43>>
stream
q
842 0 0 595 0 0 cm /Im1 Do
Q
q
Q
endstream
endobj

xref
0 6
0000000000 65536 f 
0000000015 00000 n 
0000000060 00000 n 
0000000111 00000 n 
0000000227 00000 n 
0000000401 00000 n 

trailer
<</Size 6/Root 1 0 R>>
startxref
484
%%EOF

Note due to web cut and paste affecting line endings (0D 0A) then when I save above in my device the tail needs to become (note the progressive adding of 1 then 2 then 3!).

xref
0 6
0000000000 65536 f 
0000000016 00000 n 
0000000062 00000 n 
0000000114 00000 n 
0000000231 00000 n 
0000000406 00000 n 

trailer
<</Size 6/Root 1 0 R>>
startxref
495
%%EOF

enter image description here

You need to replace car image then close and reopen the PDF to see the change since Adobe locks files whilst open. Foxit has a security switch where that may be overridden, however I could not get such files to work in Foxit or other PDF viewers.

enter image description here

0
K J On

I am adding another answer since I described the older Adobe method of image streaming is impractical. However in your question, you ask if there was a way using FDF which is of course more widely acceptable.

So we don't need any fields the "Target AnyCar.PDF" can be totally "blank", or as you wish it to be, since AcroForm Field Data is not part of the core PDF. Now we can click on the red or blue car and it opens the blank form PDF on page 1. We can (if the header is identical in date and ID etc.) instantly flip backwards and forwards between the 2.

enter image description here

The problem with image FDF is they need to be prepared as a PDF when templating the first time. Unlike most text variants they are carrying Binary so harder to massage in Notepad.

Here is AnyCar.PDF; you can see it is "blank"

%PDF-1.7
%µ¶
1 0 obj <</Pages 2 0 R/Type/Catalog>> endobj
2 0 obj <</Count 1/Kids[3 0 R]/Type/Pages>> endobj
3 0 obj <</Parent 2 0 R/Resources<<>>/Contents 4 0 R/MediaBox[0 0 842 595]/Type/Page>> endobj
4 0 obj <</Length 1>>
stream

endstream
endobj

xref
0 5
0000000000 65536 f 
0000000015 00000 n 
0000000060 00000 n 
0000000111 00000 n 
0000000205 00000 n 

trailer
<</Size 5/Root 1 0 R>>
startxref
253
%%EOF

FDF header red or blue before the main image,
but note here some corrupted by paste the binary stream data

%FDF-1.2
%âãÏÓ
1 0 obj
<</FDF<</Annots[2 0 R 3 0 R]/F(/C/temp/AnyCar.pdf)/ID[<><>]/UF(/C/temp/AnyCar.pdf)>>/Type/Catalog>>
endobj
2 0 obj
<</AP<</N 4 0 R>>/C[0.898026 0.133331 0.215683]/CreationDate(D:2023)/F 4/M(D:2023)/NM(b9f7594f-066f-420c-afe5-b6549088e74b)/Name/#23JbE7G96_cFv_-JwPzq18CC/Page 0/Popup 3 0 R/Rect[60.0000 185.000 780.000 413.000]/Subj(RedCar)/Subtype/Stamp/T(Dynamic)/Type/Annot>>
endobj
3 0 obj
<</F 28/Open false/Page 0/Parent 2 0 R/Rect[842.0 298.079 1046.0 412.079]/Subtype/Popup/Type/Annot>>
endobj
4 0 obj
<</BBox[0.0 0.0 720.0 228.0]/Filter[/FlateDecode]/FormType 1/Length 69/Matrix[1.0 0.0 0.0 1.0 0.0 0.0]/Name/FRM/Resources<</ExtGState<</FXE1 6 0 R>>/XObject<</FXX1 5 0 R>>>>/Subtype/Form/Type/XObject>>stream
H‰*ä*BrW€0ŠÒÊ/ ÎâÒw‹p5TH/V(T07‚¨02² Óɹ
@ÙC—|…@.0 çW²
endstream
endobj
5 0 obj
<</BitsPerComponent 8/ColorSpace/DeviceRGB/Filter/FlateDecode/Height 950/Length 1760549/Subtype/Image/Type/XObject/Width 3000>>stream

... red or blue image

endstream
endobj
6 0 obj
<</BM/Normal/CA 1/ca 1>>
endobj
trailer
<</Root 1 0 R>>
%%EOF