Hello Aspose Team,
I am working on a solution where I convert Visio files to PDF using Aspose.Diagram for Python via .NET.
I would like to know if it is possible to change the font size of the paragraphs present in the resulting PDF pages after the conversion.
Specifically:
- When I convert a Visio file to PDF, I need to modify the font size of all text paragraphs in the output PDF.
- Is there any way to achieve this either during the conversion process itself or by post-processing the generated PDF using Aspose.PDF for Python?
If you could please share some sample code or point me to relevant API methods to change the font size of text in the generated PDF, I would greatly appreciate it.
Thank you for your support.
@sayen_vv
Cause
Changing the font size of paragraphs in a PDF generated from Visio files is not directly supported during the conversion process using Aspose.Diagram. However, you can achieve this by post-processing the generated PDF using Aspose.PDF.
Solution
You can follow these steps to change the font size of paragraphs in the resulting PDF:
- Convert the Visio file to PDF using Aspose.Diagram.
- Load the generated PDF using Aspose.PDF.
- Iterate through the paragraphs in the PDF and change their font size.
Code
Here’s a sample code snippet demonstrating how to change the font size of all text paragraphs in a PDF after conversion:
import aspose.diagram as diagram
import aspose.pdf as pdf
# Step 1: Convert Visio to PDF
visio_file = "input.vsdx"
pdf_file = "output.pdf"
# Load the Visio diagram
diagram_document = diagram.Diagram(visio_file)
# Save as PDF
diagram_document.save(pdf_file, diagram.SaveFileFormat.PDF)
# Step 2: Load the generated PDF
pdf_document = pdf.Document(pdf_file)
# Step 3: Change font size of all paragraphs
for page in pdf_document.pages:
for paragraph in page.paragraphs:
# Change font size
for text_segment in paragraph.text_segments:
text_segment.text_state.font_size = 14 # Set desired font size
# Save the modified PDF
pdf_document.save("modified_output.pdf")
Next Steps
- Adjust the font size value in the code as needed.
- Test the code with your Visio files to ensure the desired output.
- If you encounter any issues, please reach out for further assistance.
This solution should effectively help you modify the font size in your PDF. Let me know if you need any more help!
@sayen_vv
Thanks for your inquiry.
We can use Aspose.Diagram for Python via .NET to change the font size of shape:
shape.chars[0].size.value = 0.2
If you’d like to use Aspose.PDF to change the font size of the paragraphs present in the resulting PDF , please post your question in the PDF forum, and the Aspose.PDF team will get back to you.
Thanks.