Skip to content

Size of PDF file generated is high #2983

@shashikulk

Description

@shashikulk

First of all, thanks for adding insert_htmlbox() feature/function to pymupdf. It works very well for non-English script. However, I have one observation regarding file size.

I am using insert_htmlbox() to insert some text (English as well as Devanagari) to my file. The size of the file created seems very high for the amount of text content I am writing to it. Below is the code I am using as an example in which I am writing only 1 line of Devanagari text to it, and the size of the pdf file generated is 242 KB.

import fitz_new as fitz
import os
out_path = str(os.getcwd()) + '/output/'
pdffilename = out_path + 'sample.pdf'

doc = fitz.open()
page = doc.new_page()
text = "PDF तयार करण्याचा हा माझा पहिला दस्तऐवज प्रकल्प आहे"
rect = fitz.Rect(30, 30, 480, 55)
page.insert_htmlbox(rect, text)
doc.save(pdffilename)
doc.close()

If I add more lines of text using insert_htmlbox(), the file size increases proportionately. Is there any way to keep the pdf file size to low?

I am using latest pymupdf with Python 3.10.x and Win11.

regards,
Shashikant

Metadata

Metadata

Assignees

No one assigned

    Labels

    not a bugnot a bug / user error / unable to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions