Issue with including a JPEG-data-structure into to PDF-code as an XObject

In a java program, I want to insert at coding level a JPEG image (which already exists in the java-code/program as a BufferedImage) into a PDF-file.

Since the PDF-viewer (XChange-Editor) does not show the JPEG within the created PDF-File and
Acrobat Reader at least claims an issue with the PDF file (unfortunately without given any information about the nature of the error) there must be something wrong with the PDF-file (“itself”, I would say).

Concerned Files:

  • The source-JPEG-file is ATH_Logo_Pythagoras_241225b.jpg.
  • The created PDF-file is ATH_PDF-JPEG-Test_241227a.pdf (note: this contains a yellow rectagle just o be sure that anything is drawn in the PDF. The JPEG should be drawn on top of this rectangle; To keep the contents of the page human-readable I apply the only a Filter for the XObject “XO01” which contains the JPEG part).
  • Test-extract from the created PDF-File: ATH_PDF-JPEG-Test_241227a_jpgextract.jpg
  • Re-written JPEG List in order to check if the reading/writing-process of the JPEG is valid: ATH_Logo_Pythagoras_241225b.jpg_rewrite.jpg

If I extract the JPEG code from ATH_PDF-JPEG-Test_241227a.pdf (simply by copying the PDF-file and stripping everything in front of the start of the XObject-stream (line 93, zero-based position: 1317) and everything behind the corresponding “endstream” (pos 7355) I get the file ATH_PDF-JPEG-Test_241227a_jpgextract.jpg.

QUESTION(s):

Since this JPEG file is shown as expected (e.g, by means of IrfanView) , I think that the the byte-sequence between position 1317 and 7355 in the target-PDF should represent at least a correct JPEG-data structure.
Therefore I have the following Questions

  1. Is the assumption correct, that the byte-sequence in an PDF-XObject stream is identical to the byte-sequence wihin a “pure” JPEG-file ?
  2. I declared JPXDecode as the Filter for the XObject stream. Is this false? (if so, what else should I do?)
  3. Are there any issues with the XObject dictionary (XObject “/XO01”, starting as object nr. 8 from pos. 1169)?

Thank you very much!

ADDITIONAL NOTES

  1. Apart from stackoverflow my source of information is PDFSPEC

  2. The question concerns the pure PDF-code. It is not the goal to use (i.e. no external applications or libraries (except the java(8)-standard-libraries)

  3. The code is written by an own java code of a larger application, which produces a PDF-file from the scratch.

  4. Within this java-code, I read the source-JPEG-File ATH_Logo_Pythagoras_241225b.jpg (from a local directory) with javax.imageio.ImageIO.read(...) into a BufferedImage. Later in the code this BufferedImage is written with ImageIO.write(imageBuffer, "jpg", outputStream) ; into an ByteArrayOutputStream outputStream which is written with outstream.write(outputStream.toByteArray()) to the PrintStream outstream of the target-PDF-File.

  5. For test-purposes, in the same code I did read and immediately rewrite the source-JPEG ATH_Logo_Pythagoras_241225b.jpg to ATH_Logo_Pythagoras_241225b.jpg_rewrite.jpg JPEG-file. Both files have the same content what means, that reading / writing shpuld actually not be the issue!?. The code for this operation is

              String srcflnm = "ATH_Logo_Pythagoras_241225b.jpg" ;
              BufferedImage image  = ImageIO.read(new File(srcflnm)) ;
              String outflnm  = srcflnm + "_new.jpg" ;
              ByteArrayOutputStream outputStream  = new ByteArrayOutputStream() ;
              ImageIO.write(image, "jpg", outputStream ) ;
              PrintStream outstream   = new PrintStream(outflnm) ;
              outstream.write(outputStream.toByteArray()) ;
              outstream.close() ;    
    

New contributor

ATH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Issue with including a JPEG-data-structure into to PDF-code as an XObject

In a java program, I want to insert at coding level a JPEG image (which already exists in the java-code/program as a BufferedImage) into a PDF-file.

Since the PDF-viewer (XChange-Editor) does not show the JPEG within the created PDF-File and
Acrobat Reader at least claims an issue with the PDF file (unfortunately without given any information about the nature of the error) there must be something wrong with the PDF-file (“itself”, I would say).

Concerned Files:

  • The source-JPEG-file is ATH_Logo_Pythagoras_241225b.jpg.
  • The created PDF-file is ATH_PDF-JPEG-Test_241227a.pdf (note: this contains a yellow rectagle just o be sure that anything is drawn in the PDF. The JPEG should be drawn on top of this rectangle; To keep the contents of the page human-readable I apply the only a Filter for the XObject “XO01” which contains the JPEG part).
  • Test-extract from the created PDF-File: ATH_PDF-JPEG-Test_241227a_jpgextract.jpg
  • Re-written JPEG List in order to check if the reading/writing-process of the JPEG is valid: ATH_Logo_Pythagoras_241225b.jpg_rewrite.jpg

If I extract the JPEG code from ATH_PDF-JPEG-Test_241227a.pdf (simply by copying the PDF-file and stripping everything in front of the start of the XObject-stream (line 93, zero-based position: 1317) and everything behind the corresponding “endstream” (pos 7355) I get the file ATH_PDF-JPEG-Test_241227a_jpgextract.jpg.

QUESTION(s):

Since this JPEG file is shown as expected (e.g, by means of IrfanView) , I think that the the byte-sequence between position 1317 and 7355 in the target-PDF should represent at least a correct JPEG-data structure.
Therefore I have the following Questions

  1. Is the assumption correct, that the byte-sequence in an PDF-XObject stream is identical to the byte-sequence wihin a “pure” JPEG-file ?
  2. I declared JPXDecode as the Filter for the XObject stream. Is this false? (if so, what else should I do?)
  3. Are there any issues with the XObject dictionary (XObject “/XO01”, starting as object nr. 8 from pos. 1169)?

Thank you very much!

ADDITIONAL NOTES

  1. Apart from stackoverflow my source of information is PDFSPEC

  2. The question concerns the pure PDF-code. It is not the goal to use (i.e. no external applications or libraries (except the java(8)-standard-libraries)

  3. The code is written by an own java code of a larger application, which produces a PDF-file from the scratch.

  4. Within this java-code, I read the source-JPEG-File ATH_Logo_Pythagoras_241225b.jpg (from a local directory) with javax.imageio.ImageIO.read(...) into a BufferedImage. Later in the code this BufferedImage is written with ImageIO.write(imageBuffer, "jpg", outputStream) ; into an ByteArrayOutputStream outputStream which is written with outstream.write(outputStream.toByteArray()) to the PrintStream outstream of the target-PDF-File.

  5. For test-purposes, in the same code I did read and immediately rewrite the source-JPEG ATH_Logo_Pythagoras_241225b.jpg to ATH_Logo_Pythagoras_241225b.jpg_rewrite.jpg JPEG-file. Both files have the same content what means, that reading / writing shpuld actually not be the issue!?. The code for this operation is

              String srcflnm = "ATH_Logo_Pythagoras_241225b.jpg" ;
              BufferedImage image  = ImageIO.read(new File(srcflnm)) ;
              String outflnm  = srcflnm + "_new.jpg" ;
              ByteArrayOutputStream outputStream  = new ByteArrayOutputStream() ;
              ImageIO.write(image, "jpg", outputStream ) ;
              PrintStream outstream   = new PrintStream(outflnm) ;
              outstream.write(outputStream.toByteArray()) ;
              outstream.close() ;    
    

New contributor

ATH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Issue with including a JPEG-data-structure into to PDF-code as an XObject

In a java program, I want to insert at coding level a JPEG image (which already exists in the java-code/program as a BufferedImage) into a PDF-file.

Since the PDF-viewer (XChange-Editor) does not show the JPEG within the created PDF-File and
Acrobat Reader at least claims an issue with the PDF file (unfortunately without given any information about the nature of the error) there must be something wrong with the PDF-file (“itself”, I would say).

Concerned Files:

  • The source-JPEG-file is ATH_Logo_Pythagoras_241225b.jpg.
  • The created PDF-file is ATH_PDF-JPEG-Test_241227a.pdf (note: this contains a yellow rectagle just o be sure that anything is drawn in the PDF. The JPEG should be drawn on top of this rectangle; To keep the contents of the page human-readable I apply the only a Filter for the XObject “XO01” which contains the JPEG part).
  • Test-extract from the created PDF-File: ATH_PDF-JPEG-Test_241227a_jpgextract.jpg
  • Re-written JPEG List in order to check if the reading/writing-process of the JPEG is valid: ATH_Logo_Pythagoras_241225b.jpg_rewrite.jpg

If I extract the JPEG code from ATH_PDF-JPEG-Test_241227a.pdf (simply by copying the PDF-file and stripping everything in front of the start of the XObject-stream (line 93, zero-based position: 1317) and everything behind the corresponding “endstream” (pos 7355) I get the file ATH_PDF-JPEG-Test_241227a_jpgextract.jpg.

QUESTION(s):

Since this JPEG file is shown as expected (e.g, by means of IrfanView) , I think that the the byte-sequence between position 1317 and 7355 in the target-PDF should represent at least a correct JPEG-data structure.
Therefore I have the following Questions

  1. Is the assumption correct, that the byte-sequence in an PDF-XObject stream is identical to the byte-sequence wihin a “pure” JPEG-file ?
  2. I declared JPXDecode as the Filter for the XObject stream. Is this false? (if so, what else should I do?)
  3. Are there any issues with the XObject dictionary (XObject “/XO01”, starting as object nr. 8 from pos. 1169)?

Thank you very much!

ADDITIONAL NOTES

  1. Apart from stackoverflow my source of information is PDFSPEC

  2. The question concerns the pure PDF-code. It is not the goal to use (i.e. no external applications or libraries (except the java(8)-standard-libraries)

  3. The code is written by an own java code of a larger application, which produces a PDF-file from the scratch.

  4. Within this java-code, I read the source-JPEG-File ATH_Logo_Pythagoras_241225b.jpg (from a local directory) with javax.imageio.ImageIO.read(...) into a BufferedImage. Later in the code this BufferedImage is written with ImageIO.write(imageBuffer, "jpg", outputStream) ; into an ByteArrayOutputStream outputStream which is written with outstream.write(outputStream.toByteArray()) to the PrintStream outstream of the target-PDF-File.

  5. For test-purposes, in the same code I did read and immediately rewrite the source-JPEG ATH_Logo_Pythagoras_241225b.jpg to ATH_Logo_Pythagoras_241225b.jpg_rewrite.jpg JPEG-file. Both files have the same content what means, that reading / writing shpuld actually not be the issue!?. The code for this operation is

              String srcflnm = "ATH_Logo_Pythagoras_241225b.jpg" ;
              BufferedImage image  = ImageIO.read(new File(srcflnm)) ;
              String outflnm  = srcflnm + "_new.jpg" ;
              ByteArrayOutputStream outputStream  = new ByteArrayOutputStream() ;
              ImageIO.write(image, "jpg", outputStream ) ;
              PrintStream outstream   = new PrintStream(outflnm) ;
              outstream.write(outputStream.toByteArray()) ;
              outstream.close() ;    
    

New contributor

ATH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật