Skip to content

Size of PDF file generated is high #2987

Answered by JorjMcKie
shashikulk asked this question in Q&A
Discussion options

You must be logged in to vote

The method dynamically pulls in all required fonts. These may be several. Asian fonts typically are large, but the number of glyphs that you actually use in your text is small.
Therefore you should make sure to

  • build font subsets which only contain the glyphs that are actually in use
  • save the file with all available compression options

Please try the following code version:

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.subset_fonts()
doc.ez_save(pdffil…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by shashikulk
Comment options

You must be logged in to vote
10 replies
@shashikulk
Comment options

@shashikulk
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
not a bug not a bug / user error / unable to reproduce
2 participants
Converted from issue

This discussion was converted from issue #2983 on January 08, 2024 08:50.