embedº¯ÊýÔõôʹÓÃpdf
embed º¯ÊýÔÊÐí½«ÍⲿÎļþ£¨ÈçͼÏñ¡¢×ÖÌå¡¢Îĵµ£©Ç¶Èëµ½ pdf ÖУ¬ÎÞÐ轫ÆäÎïÀí´æ´¢ÔÚ pdf ÎļþÄÚ¡£°ì·¨°üÀ¨£º½¨Éè pdf Îĵµ¡¢×¼±¸Ç¶ÈëÎļþ¡¢Å²Óà embed º¯Êý¡¢Ö¸¶¨Ç¶ÈëÎļþµÄλÖá£Óŵã°üÀ¨¼õС pdf ¾Þϸ¡¢È·±£Îļþ·Ö·¢¡¢Àû±ã´¦Öóͷ£¡£ÈõµãÊÇÔöÌíÖØ´óÐÔ¡¢Ó°Ïì¼ÓÔØʱ¼äºÍÐÔÄÜ¡£
embed º¯ÊýÔÚ PDF ÖеÄʹÓÃ
embed º¯ÊýÔÚ PDF ÖÐÓÃÓÚ½«ÍⲿÎļþǶÈ뵽Ŀ½ñÎĵµÖС£ËüÔÊÐíÄ㽫ͼÏñ¡¢×ÖÌåºÍÎĵµµÈÆäËûÎļþ²åÈëµ½ PDF ÖУ¬¶øÎÞÐ轫ËüÃÇÎïÀí´æ´¢ÔÚ PDF ÎļþÄÚ¡£
Óï·¨£º
embed(file, type, name, description, mimetype, subfile)
µÇ¼ºó¸´ÖÆ
²ÎÊý£º
file£ºÒªÇ¶ÈëµÄÎļþ·¾¶¡£
type£ºÎļþÀàÐÍ£¬ÀýÈç “Image” »ò “Font¡±¡£
name£ºÇ¶ÈëÎļþÔÚ PDF ÖеÄÃû³Æ¡£
description£ºÇ¶ÈëÎļþµÄÐÎò¡£
mimetype£ºÇ¶ÈëÎļþµÄ MIME ÀàÐÍ£¬ÀýÈç “image/png”¡£
subfile£ºÈôÊÇǶÈëµÄÎļþÊÇÒ»¸ö¸´ºÏÎļþ£¨Èç PDF »ò DOC£©£¬Ôò´Ë²ÎÊýÖ¸¶¨ÒªÇ¶ÈëµÄÎļþÖеÄÌض¨×ÓÎļþ¡£
°ì·¨£º
½¨Éè PDF Îĵµ£ºÊ¹Óà PDF ¿â£¨Èç pdfium »ò poppler£©½¨Éè»ò·¿ªÒ»¸ö PDF Îĵµ¡£
×¼±¸ÒªÇ¶ÈëµÄÎļþ£ºÈ·¶¨ÒªÇ¶ÈëµÄÎļþ²¢»ñÈ¡Æä·¾¶¡£
ŲÓà embed º¯Êý£ºÊ¹Óà embed º¯Êý½«ÎļþǶÈëµ½ PDF ÎĵµÖС£
Ö¸¶¨Ç¶ÈëÎļþµÄλÖãºÊ¹Óà pdf_add_object »òÀàËƺ¯Êý½«Ç¶ÈëÎļþÌí¼Óµ½ PDF ÎĵµÖС£
ʾÀý£º
import pdfrw input_pdf = pdfrw.PdfReader("input.pdf") image_path = "image.png" pdfrw.EmbeddedFiles.embed(input_pdf, type="Image", name="MyImage", file=image_path) with pdfrw.PdfWriter() as output_pdf: output_pdf.write(input_pdf) output_pdf.stream.seek(0) output_pdf.write("embedded.pdf")
µÇ¼ºó¸´ÖÆ
Óŵ㣺
¼õС PDF Îļþ¾Þϸ£¬ÌØÊâÊǵ±Ç¶ÈëµÄÎļþ½Ï´óʱ¡£
È·±£Ç¶ÈëµÄÎļþÓë PDF ÎĵµÒ»Æð·Ö·¢¡£
Àû±ãÓëÆäËûÎļþÒ»Æð´¦Öóͷ£ PDF Îĵµ¡£
Èõµã£º
ÔöÌí PDF ÎĵµµÄÖØ´óÐÔ¡£
ǶÈëµÄÎļþ¿ÉÄÜ»áÓ°ÏìÎĵµµÄ¼ÓÔØʱ¼äºÍÐÔÄÜ¡£
ÒÔÉϾÍÊÇembedº¯ÊýÔõôʹÓÃpdfµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡